diff options
| author | Jim Porter | 2023-12-14 11:31:27 -0800 |
|---|---|---|
| committer | Jim Porter | 2023-12-27 14:22:18 -0800 |
| commit | ea4cbb3aae3c7f72ef04337bc2db7292909ca9a1 (patch) | |
| tree | 9fed8a224f144f742bfb36df82a10e6f5a1a7fe5 | |
| parent | 9e0eeb2d49ccd443bb667be9231fe932be67bb10 (diff) | |
| download | emacs-ea4cbb3aae3c7f72ef04337bc2db7292909ca9a1.tar.gz emacs-ea4cbb3aae3c7f72ef04337bc2db7292909ca9a1.zip | |
Abbreviate the VC revision in vc-annotate's buffer name
* lisp/vc/vc-hooks.el (vc-use-short-revision): New variable.
(vc-short-revision): New function.
* lisp/vc/vc-annotate.el (vc-annotate-use-short-revision): New
option...
(vc-annotate): ... use it.
* lisp/vc/vc-git.el (vc-git--rev-parse): Consult
'vc-use-short-revision'.
* etc/NEWS: Announce this change (bug#67062).
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/vc/vc-annotate.el | 10 | ||||
| -rw-r--r-- | lisp/vc/vc-git.el | 7 | ||||
| -rw-r--r-- | lisp/vc/vc-hooks.el | 12 |
4 files changed, 32 insertions, 3 deletions
| @@ -497,6 +497,12 @@ switch is used, commands to see the diff of the old revision ('d'), | |||
| 497 | check out an old file version ('f') or annotate it right away ('a'), | 497 | check out an old file version ('f') or annotate it right away ('a'), |
| 498 | also work on revisions which precede renames. | 498 | also work on revisions which precede renames. |
| 499 | 499 | ||
| 500 | --- | ||
| 501 | *** 'vc-annotate' now abbreviates the Git revision in the buffer name. | ||
| 502 | When using the Git backend, 'vc-annotate' will use an abbreviated | ||
| 503 | revision identifier in its buffer name. To restore the previous | ||
| 504 | behavior, set 'vc-annotate-use-short-revision' to nil. | ||
| 505 | |||
| 500 | *** New option 'vc-git-file-name-changes-switches'. | 506 | *** New option 'vc-git-file-name-changes-switches'. |
| 501 | It allows tweaking the thresholds for rename and copy detection. | 507 | It allows tweaking the thresholds for rename and copy detection. |
| 502 | 508 | ||
diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el index de6c3adbbdb..cfca7cbfac0 100644 --- a/lisp/vc/vc-annotate.el +++ b/lisp/vc/vc-annotate.el | |||
| @@ -162,6 +162,11 @@ List of factors, used to expand/compress the time scale. See `vc-annotate'." | |||
| 162 | :type '(repeat number) | 162 | :type '(repeat number) |
| 163 | :group 'vc) | 163 | :group 'vc) |
| 164 | 164 | ||
| 165 | (defcustom vc-annotate-use-short-revision t | ||
| 166 | "If non-nil, \\[vc-annotate] will use short revisions in its buffer name." | ||
| 167 | :type 'boolean | ||
| 168 | :group 'vc) | ||
| 169 | |||
| 165 | (defvar-keymap vc-annotate-mode-map | 170 | (defvar-keymap vc-annotate-mode-map |
| 166 | :doc "Local keymap used for VC-Annotate mode." | 171 | :doc "Local keymap used for VC-Annotate mode." |
| 167 | "a" #'vc-annotate-revision-previous-to-line | 172 | "a" #'vc-annotate-revision-previous-to-line |
| @@ -397,7 +402,10 @@ should be applied to the background or to the foreground." | |||
| 397 | (save-current-buffer | 402 | (save-current-buffer |
| 398 | (vc-ensure-vc-buffer) | 403 | (vc-ensure-vc-buffer) |
| 399 | (list buffer-file-name | 404 | (list buffer-file-name |
| 400 | (let ((def (vc-working-revision buffer-file-name))) | 405 | (let ((def (funcall (if vc-annotate-use-short-revision |
| 406 | #'vc-short-revision | ||
| 407 | #'vc-working-revision) | ||
| 408 | buffer-file-name))) | ||
| 401 | (if (null current-prefix-arg) def | 409 | (if (null current-prefix-arg) def |
| 402 | (vc-read-revision | 410 | (vc-read-revision |
| 403 | (format-prompt "Annotate from revision" def) | 411 | (format-prompt "Annotate from revision" def) |
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 24469f04f7c..bd74e2a6a44 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el | |||
| @@ -1857,8 +1857,11 @@ This requires git 1.8.4 or later, for the \"-L\" option of \"git log\"." | |||
| 1857 | (defun vc-git--rev-parse (rev) | 1857 | (defun vc-git--rev-parse (rev) |
| 1858 | (with-temp-buffer | 1858 | (with-temp-buffer |
| 1859 | (and | 1859 | (and |
| 1860 | (vc-git--out-ok "rev-parse" rev) | 1860 | (apply #'vc-git--out-ok "rev-parse" |
| 1861 | (buffer-substring-no-properties (point-min) (+ (point-min) 40))))) | 1861 | (append (when vc-use-short-revision '("--short")) |
| 1862 | (list rev))) | ||
| 1863 | (goto-char (point-min)) | ||
| 1864 | (buffer-substring-no-properties (point) (pos-eol))))) | ||
| 1862 | 1865 | ||
| 1863 | (defun vc-git-next-revision (file rev) | 1866 | (defun vc-git-next-revision (file rev) |
| 1864 | "Git-specific version of `vc-next-revision'." | 1867 | "Git-specific version of `vc-next-revision'." |
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el index 8451128286b..e84cdffe2dd 100644 --- a/lisp/vc/vc-hooks.el +++ b/lisp/vc/vc-hooks.el | |||
| @@ -506,6 +506,18 @@ If FILE is not registered, this function always returns nil." | |||
| 506 | (vc-call-backend | 506 | (vc-call-backend |
| 507 | backend 'working-revision file)))))) | 507 | backend 'working-revision file)))))) |
| 508 | 508 | ||
| 509 | (defvar vc-use-short-revision nil | ||
| 510 | "If non-nil, VC backend functions should return short revisions if possible. | ||
| 511 | This is set to t when calling `vc-short-revision', which will | ||
| 512 | then call the \\=`working-revision' backend function.") | ||
| 513 | |||
| 514 | (defun vc-short-revision (file &optional backend) | ||
| 515 | "Return the repository version for FILE in a shortened form. | ||
| 516 | If FILE is not registered, this function always returns nil." | ||
| 517 | (let ((vc-use-short-revision t)) | ||
| 518 | (vc-call-backend (or backend (vc-backend file)) | ||
| 519 | 'working-revision file))) | ||
| 520 | |||
| 509 | (defun vc-default-registered (backend file) | 521 | (defun vc-default-registered (backend file) |
| 510 | "Check if FILE is registered in BACKEND using vc-BACKEND-master-templates." | 522 | "Check if FILE is registered in BACKEND using vc-BACKEND-master-templates." |
| 511 | (let ((sym (vc-make-backend-sym backend 'master-templates))) | 523 | (let ((sym (vc-make-backend-sym backend 'master-templates))) |