diff options
author | Charles A. Roelli <charles@aurox.ch> | 2019-02-24 16:13:13 +0100 |
---|---|---|
committer | Charles A. Roelli <charles@aurox.ch> | 2019-03-03 21:31:05 +0100 |
commit | d6b3e5bbc5e14c32f3faad9f1481ec16807ac2fe (patch) | |
tree | d6c054f8db81eb0fbdaa90a4046703b6b28f2612 /lisp/vc | |
parent | 81ae21792b3d840a2f11e4c3a682e1e30799c37f (diff) | |
download | emacs-d6b3e5bbc5e14c32f3faad9f1481ec16807ac2fe.tar.gz |
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')
-rw-r--r-- | lisp/vc/diff-mode.el | 30 | ||||
-rw-r--r-- | lisp/vc/smerge-mode.el | 4 |
2 files changed, 24 insertions, 10 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)." :type 'hook :options '(diff-delete-empty-files diff-make-unified)) -(defcustom diff-font-lock-refine t - "If non-nil, font-lock highlighting includes hunk refinement." +(defcustom diff-refine 'font-lock + "If non-nil, enable hunk refinement. + +The value `font-lock' means to refine during font-lock. +The value `navigation' means to refine each hunk as you visit it +with `diff-hunk-next' or `diff-hunk-prev'. + +You can always manually refine a hunk with `diff-refine-hunk'." :version "27.1" - :type 'boolean) + :type '(choice (const :tag "Don't refine hunks" nil) + (const :tag "Refine hunks during font-lock" font-lock) + (const :tag "Refine hunks during navigation" navigation))) (defcustom diff-font-lock-prettify nil "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 changes in detail as the user visits hunks. When transitioning from disabled to enabled, it tries to refine the current hunk, as well." - :group 'diff-mode :init-value t :lighter nil ;; " Auto-Refine" - (when diff-auto-refine-mode - (condition-case-unless-debug nil (diff-refine-hunk) (error nil)))) + :group 'diff-mode :init-value nil :lighter nil ;; " Auto-Refine" + (if diff-auto-refine-mode + (progn + (customize-set-variable 'diff-refine 'navigation) + (condition-case-unless-debug nil (diff-refine-hunk) (error nil))) + (customize-set-variable 'diff-refine nil))) +(make-obsolete 'diff-auto-refine-mode "set `diff-refine' instead." "27.1") +(make-obsolete-variable 'diff-auto-refine-mode + "set `diff-refine' instead." "27.1") ;;;; ;;;; font-lock support @@ -623,7 +637,7 @@ next hunk if TRY-HARDER is non-nil; otherwise signal an error." ;; Define diff-{hunk,file}-{prev,next} (easy-mmode-define-navigation diff-hunk diff-hunk-header-re "hunk" diff-end-of-hunk diff-restrict-view - (when diff-auto-refine-mode + (when (and (eq diff-refine 'navigation) (called-interactively-p 'interactive)) (unless (prog1 diff--auto-refine-data (setq diff--auto-refine-data (cons (current-buffer) (point-marker)))) @@ -2146,7 +2160,7 @@ Call FUN with two args (BEG and END) for each hunk." (defun diff--font-lock-refined (max) "Apply hunk refinement from font-lock." - (when diff-font-lock-refine + (when (eq diff-refine 'font-lock) (when (get-char-property (point) 'diff--font-lock-refined) ;; Refinement works over a complete hunk, whereas font-lock limits itself ;; to highlighting smallish chunks between point..max, so we may be diff --git a/lisp/vc/smerge-mode.el b/lisp/vc/smerge-mode.el index 02cee44a3ae..6b1df6603df 100644 --- a/lisp/vc/smerge-mode.el +++ b/lisp/vc/smerge-mode.el @@ -44,7 +44,7 @@ ;;; Code: (eval-when-compile (require 'cl-lib)) -(require 'diff-mode) ;For diff-auto-refine-mode. +(require 'diff-mode) ;For diff-refine. (require 'newcomment) ;;; The real definition comes later. @@ -264,7 +264,7 @@ Can be nil if the style is undecided, or else: ;; Define smerge-next and smerge-prev (easy-mmode-define-navigation smerge smerge-begin-re "conflict" nil nil - (if diff-auto-refine-mode + (if diff-refine (condition-case nil (smerge-refine) (error nil)))) (defconst smerge-match-names ["conflict" "upper" "base" "lower"]) |