feat(emacs.d): Add notmuch-depot-apply-patch helper function
This function lets me interactively apply a patch from the currently opened notmuch message to the depot.
This commit is contained in:
parent
2fa7bf7bb0
commit
fb5f26e548
1 changed files with 21 additions and 0 deletions
|
@ -238,4 +238,25 @@
|
|||
(if prefix (text-scale-adjust 0)
|
||||
(set-face-attribute 'default nil :height (or to 120))))
|
||||
|
||||
(defun notmuch-depot-apply-patch ()
|
||||
"Apply the currently opened notmuch message as a patch on the
|
||||
depot."
|
||||
|
||||
(interactive)
|
||||
;; The implementation works by letting notmuch render a raw message
|
||||
;; and capturing it by overriding the `view-buffer' function it
|
||||
;; calls after rendering.
|
||||
;;
|
||||
;; The buffer is then passed to `git-am'.
|
||||
(cl-letf (((symbol-function 'view-buffer)
|
||||
(lambda (buffer &optional exit-action) buffer)))
|
||||
(if-let ((raw-buffer (notmuch-show-view-raw-message)))
|
||||
(progn
|
||||
(with-current-buffer raw-buffer
|
||||
(call-shell-region (point-min) (point-max) "git am -C ~/depot")
|
||||
(message "Patch applied!")
|
||||
(kill-buffer))
|
||||
(magit-status "~/depot"))
|
||||
(warn "notmuch failed to render the raw message buffer"))))
|
||||
|
||||
(provide 'functions)
|
||||
|
|
Loading…
Reference in a new issue