feat(emacs): add command for extracting a patch from emails

This commit is contained in:
Ade Attwood 2022-02-15 20:47:31 +00:00
parent e5877a73da
commit d29a601b65

View file

@ -120,3 +120,27 @@
:type "notmuch" :type "notmuch"
:link link :link link
:description description))))) :description description)))))
;; https://notmuchmail.org/emacstips
;; Viewing diffs in notmuch
(defun aa/notmuch-show-view-as-patch ()
"View the the current message as a patch."
(interactive)
(let* ((id (notmuch-show-get-message-id))
(msg (notmuch-show-get-message-properties))
(part (notmuch-show-get-part-properties))
(subject (concat "Subject: " (notmuch-show-get-subject) "\n"))
(diff-default-read-only t)
(buf (get-buffer-create (concat "*notmuch-patch-" id "*")))
(map (make-sparse-keymap)))
(define-key map "q" 'notmuch-bury-or-kill-this-buffer)
(switch-to-buffer buf)
(let ((inhibit-read-only t))
(erase-buffer)
(insert subject)
(insert (notmuch-get-bodypart-text msg part nil)))
(set-buffer-modified-p nil)
(diff-mode)
(lexical-let ((new-ro-bind (cons 'buffer-read-only map)))
(add-to-list 'minor-mode-overriding-map-alist new-ro-bind))
(goto-char (point-min))))