diff options
| author | Dima Kogan | 2016-12-19 23:23:14 -0800 |
|---|---|---|
| committer | Dima Kogan | 2016-12-24 21:42:02 -0800 |
| commit | e5ef59b87da5c2ddfa22f7342efe29b3eea6ed97 (patch) | |
| tree | 8bd80d19534ed1e97400bdd912fb2883b82fba12 /lisp/vc | |
| parent | 6b6abe0dba6a9a2e5f78aac3814421886e7a184f (diff) | |
| download | emacs-e5ef59b87da5c2ddfa22f7342efe29b3eea6ed97.tar.gz emacs-e5ef59b87da5c2ddfa22f7342efe29b3eea6ed97.zip | |
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
Diffstat (limited to 'lisp/vc')
| -rw-r--r-- | lisp/vc/diff-mode.el | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index d74ff2f5c99..75fd420922a 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el | |||
| @@ -551,23 +551,7 @@ next hunk if TRY-HARDER is non-nil; otherwise signal an error." | |||
| 551 | 551 | ||
| 552 | ;; Define diff-{hunk,file}-{prev,next} | 552 | ;; Define diff-{hunk,file}-{prev,next} |
| 553 | (easy-mmode-define-navigation | 553 | (easy-mmode-define-navigation |
| 554 | diff--internal-hunk diff-hunk-header-re "hunk" diff-end-of-hunk diff-restrict-view | 554 | diff--internal-hunk diff-hunk-header-re "hunk" diff-end-of-hunk diff-restrict-view) |
| 555 | (when diff-auto-refine-mode | ||
| 556 | (unless (prog1 diff--auto-refine-data | ||
| 557 | (setq diff--auto-refine-data | ||
| 558 | (cons (current-buffer) (point-marker)))) | ||
| 559 | (run-at-time 0.0 nil | ||
| 560 | (lambda () | ||
| 561 | (when diff--auto-refine-data | ||
| 562 | (let ((buffer (car diff--auto-refine-data)) | ||
| 563 | (point (cdr diff--auto-refine-data))) | ||
| 564 | (setq diff--auto-refine-data nil) | ||
| 565 | (with-local-quit | ||
| 566 | (when (buffer-live-p buffer) | ||
| 567 | (with-current-buffer buffer | ||
| 568 | (save-excursion | ||
| 569 | (goto-char point) | ||
| 570 | (diff-refine-hunk)))))))))))) | ||
| 571 | 555 | ||
| 572 | (easy-mmode-define-navigation | 556 | (easy-mmode-define-navigation |
| 573 | diff--internal-file diff-file-header-re "file" diff-end-of-file) | 557 | diff--internal-file diff-file-header-re "file" diff-end-of-file) |
| @@ -605,7 +589,26 @@ to the NEXT marker." | |||
| 605 | 589 | ||
| 606 | (when (not (looking-at header-re)) | 590 | (when (not (looking-at header-re)) |
| 607 | (goto-char start) | 591 | (goto-char start) |
| 608 | (user-error (format "No %s" what)))))) | 592 | (user-error (format "No %s" what))) |
| 593 | |||
| 594 | ;; We successfully moved to the next/prev hunk/file. Apply the | ||
| 595 | ;; auto-refinement if needed | ||
| 596 | (when diff-auto-refine-mode | ||
| 597 | (unless (prog1 diff--auto-refine-data | ||
| 598 | (setq diff--auto-refine-data | ||
| 599 | (cons (current-buffer) (point-marker)))) | ||
| 600 | (run-at-time 0.0 nil | ||
| 601 | (lambda () | ||
| 602 | (when diff--auto-refine-data | ||
| 603 | (let ((buffer (car diff--auto-refine-data)) | ||
| 604 | (point (cdr diff--auto-refine-data))) | ||
| 605 | (setq diff--auto-refine-data nil) | ||
| 606 | (with-local-quit | ||
| 607 | (when (buffer-live-p buffer) | ||
| 608 | (with-current-buffer buffer | ||
| 609 | (save-excursion | ||
| 610 | (goto-char point) | ||
| 611 | (diff-refine-hunk)))))))))))))) | ||
| 609 | 612 | ||
| 610 | ;; These functions all take a skip-hunk-start argument which controls | 613 | ;; These functions all take a skip-hunk-start argument which controls |
| 611 | ;; whether we skip pre-hunk-start text or not. In interactive uses we | 614 | ;; whether we skip pre-hunk-start text or not. In interactive uses we |