commit 2b79c20fc741be7cab3126f6001295579042bfeb parent 1e353e6b0ba93a38d7a4e6111db97f95355f7b39 Author: andsy10 <andsy1016@gmail.com> Date: Tue, 22 Sep 2026 19:16:42 +0800 Add helpers for vc-annotate Diffstat:
| M | lisp/init-kbd.el | | | 9 | +++++++++ |
| M | lisp/init-package.el | | | 41 | +++++++++++++++++++++++++++++++++++++---- |
2 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el @@ -229,6 +229,15 @@ (general-def (magit-mode-map tokei-mode-map) "C-<tab>" #'my-magit-toggle-parent-section) +;; vc +(general-def vc-annotate-mode-map + "t" #'consult-vc-annotate-revision + "=" #'my-vc-annotate-diff-current-revision + "d" #'my-vc-annotate-diff-current-revision + "D" #'vc-annotate-show-diff-revision-at-line + "l" #'my-vc-print-log-current-revision + "L" #'vc-annotate-show-log-revision-at-line) + ;; sly (general-def (sly-mode-map sly-editing-mode-map) "M-p" #'backward-paragraph diff --git a/lisp/init-package.el b/lisp/init-package.el @@ -29,9 +29,8 @@ (use-package consult-jinx :straight - (consult-jinx - :type git - :repo "https://git.trogloxene.org/consult-jinx.git"))) + (consult-jinx :type git + :repo "https://git.trogloxene.org/consult-jinx.git"))) ;; terminal emulator (use-package ghostel @@ -143,7 +142,41 @@ Like normal Emacs `C-k'. Kill to end of line and put content in kill-ring." ;; vc (use-package vc :straight nil - :autoload vc-create-repo) + :autoload vc-create-repo + :config + (defun my-vc-annotate-diff-current-revision () + "Show the diff of the revision displayed in this vc-annotate buffer +against its previous revision." + (interactive) + (if (not (derived-mode-p 'vc-annotate-mode)) + (message "Not a vc annotate buffer") + (let* ((file (caadr vc-buffer-overriding-fileset)) + (rev vc-buffer-revision) + (prev-rev + (let ((vc-use-short-revision vc-annotate-use-short-revision)) + (vc-call-backend vc-annotate-backend 'previous-revision file rev)))) + (if (not prev-rev) + (message "No previous revisions") + (vc-diff-internal vc-allow-async-diff + (list vc-annotate-backend (list file)) + prev-rev rev))))) + + (defun my-vc-print-log-current-revision () + "Print the log of the revision displayed in this vc-annotate buffer." + (interactive) + (if (not (derived-mode-p 'vc-annotate-mode)) + (message "Not a vc annotate buffer") + (let* ((file (cadr vc-buffer-overriding-fileset)) + (rev vc-buffer-revision)) + (vc-print-log-internal vc-annotate-backend file rev t 1))))) + +(use-package consult-vc + :straight + (consult-vc :type git + :repo "https://git.trogloxene.org/consult-vc.git") + :init + (setq consult-vc-annotate-revision-narrow-key-forward ?\] + consult-vc-annotate-revision-narrow-key-backward ?\[)) ;; project (use-package project