diff options
| author | Charles A. Roelli | 2019-02-24 16:13:13 +0100 |
|---|---|---|
| committer | Charles A. Roelli | 2019-03-03 21:31:05 +0100 |
| commit | d6b3e5bbc5e14c32f3faad9f1481ec16807ac2fe (patch) | |
| tree | d6c054f8db81eb0fbdaa90a4046703b6b28f2612 /lisp/vc/diff-mode.el | |
| parent | 81ae21792b3d840a2f11e4c3a682e1e30799c37f (diff) | |
| download | emacs-d6b3e5bbc5e14c32f3faad9f1481ec16807ac2fe.tar.gz emacs-d6b3e5bbc5e14c32f3faad9f1481ec16807ac2fe.zip | |
Merge diff-font-lock-refine and diff-auto-refine-mode into diff-refine
This change was discussed in Bug#32991.
* admin/gitmerge.el (gitmerge-resolve): Bind 'diff-refine'
instead of 'diff-auto-refine-mode' to nil.
* doc/emacs/files.texi (Diff Mode): Explain 'diff-refine'
instead of 'diff-auto-refine-mode' in the documentation of
'diff-hunk-next' and 'diff-hunk-prev'. Mention in the
documentation of 'diff-refine-hunk' that refining is already
done by default.
* etc/NEWS (Diff mode): Explain renamed 'diff-refine' variable
and mention deprecation and disabling of
'diff-auto-refine-mode'.
* lisp/vc/diff-mode.el (diff-font-lock-refine): Rename to
'diff-refine' and allow choices nil, 'font-lock' and 'navigation'.
(diff-auto-refine-mode): Disable it by default, make it
obsolete and make it set 'diff-refine' appropriately to keep
backward compatibility.
(diff-hunk-next, diff-hunk-prev): Adapt to rename of
diff-auto-refine-mode and ensure that refining only happens
when calling these commands interactively.
(diff--font-lock-refined): Adapt to rename of
diff-font-lock-refine.
* lisp/vc/smerge-mode.el (smerge-next, smerge-prev): Check
that 'diff-refine' is set instead of checking
'diff-auto-refine-mode' when deciding whether to refine a
conflict.
Diffstat (limited to 'lisp/vc/diff-mode.el')
| -rw-r--r-- | lisp/vc/diff-mode.el | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index b22a5888984..2c790a28561 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el | |||
| @@ -94,10 +94,18 @@ when editing big diffs)." | |||
| 94 | :type 'hook | 94 | :type 'hook |
| 95 | :options '(diff-delete-empty-files diff-make-unified)) | 95 | :options '(diff-delete-empty-files diff-make-unified)) |
| 96 | 96 | ||
| 97 | (defcustom diff-font-lock-refine t | 97 | (defcustom diff-refine 'font-lock |
| 98 | "If non-nil, font-lock highlighting includes hunk refinement." | 98 | "If non-nil, enable hunk refinement. |
| 99 | |||
| 100 | The value `font-lock' means to refine during font-lock. | ||
| 101 | The value `navigation' means to refine each hunk as you visit it | ||
| 102 | with `diff-hunk-next' or `diff-hunk-prev'. | ||
| 103 | |||
| 104 | You can always manually refine a hunk with `diff-refine-hunk'." | ||
| 99 | :version "27.1" | 105 | :version "27.1" |
| 100 | :type 'boolean) | 106 | :type '(choice (const :tag "Don't refine hunks" nil) |
| 107 | (const :tag "Refine hunks during font-lock" font-lock) | ||
| 108 | (const :tag "Refine hunks during navigation" navigation))) | ||
| 101 | 109 | ||
| 102 | (defcustom diff-font-lock-prettify nil | 110 | (defcustom diff-font-lock-prettify nil |
| 103 | "If non-nil, font-lock will try and make the format prettier." | 111 | "If non-nil, font-lock will try and make the format prettier." |
| @@ -262,9 +270,15 @@ Diff Auto Refine mode is a buffer-local minor mode used with | |||
| 262 | changes in detail as the user visits hunks. When transitioning | 270 | changes in detail as the user visits hunks. When transitioning |
| 263 | from disabled to enabled, it tries to refine the current hunk, as | 271 | from disabled to enabled, it tries to refine the current hunk, as |
| 264 | well." | 272 | well." |
| 265 | :group 'diff-mode :init-value t :lighter nil ;; " Auto-Refine" | 273 | :group 'diff-mode :init-value nil :lighter nil ;; " Auto-Refine" |
| 266 | (when diff-auto-refine-mode | 274 | (if diff-auto-refine-mode |
| 267 | (condition-case-unless-debug nil (diff-refine-hunk) (error nil)))) | 275 | (progn |
| 276 | (customize-set-variable 'diff-refine 'navigation) | ||
| 277 | (condition-case-unless-debug nil (diff-refine-hunk) (error nil))) | ||
| 278 | (customize-set-variable 'diff-refine nil))) | ||
| 279 | (make-obsolete 'diff-auto-refine-mode "set `diff-refine' instead." "27.1") | ||
| 280 | (make-obsolete-variable 'diff-auto-refine-mode | ||
| 281 | "set `diff-refine' instead." "27.1") | ||
| 268 | 282 | ||
| 269 | ;;;; | 283 | ;;;; |
| 270 | ;;;; font-lock support | 284 | ;;;; font-lock support |
| @@ -623,7 +637,7 @@ next hunk if TRY-HARDER is non-nil; otherwise signal an error." | |||
| 623 | ;; Define diff-{hunk,file}-{prev,next} | 637 | ;; Define diff-{hunk,file}-{prev,next} |
| 624 | (easy-mmode-define-navigation | 638 | (easy-mmode-define-navigation |
| 625 | diff-hunk diff-hunk-header-re "hunk" diff-end-of-hunk diff-restrict-view | 639 | diff-hunk diff-hunk-header-re "hunk" diff-end-of-hunk diff-restrict-view |
| 626 | (when diff-auto-refine-mode | 640 | (when (and (eq diff-refine 'navigation) (called-interactively-p 'interactive)) |
| 627 | (unless (prog1 diff--auto-refine-data | 641 | (unless (prog1 diff--auto-refine-data |
| 628 | (setq diff--auto-refine-data | 642 | (setq diff--auto-refine-data |
| 629 | (cons (current-buffer) (point-marker)))) | 643 | (cons (current-buffer) (point-marker)))) |
| @@ -2146,7 +2160,7 @@ Call FUN with two args (BEG and END) for each hunk." | |||
| 2146 | 2160 | ||
| 2147 | (defun diff--font-lock-refined (max) | 2161 | (defun diff--font-lock-refined (max) |
| 2148 | "Apply hunk refinement from font-lock." | 2162 | "Apply hunk refinement from font-lock." |
| 2149 | (when diff-font-lock-refine | 2163 | (when (eq diff-refine 'font-lock) |
| 2150 | (when (get-char-property (point) 'diff--font-lock-refined) | 2164 | (when (get-char-property (point) 'diff--font-lock-refined) |
| 2151 | ;; Refinement works over a complete hunk, whereas font-lock limits itself | 2165 | ;; Refinement works over a complete hunk, whereas font-lock limits itself |
| 2152 | ;; to highlighting smallish chunks between point..max, so we may be | 2166 | ;; to highlighting smallish chunks between point..max, so we may be |