aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2018-11-14 02:14:52 +0200
committerJuri Linkov2018-11-14 02:14:52 +0200
commit2ccfb4b5f43b7592af4efe943c24741370f3eb86 (patch)
tree207d997d45a4bcd7e9b6d7417d7e7c5ae6624d14
parent4a5a17507fe1e12ee02c174350edc479fb01ac01 (diff)
downloademacs-2ccfb4b5f43b7592af4efe943c24741370f3eb86.tar.gz
emacs-2ccfb4b5f43b7592af4efe943c24741370f3eb86.zip
Support VC revisions in diff-goto-source (bug#33319)
* lisp/vc/diff-mode.el (diff-vc-revisions): New defvar. (diff-find-source-location): Call vc-find-revision for non-nil values of 'other', diff-vc-backend, diff-vc-revisions. * lisp/vc/vc.el (vc-diff-internal): Set buffer-local diff-vc-revisions to the list of used revisions. * doc/emacs/files.texi (Diff Mode): Update diff-goto-source for VC-related prefix argument.
-rw-r--r--doc/emacs/files.texi4
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/vc/diff-mode.el16
-rw-r--r--lisp/vc/vc.el2
4 files changed, 24 insertions, 2 deletions
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index 649fa8bcb4d..b47be51e24c 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -1530,6 +1530,10 @@ default jumps to the ``old'' file, and the meaning of the prefix
1530argument is reversed. If the prefix argument is a number greater than 1530argument is reversed. If the prefix argument is a number greater than
15318 (e.g., if you type @kbd{C-u C-u C-c C-c}), then this command also 15318 (e.g., if you type @kbd{C-u C-u C-c C-c}), then this command also
1532sets @code{diff-jump-to-old-file} for the next invocation. 1532sets @code{diff-jump-to-old-file} for the next invocation.
1533If the source file is under version control (@pxref{Version Control}),
1534this jumps to the work file by default. With a prefix argument, jump
1535to the ``old'' revision of the file (@pxref{Old Revisions}), when
1536point is on the old line, or otherwise jump to the ``new'' revision.
1533 1537
1534@item C-c C-e 1538@item C-c C-e
1535@findex diff-ediff-patch 1539@findex diff-ediff-patch
diff --git a/etc/NEWS b/etc/NEWS
index 2f07abb4eb5..2a2010e9d36 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -368,6 +368,10 @@ To disable it, set the new defcustom 'diff-font-lock-refine' to nil.
368*** File headers can be shortened, mimicking Magit's diff format. 368*** File headers can be shortened, mimicking Magit's diff format.
369To enable it, set the new defcustom 'diff-font-lock-prettify to t. 369To enable it, set the new defcustom 'diff-font-lock-prettify to t.
370 370
371*** Prefix arg of 'diff-goto-source' means jump to the old revision
372of the file under version control if point is on an old changed line,
373or to the new revision of the file otherwise.
374
371** Browse-url 375** Browse-url
372 376
373*** The function 'browse-url-emacs' can now visit a URL in selected window. 377*** The function 'browse-url-emacs' can now visit a URL in selected window.
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index cf523685086..8539423eed5 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -55,6 +55,7 @@
55;;; Code: 55;;; Code:
56(eval-when-compile (require 'cl-lib)) 56(eval-when-compile (require 'cl-lib))
57 57
58(autoload 'vc-find-revision "vc")
58(defvar add-log-buffer-file-name-function) 59(defvar add-log-buffer-file-name-function)
59 60
60 61
@@ -104,6 +105,9 @@ when editing big diffs)."
104(defvar diff-vc-backend nil 105(defvar diff-vc-backend nil
105 "The VC backend that created the current Diff buffer, if any.") 106 "The VC backend that created the current Diff buffer, if any.")
106 107
108(defvar diff-vc-revisions nil
109 "The VC revisions compared in the current Diff buffer, if any.")
110
107(defvar diff-outline-regexp 111(defvar diff-outline-regexp
108 "\\([*+][*+][*+] [^0-9]\\|@@ ...\\|\\*\\*\\* [0-9].\\|--- [0-9]..\\)") 112 "\\([*+][*+][*+] [^0-9]\\|@@ ...\\|\\*\\*\\* [0-9].\\|--- [0-9]..\\)")
109 113
@@ -1736,7 +1740,11 @@ NOPROMPT, if non-nil, means not to prompt the user."
1736 (match-string 1))))) 1740 (match-string 1)))))
1737 (file (or (diff-find-file-name other noprompt) 1741 (file (or (diff-find-file-name other noprompt)
1738 (error "Can't find the file"))) 1742 (error "Can't find the file")))
1739 (buf (find-file-noselect file))) 1743 (revision (and other diff-vc-backend
1744 (nth (if reverse 1 0) diff-vc-revisions)))
1745 (buf (if revision
1746 (vc-find-revision file revision diff-vc-backend)
1747 (find-file-noselect file))))
1740 ;; Update the user preference if he so wished. 1748 ;; Update the user preference if he so wished.
1741 (when (> (prefix-numeric-value other-file) 8) 1749 (when (> (prefix-numeric-value other-file) 8)
1742 (setq diff-jump-to-old-file other)) 1750 (setq diff-jump-to-old-file other))
@@ -1862,7 +1870,11 @@ With a prefix argument, try to REVERSE the hunk."
1862`diff-jump-to-old-file' (or its opposite if the OTHER-FILE prefix arg 1870`diff-jump-to-old-file' (or its opposite if the OTHER-FILE prefix arg
1863is given) determines whether to jump to the old or the new file. 1871is given) determines whether to jump to the old or the new file.
1864If the prefix arg is bigger than 8 (for example with \\[universal-argument] \\[universal-argument]) 1872If the prefix arg is bigger than 8 (for example with \\[universal-argument] \\[universal-argument])
1865then `diff-jump-to-old-file' is also set, for the next invocations." 1873then `diff-jump-to-old-file' is also set, for the next invocations.
1874
1875Under version control, the OTHER-FILE prefix arg means jump to the old
1876revision of the file if point is on an old changed line, or to the new
1877revision of the file otherwise."
1866 (interactive (list current-prefix-arg last-input-event)) 1878 (interactive (list current-prefix-arg last-input-event))
1867 ;; When pointing at a removal line, we probably want to jump to 1879 ;; When pointing at a removal line, we probably want to jump to
1868 ;; the old location, and else to the new (i.e. as if reverting). 1880 ;; the old location, and else to the new (i.e. as if reverting).
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index dcfbf26e867..6b7ca02440d 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -987,6 +987,7 @@ Within directories, only files already under version control are noticed."
987(defvar log-view-vc-backend) 987(defvar log-view-vc-backend)
988(defvar log-edit-vc-backend) 988(defvar log-edit-vc-backend)
989(defvar diff-vc-backend) 989(defvar diff-vc-backend)
990(defvar diff-vc-revisions)
990 991
991(defun vc-deduce-backend () 992(defun vc-deduce-backend ()
992 (cond ((derived-mode-p 'vc-dir-mode) vc-dir-backend) 993 (cond ((derived-mode-p 'vc-dir-mode) vc-dir-backend)
@@ -1728,6 +1729,7 @@ Return t if the buffer had changes, nil otherwise."
1728 (set-buffer buffer) 1729 (set-buffer buffer)
1729 (diff-mode) 1730 (diff-mode)
1730 (set (make-local-variable 'diff-vc-backend) (car vc-fileset)) 1731 (set (make-local-variable 'diff-vc-backend) (car vc-fileset))
1732 (set (make-local-variable 'diff-vc-revisions) (list rev1 rev2))
1731 (set (make-local-variable 'revert-buffer-function) 1733 (set (make-local-variable 'revert-buffer-function)
1732 (lambda (_ignore-auto _noconfirm) 1734 (lambda (_ignore-auto _noconfirm)
1733 (vc-diff-internal async vc-fileset rev1 rev2 verbose))) 1735 (vc-diff-internal async vc-fileset rev1 rev2 verbose)))