Skip to content

Instantly share code, notes, and snippets.

@jasonm23
Created April 1, 2017 05:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jasonm23/6326d278d99fe82f252a90d9b9ad61db to your computer and use it in GitHub Desktop.
Save jasonm23/6326d278d99fe82f252a90d9b9ad61db to your computer and use it in GitHub Desktop.
Use Magit and Emacs with git-duet (Just a basic commit feature)
(require 'dash)
(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))))))
(defun magit-duet-commit-deinit ()
"Remove duet-commit from magit commit popup.."
(interactive)
(unless (eq magit-duet--default-commit-popup-actions nil)
(plist-put magit-commit-popup
:actions
magit-duet--default-commit-popup-actions)))
@jasonm23
Copy link
Author

jasonm23 commented Apr 1, 2017

This is a brittle solution, modifying the pop-up like this won't work if Magit contributors change the commit pop-up.

@jasonm23
Copy link
Author

jasonm23 commented Apr 1, 2017

I'll tryout magit-define-popup-action instead. Hopefully the ordering can be controlled to maintain the same command layout.

@ldeck
Copy link

ldeck commented Apr 2, 2019

Hi Jason! This appears to not work anymore with the latest emacs/magit combo.

Any chance you’ve got this working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment