about summary refs log tree commit diff stats
path: root/.emacs.d/lisp
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2023-05-17 12:50:40 +0100
committerDavid Morgan <djm_uk@protonmail.com>2023-05-17 12:50:40 +0100
commite17ff91dfb71b9804125ad33694ba9e6a7fabc29 (patch)
tree35b4151ec029910db93b1fd870892d553c125254 /.emacs.d/lisp
parent05afb02a1a47b8c008d785f595143b4c1ae00dee (diff)
downloaddotfiles-e17ff91dfb71b9804125ad33694ba9e6a7fabc29.tar.gz
Add git-link-branch function
Diffstat (limited to '.emacs.d/lisp')
-rw-r--r--.emacs.d/lisp/init-git.el10
1 files changed, 9 insertions, 1 deletions
diff --git a/.emacs.d/lisp/init-git.el b/.emacs.d/lisp/init-git.el
index f2030f8..5478bfd 100644
--- a/.emacs.d/lisp/init-git.el
+++ b/.emacs.d/lisp/init-git.el
@@ -302,11 +302,19 @@
     (interactive)
     (let ((git-link-use-commit nil))
       (call-interactively 'git-link)))
+  (defun git-link-branch ()
+    (interactive)
+    (let* ((remote-info (git-link--parse-remote (git-link--remote-url (git-link--select-remote))))
+           (branch (git-link--branch)))
+      (if (null (car remote-info))
+          (message "Remote `%s' contains an unsupported URL" remote)
+        (git-link--new (format "https://%s/%s/tree/%s" (car remote-info) (cadr remote-info) branch)))))
   :custom (git-link-use-commit t)
   :bind
   ("C-c g s" . git-link)
   ("C-c g S" . git-link-on-branch)
-  ("C-c g c" . git-link-commit))
+  ("C-c g c" . git-link-commit)
+  ("C-c g b" . git-link-branch))
 
 (provide 'init-git)
 ;;; init-git.el ends here