mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 12:21:25 -08:00
diff-mode auto-refines only after a successful motion
Prior to this patch (if enabled) auto-refinement would kick in after all hunk navigation commands, even if the motion failed. This would result in a situation where the hunk navigation would signal an error and beep, but yet still accomplish potentially useful work, by auto-refining. This patch moves the auto-refinement code to only run when a motion was successful * lisp/vc/diff-mode.el (diff--internal-hunk-next, diff--internal-hunk-prev): Removed auto-refinement-triggering code * lisp/vc/diff-mode.el (diff--wrap-navigation): Added auto-refinement-triggering code
This commit is contained in:
parent
6b6abe0dba
commit
e5ef59b87d
1 changed files with 21 additions and 18 deletions
|
|
@ -551,23 +551,7 @@ next hunk if TRY-HARDER is non-nil; otherwise signal an error."
|
|||
|
||||
;; Define diff-{hunk,file}-{prev,next}
|
||||
(easy-mmode-define-navigation
|
||||
diff--internal-hunk diff-hunk-header-re "hunk" diff-end-of-hunk diff-restrict-view
|
||||
(when diff-auto-refine-mode
|
||||
(unless (prog1 diff--auto-refine-data
|
||||
(setq diff--auto-refine-data
|
||||
(cons (current-buffer) (point-marker))))
|
||||
(run-at-time 0.0 nil
|
||||
(lambda ()
|
||||
(when diff--auto-refine-data
|
||||
(let ((buffer (car diff--auto-refine-data))
|
||||
(point (cdr diff--auto-refine-data)))
|
||||
(setq diff--auto-refine-data nil)
|
||||
(with-local-quit
|
||||
(when (buffer-live-p buffer)
|
||||
(with-current-buffer buffer
|
||||
(save-excursion
|
||||
(goto-char point)
|
||||
(diff-refine-hunk))))))))))))
|
||||
diff--internal-hunk diff-hunk-header-re "hunk" diff-end-of-hunk diff-restrict-view)
|
||||
|
||||
(easy-mmode-define-navigation
|
||||
diff--internal-file diff-file-header-re "file" diff-end-of-file)
|
||||
|
|
@ -605,7 +589,26 @@ to the NEXT marker."
|
|||
|
||||
(when (not (looking-at header-re))
|
||||
(goto-char start)
|
||||
(user-error (format "No %s" what))))))
|
||||
(user-error (format "No %s" what)))
|
||||
|
||||
;; We successfully moved to the next/prev hunk/file. Apply the
|
||||
;; auto-refinement if needed
|
||||
(when diff-auto-refine-mode
|
||||
(unless (prog1 diff--auto-refine-data
|
||||
(setq diff--auto-refine-data
|
||||
(cons (current-buffer) (point-marker))))
|
||||
(run-at-time 0.0 nil
|
||||
(lambda ()
|
||||
(when diff--auto-refine-data
|
||||
(let ((buffer (car diff--auto-refine-data))
|
||||
(point (cdr diff--auto-refine-data)))
|
||||
(setq diff--auto-refine-data nil)
|
||||
(with-local-quit
|
||||
(when (buffer-live-p buffer)
|
||||
(with-current-buffer buffer
|
||||
(save-excursion
|
||||
(goto-char point)
|
||||
(diff-refine-hunk))))))))))))))
|
||||
|
||||
;; These functions all take a skip-hunk-start argument which controls
|
||||
;; whether we skip pre-hunk-start text or not. In interactive uses we
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue