feat(emacs): add command for extracting a patch from emails
This commit is contained in:
parent
e5877a73da
commit
d29a601b65
1 changed files with 24 additions and 0 deletions
|
|
@ -120,3 +120,27 @@
|
|||
:type "notmuch"
|
||||
:link link
|
||||
: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))))
|
||||
|
|
|
|||
Loading…
Reference in a new issue