about summary refs log tree commit diff
path: root/modules/workstation/emacs/init.el
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-10-24 11:21:46 +0000
committerAlyssa Ross <hi@alyssa.is>2022-02-21 20:27:49 +0000
commitee5b1e241475f98227aa785f69c8362f69a11656 (patch)
treecd8f3f9a1a46dc806abe5f5e6c961dd16ae5ade8 /modules/workstation/emacs/init.el
parent83f9d5f3c6553f0afb1e9c1cf6f1e0bfef750e97 (diff)
downloadnixlib-ee5b1e241475f98227aa785f69c8362f69a11656.tar
nixlib-ee5b1e241475f98227aa785f69c8362f69a11656.tar.gz
nixlib-ee5b1e241475f98227aa785f69c8362f69a11656.tar.bz2
nixlib-ee5b1e241475f98227aa785f69c8362f69a11656.tar.lz
nixlib-ee5b1e241475f98227aa785f69c8362f69a11656.tar.xz
nixlib-ee5b1e241475f98227aa785f69c8362f69a11656.tar.zst
nixlib-ee5b1e241475f98227aa785f69c8362f69a11656.zip
modules/emacs: add git-commit-message-pretty-ref
Diffstat (limited to 'modules/workstation/emacs/init.el')
-rw-r--r--modules/workstation/emacs/init.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/workstation/emacs/init.el b/modules/workstation/emacs/init.el
index 09a1a5f4d6b4..1f1d79dd4fe5 100644
--- a/modules/workstation/emacs/init.el
+++ b/modules/workstation/emacs/init.el
@@ -152,6 +152,16 @@
 ;; in the right when this happens).
 (setq magit-commit-show-diff nil)
 
+(defun git-commit-message-pretty-ref (commit)
+  "Generate a reference to git COMMIT in the format used in the
+Linux kernel (`SHORT-HASH (\"SHORT-MESSAGE\")') and insert it at
+point."
+  (interactive
+   (list (or (nreverse (magit-region-values 'commit))
+	     (magit-read-other-branch-or-commit "Reference commit"))))
+  (call-process (magit-git-executable) nil t nil
+		"show" "--no-patch" "--pretty=format:%h (\"%s\")" commit))
+
 (with-eval-after-load "magit"
   (define-key magit-process-mode-map (kbd "k") #'magit-process-kill)