emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/diff-hl ecd3a3e 3/4: fixup! more generalized diff-hl-se


From: ELPA Syncer
Subject: [elpa] externals/diff-hl ecd3a3e 3/4: fixup! more generalized diff-hl-set-reference-rev
Date: Wed, 6 Jan 2021 21:57:09 -0500 (EST)

branch: externals/diff-hl
commit ecd3a3e2c12680d013be23d9d7ee6f49a3394504
Author: AmaiKinono <amaikinono@gmail.com>
Commit: AmaiKinono <amaikinono@gmail.com>

    fixup! more generalized diff-hl-set-reference-rev
---
 README.md  |  4 ++--
 diff-hl.el | 34 +++++++++++++++++++++++-----------
 2 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/README.md b/README.md
index c5dd945..b64d228 100644
--- a/README.md
+++ b/README.md
@@ -15,8 +15,8 @@ The package also contains auxiliary modes:
 * `diff-hl-margin-mode` changes the highlighting function to
   use the margin instead of the fringe.
 * `diff-hl-amend-mode` sets the reference revision to the one before
-  recent one. Also, you could use `diff-hl-log-view-set-reference-rev`
-  to set it to any revision, see its docstring for details.
+  recent one. Also, you could use `diff-hl-set-reference-rev` to set
+  it to any revision, see its docstring for details.
 * `diff-hl-flydiff-mode` implements highlighting changes on the fly.
   It requires Emacs 24.4 or newer.
 
diff --git a/diff-hl.el b/diff-hl.el
index 10579a1..6328862 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -35,7 +35,7 @@
 ;; `diff-hl-revert-hunk'     C-x v n
 ;; `diff-hl-previous-hunk'   C-x v [
 ;; `diff-hl-next-hunk'       C-x v ]
-;; `diff-hl-log-view-set-reference-rev'
+;; `diff-hl-set-reference-rev'
 ;; `diff-hl-reset-reference-rev'
 ;;
 ;; The mode takes advantage of `smartrep' if it is installed.
@@ -688,26 +688,38 @@ The value of this variable is a mode line template as in
     (turn-on-diff-hl-mode)))
 
 ;;;###autoload
-(defun diff-hl-log-view-set-reference-rev ()
-  "In *vc-change-log* buffer, set the current one as reference revision.
-Call `vc-print-log' or `vc-print-root-log' first, then use this
-command on a revision, `diff-hl-mode' will show changes against
-this revision.
+(defun diff-hl-set-reference-rev (&optional rev)
+  "Set the reference revision globally to REV.
+When called interactively, REV is get from contexts:
+
+- In a log view buffer, it uses the revision of current entry.
+Call `vc-print-log' or `vc-print-root-log' first to open a log
+view buffer.
+- In a VC annotate buffer, it uses the revision of current line.
+- In other situations, get the revision name at point.
 
 Notice that this sets the reference revision globally, so in
 files from other repositories, `diff-hl-mode' will not highlight
 changes correctly, until you run `diff-hl-reset-reference-rev'.
 
-Also notice that `diff-hl-amend-mode' will override this.
-Disable it to reveal the effect of this command."
+Also notice that this will disable `diff-hl-amend-mode' in
+buffers that enables it, since `diff-hl-amend-mode' overrides its
+effect."
   (interactive)
-  (let* ((rev (log-view-current-tag)))
-    (unless rev
-      (user-error "Not in a change log buffer"))
+  (let* ((rev (or rev
+                  (and (equal major-mode 'vc-annotate-mode)
+                       (car (vc-annotate-extract-revision-at-line)))
+                  (log-view-current-tag)
+                  (thing-at-point 'symbol t))))
+    (if rev
+        (message "Set reference rev to %s" rev)
+      (user-error "Can't find a revision around point"))
     (setq diff-hl-reference-revision rev))
   (dolist (buf (buffer-list))
     (with-current-buffer buf
       (when diff-hl-mode
+        (when diff-hl-amend-mode
+          (diff-hl-amend-mode -1))
         (diff-hl-update)))))
 
 ;;;###autoload



reply via email to

[Prev in Thread] Current Thread [Next in Thread]