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.
((derived-mode-p 'change-log-mode)
;; Fix up dates before resolving the conflicts.
(goto-char (point-min))
- (let ((diff-auto-refine-mode nil))
+ (let ((diff-refine nil))
(while (re-search-forward smerge-begin-re nil t)
(smerge-match-conflict)
(smerge-ensure-match 3)
Move to the next hunk-start (@code{diff-hunk-next}). With prefix
argument @var{n}, move forward to the @var{n}th next hunk.
-@findex diff-auto-refine-mode
-@cindex mode, Diff Auto-Refine
-@cindex Diff Auto-Refine mode
-This command has a side effect: it @dfn{refines} the hunk you move to,
-highlighting its changes with better granularity. To disable this
-feature, type @kbd{M-x diff-auto-refine-mode} to toggle off the minor
-mode Diff Auto-Refine mode. To disable Diff Auto-Refine mode by
-default, add this to your init file (@pxref{Hooks}):
-
-@example
-(add-hook 'diff-mode-hook
- (lambda () (diff-auto-refine-mode -1)))
-@end example
+@vindex diff-refine
+By default, Diff mode @dfn{refines} hunks as Emacs displays them,
+highlighting their changes with better granularity. Alternatively, if
+you set @code{diff-refine} to the symbol @code{navigation}, Diff mode
+only refines the hunk you move to with this command or with
+@code{diff-hunk-prev}.
@item M-p
@findex diff-hunk-prev
Move to the previous hunk-start (@code{diff-hunk-prev}). With prefix
argument @var{n}, move back to the @var{n}th previous hunk. Like
-@kbd{M-n}, this has the side-effect of refining the hunk you move to,
-unless you disable Diff Auto-Refine mode.
+@kbd{M-n}, this command refines the hunk you move to if you set
+@code{diff-refine} to the symbol @code{navigation}.
@item M-@}
@findex diff-file-next
(@code{diff-refine-hunk}). This allows you to see exactly which parts
of each changed line were actually changed.
+@vindex diff-refine
+By default, Diff mode refines hunks as Emacs displays them, so you may
+find this command useful if you customize @code{diff-refine} to a
+non-default value.
+
@item C-c C-c
@findex diff-goto-source
@vindex diff-jump-to-old-file
to hg revert.
** Diff mode
-*** Hunks are now automatically refined by default.
-To disable it, set the new defcustom 'diff-font-lock-refine' to nil.
++++
+*** Hunks are now automatically refined by font-lock.
+To disable refinement, set the new defcustom 'diff-refine' to nil.
+To get back the old behavior where hunks are refined as you navigate
+through a diff, set 'diff-refine' to the symbol 'navigate'.
++++
+*** 'diff-auto-refine-mode' is deprecated in favor of 'diff-refine'.
+It is no longer enabled by default and binding it no longer has any
+effect.
+++
*** Better syntax highlighting of Diff hunks.
: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."
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
;; 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))))
(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
;;; 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.
;; 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"])