emacs: remove some code duplication in notmuch-show

Add optional props argument to `notmuch-show-get-header'.  Use it to
get headers in `notmuch-show-insert-part-multipart/signed' and
`notmuch-show-insert-part-multipart/encrypted'.
This commit is contained in:
Dmitry Kurochkin 2011-11-26 02:23:30 +04:00 committed by David Bremner
parent 1daa7f3e95
commit f1e75c724d

View file

@ -460,8 +460,7 @@ current buffer, if possible."
(button-put button 'face '(:foreground "blue")) (button-put button 'face '(:foreground "blue"))
;; add signature status button if sigstatus provided ;; add signature status button if sigstatus provided
(if (plist-member part :sigstatus) (if (plist-member part :sigstatus)
(let* ((headers (plist-get msg :headers)) (let* ((from (notmuch-show-get-header :From msg))
(from (plist-get headers :From))
(sigstatus (car (plist-get part :sigstatus)))) (sigstatus (car (plist-get part :sigstatus))))
(notmuch-crypto-insert-sigstatus-button sigstatus from)) (notmuch-crypto-insert-sigstatus-button sigstatus from))
;; if we're not adding sigstatus, tell the user how they can get it ;; if we're not adding sigstatus, tell the user how they can get it
@ -487,8 +486,7 @@ current buffer, if possible."
(notmuch-crypto-insert-encstatus-button encstatus) (notmuch-crypto-insert-encstatus-button encstatus)
;; add signature status button if sigstatus specified ;; add signature status button if sigstatus specified
(if (plist-member part :sigstatus) (if (plist-member part :sigstatus)
(let* ((headers (plist-get msg :headers)) (let* ((from (notmuch-show-get-header :From msg))
(from (plist-get headers :From))
(sigstatus (car (plist-get part :sigstatus)))) (sigstatus (car (plist-get part :sigstatus))))
(notmuch-crypto-insert-sigstatus-button sigstatus from)))) (notmuch-crypto-insert-sigstatus-button sigstatus from))))
;; if we're not adding encstatus, tell the user how they can get it ;; if we're not adding encstatus, tell the user how they can get it
@ -1089,9 +1087,9 @@ All currently available key bindings:
"Return the filename of the current message." "Return the filename of the current message."
(notmuch-show-get-prop :filename)) (notmuch-show-get-prop :filename))
(defun notmuch-show-get-header (header) (defun notmuch-show-get-header (header &optional props)
"Return the named header of the current message, if any." "Return the named header of the current message, if any."
(plist-get (notmuch-show-get-prop :headers) header)) (plist-get (notmuch-show-get-prop :headers props) header))
(defun notmuch-show-get-cc () (defun notmuch-show-get-cc ()
(notmuch-show-get-header :Cc)) (notmuch-show-get-header :Cc))