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 | |
| 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.
| -rw-r--r-- | admin/gitmerge.el | 2 | ||||
| -rw-r--r-- | doc/emacs/files.texi | 28 | ||||
| -rw-r--r-- | etc/NEWS | 11 | ||||
| -rw-r--r-- | lisp/vc/diff-mode.el | 30 | ||||
| -rw-r--r-- | lisp/vc/smerge-mode.el | 4 |
5 files changed, 47 insertions, 28 deletions
diff --git a/admin/gitmerge.el b/admin/gitmerge.el index 4854862a681..edf43797304 100644 --- a/admin/gitmerge.el +++ b/admin/gitmerge.el | |||
| @@ -294,7 +294,7 @@ Returns non-nil if conflicts remain." | |||
| 294 | ((derived-mode-p 'change-log-mode) | 294 | ((derived-mode-p 'change-log-mode) |
| 295 | ;; Fix up dates before resolving the conflicts. | 295 | ;; Fix up dates before resolving the conflicts. |
| 296 | (goto-char (point-min)) | 296 | (goto-char (point-min)) |
| 297 | (let ((diff-auto-refine-mode nil)) | 297 | (let ((diff-refine nil)) |
| 298 | (while (re-search-forward smerge-begin-re nil t) | 298 | (while (re-search-forward smerge-begin-re nil t) |
| 299 | (smerge-match-conflict) | 299 | (smerge-match-conflict) |
| 300 | (smerge-ensure-match 3) | 300 | (smerge-ensure-match 3) |
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index d12d1edae72..a57428230cc 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi | |||
| @@ -1461,26 +1461,19 @@ manipulate and apply parts of patches: | |||
| 1461 | Move to the next hunk-start (@code{diff-hunk-next}). With prefix | 1461 | Move to the next hunk-start (@code{diff-hunk-next}). With prefix |
| 1462 | argument @var{n}, move forward to the @var{n}th next hunk. | 1462 | argument @var{n}, move forward to the @var{n}th next hunk. |
| 1463 | 1463 | ||
| 1464 | @findex diff-auto-refine-mode | 1464 | @vindex diff-refine |
| 1465 | @cindex mode, Diff Auto-Refine | 1465 | By default, Diff mode @dfn{refines} hunks as Emacs displays them, |
| 1466 | @cindex Diff Auto-Refine mode | 1466 | highlighting their changes with better granularity. Alternatively, if |
| 1467 | This command has a side effect: it @dfn{refines} the hunk you move to, | 1467 | you set @code{diff-refine} to the symbol @code{navigation}, Diff mode |
| 1468 | highlighting its changes with better granularity. To disable this | 1468 | only refines the hunk you move to with this command or with |
| 1469 | feature, type @kbd{M-x diff-auto-refine-mode} to toggle off the minor | 1469 | @code{diff-hunk-prev}. |
| 1470 | mode Diff Auto-Refine mode. To disable Diff Auto-Refine mode by | ||
| 1471 | default, add this to your init file (@pxref{Hooks}): | ||
| 1472 | |||
| 1473 | @example | ||
| 1474 | (add-hook 'diff-mode-hook | ||
| 1475 | (lambda () (diff-auto-refine-mode -1))) | ||
| 1476 | @end example | ||
| 1477 | 1470 | ||
| 1478 | @item M-p | 1471 | @item M-p |
| 1479 | @findex diff-hunk-prev | 1472 | @findex diff-hunk-prev |
| 1480 | Move to the previous hunk-start (@code{diff-hunk-prev}). With prefix | 1473 | Move to the previous hunk-start (@code{diff-hunk-prev}). With prefix |
| 1481 | argument @var{n}, move back to the @var{n}th previous hunk. Like | 1474 | argument @var{n}, move back to the @var{n}th previous hunk. Like |
| 1482 | @kbd{M-n}, this has the side-effect of refining the hunk you move to, | 1475 | @kbd{M-n}, this command refines the hunk you move to if you set |
| 1483 | unless you disable Diff Auto-Refine mode. | 1476 | @code{diff-refine} to the symbol @code{navigation}. |
| 1484 | 1477 | ||
| 1485 | @item M-@} | 1478 | @item M-@} |
| 1486 | @findex diff-file-next | 1479 | @findex diff-file-next |
| @@ -1518,6 +1511,11 @@ Highlight the changes of the hunk at point with a finer granularity | |||
| 1518 | (@code{diff-refine-hunk}). This allows you to see exactly which parts | 1511 | (@code{diff-refine-hunk}). This allows you to see exactly which parts |
| 1519 | of each changed line were actually changed. | 1512 | of each changed line were actually changed. |
| 1520 | 1513 | ||
| 1514 | @vindex diff-refine | ||
| 1515 | By default, Diff mode refines hunks as Emacs displays them, so you may | ||
| 1516 | find this command useful if you customize @code{diff-refine} to a | ||
| 1517 | non-default value. | ||
| 1518 | |||
| 1521 | @item C-c C-c | 1519 | @item C-c C-c |
| 1522 | @findex diff-goto-source | 1520 | @findex diff-goto-source |
| 1523 | @vindex diff-jump-to-old-file | 1521 | @vindex diff-jump-to-old-file |
| @@ -479,8 +479,15 @@ and compares their entire trees. | |||
| 479 | to hg revert. | 479 | to hg revert. |
| 480 | 480 | ||
| 481 | ** Diff mode | 481 | ** Diff mode |
| 482 | *** Hunks are now automatically refined by default. | 482 | +++ |
| 483 | To disable it, set the new defcustom 'diff-font-lock-refine' to nil. | 483 | *** Hunks are now automatically refined by font-lock. |
| 484 | To disable refinement, set the new defcustom 'diff-refine' to nil. | ||
| 485 | To get back the old behavior where hunks are refined as you navigate | ||
| 486 | through a diff, set 'diff-refine' to the symbol 'navigate'. | ||
| 487 | +++ | ||
| 488 | *** 'diff-auto-refine-mode' is deprecated in favor of 'diff-refine'. | ||
| 489 | It is no longer enabled by default and binding it no longer has any | ||
| 490 | effect. | ||
| 484 | 491 | ||
| 485 | +++ | 492 | +++ |
| 486 | *** Better syntax highlighting of Diff hunks. | 493 | *** Better syntax highlighting of Diff hunks. |
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 |
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 @@ | |||
| 44 | ;;; Code: | 44 | ;;; Code: |
| 45 | 45 | ||
| 46 | (eval-when-compile (require 'cl-lib)) | 46 | (eval-when-compile (require 'cl-lib)) |
| 47 | (require 'diff-mode) ;For diff-auto-refine-mode. | 47 | (require 'diff-mode) ;For diff-refine. |
| 48 | (require 'newcomment) | 48 | (require 'newcomment) |
| 49 | 49 | ||
| 50 | ;;; The real definition comes later. | 50 | ;;; The real definition comes later. |
| @@ -264,7 +264,7 @@ Can be nil if the style is undecided, or else: | |||
| 264 | 264 | ||
| 265 | ;; Define smerge-next and smerge-prev | 265 | ;; Define smerge-next and smerge-prev |
| 266 | (easy-mmode-define-navigation smerge smerge-begin-re "conflict" nil nil | 266 | (easy-mmode-define-navigation smerge smerge-begin-re "conflict" nil nil |
| 267 | (if diff-auto-refine-mode | 267 | (if diff-refine |
| 268 | (condition-case nil (smerge-refine) (error nil)))) | 268 | (condition-case nil (smerge-refine) (error nil)))) |
| 269 | 269 | ||
| 270 | (defconst smerge-match-names ["conflict" "upper" "base" "lower"]) | 270 | (defconst smerge-match-names ["conflict" "upper" "base" "lower"]) |