Skip to content

Instantly share code, notes, and snippets.

@ldeck
Forked from jasonm23/magit-duet-commit.el
Last active September 12, 2017 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ldeck/0afd31a407e732bea3cefa1f4b8a4e1f to your computer and use it in GitHub Desktop.
Save ldeck/0afd31a407e732bea3cefa1f4b8a4e1f to your computer and use it in GitHub Desktop.
Use Magit and Emacs with git-duet
(require 'dash)
(require 'magit)
(defvar magit-duet--default-commit-popup-actions nil
"Store the magit-commit-popup here for
de-initializing. magit-duet-commit")
(defun magit-duet-commit (&optional args)
"Create a new duet commit"
(interactive (if current-prefix-arg
(list (cons "--amend" (magit-commit-arguments)))
(list (magit-commit-arguments))))
(when (setq args (magit-commit-assert args))
(magit-run-git-with-editor "duet-commit" args)))
(defun magit-duet-commit-init ()
"Add duet-commit to magit commit popup.."
(interactive)
(when (eq magit-duet--default-commit-popup-actions nil)
(setq magit-duet--default-commit-popup-actions
(plist-get magit-commit-popup :actions))
(plist-put
magit-commit-popup
:actions
(-remove-at 5 (-insert-at 4
'(100 "Duet commit" magit-duet-commit)
(plist-get magit-commit-popup :actions))))))
(add-hook 'magit-mode-hook 'magit-duet-commit-init)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment