X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fnotmuch-show.el;h=aa6ddd1a0ac6130969ee65204b84191c76622880;hp=ed7037a15983437819d40055653e597fa9ffd7a4;hb=933011ccaf4cb4ca2e92cff8a4a1ded6567db37c;hpb=0898cfad5ef2d7c000e9c23e9205e02aec18cc24 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index ed7037a1..aa6ddd1a 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -32,6 +32,7 @@ (require 'notmuch-query) (require 'notmuch-wash) (require 'notmuch-mua) +(require 'notmuch-crypto) (declare-function notmuch-call-notmuch-process "notmuch" (&rest args)) (declare-function notmuch-fontify-headers "notmuch" nil) @@ -295,18 +296,20 @@ message at DEPTH in the current thread." ;; Functions handling particular MIME parts. (defun notmuch-show-save-part (message-id nth &optional filename) - (with-temp-buffer - ;; Always acquires the part via `notmuch part', even if it is - ;; available in the JSON output. - (insert (notmuch-show-get-bodypart-internal message-id nth)) - (let ((file (read-file-name - "Filename to save as: " - (or mailcap-download-directory "~/") - nil nil - filename)) - (require-final-newline nil) - (coding-system-for-write 'no-conversion)) - (write-region (point-min) (point-max) file)))) + (let ((process-crypto notmuch-show-process-crypto)) + (with-temp-buffer + (setq notmuch-show-process-crypto process-crypto) + ;; Always acquires the part via `notmuch part', even if it is + ;; available in the JSON output. + (insert (notmuch-show-get-bodypart-internal message-id nth)) + (let ((file (read-file-name + "Filename to save as: " + (or mailcap-download-directory "~/") + nil nil + filename)) + (require-final-newline nil) + (coding-system-for-write 'no-conversion)) + (write-region (point-min) (point-max) file))))) (defun notmuch-show-mm-display-part-inline (msg part content-type content) "Use the mm-decode/mm-view functions to display a part in the @@ -521,6 +524,11 @@ current buffer, if possible." nil)) nil)))) +(defun notmuch-show-insert-part-application/* (msg part content-type nth depth declared-type +) + ;; do not render random "application" parts + (notmuch-show-insert-part-header nth content-type declared-type (plist-get part :filename))) + (defun notmuch-show-insert-part-*/* (msg part content-type nth depth declared-type) ;; This handler _must_ succeed - it is the handler of last resort. (notmuch-show-insert-part-header nth content-type declared-type (plist-get part :filename)) @@ -551,13 +559,20 @@ current buffer, if possible." ;; Helper for parts which are generally not included in the default ;; JSON output. - +;; Uses the buffer-local variable notmuch-show-process-crypto to +;; determine if parts should be decrypted first. (defun notmuch-show-get-bodypart-internal (message-id part-number) - (with-temp-buffer - (let ((coding-system-for-read 'no-conversion)) - (call-process notmuch-command nil t nil - "part" (format "--part=%s" part-number) message-id) - (buffer-string)))) + (let ((args '("show" "--format=raw")) + (part-arg (format "--part=%s" part-number))) + (setq args (append args (list part-arg))) + (if notmuch-show-process-crypto + (setq args (append args '("--decrypt")))) + (setq args (append args (list message-id))) + (with-temp-buffer + (let ((coding-system-for-read 'no-conversion)) + (progn + (apply 'call-process (append (list notmuch-command nil (list t nil) nil) args)) + (buffer-string)))))) (defun notmuch-show-get-bodypart-content (msg part nth) (or (plist-get part :content) @@ -578,6 +593,16 @@ current buffer, if possible." "Insert the body part PART at depth DEPTH in the current thread." (let ((content-type (downcase (plist-get part :content-type))) (nth (plist-get part :id))) + ;; add encryption status button if encstatus specified + (if (plist-member part :encstatus) + (let* ((encstatus (car (plist-get part :encstatus)))) + (notmuch-crypto-insert-encstatus-button encstatus))) + ;; add signature status button if sigstatus specified + (if (plist-member part :sigstatus) + (let* ((headers (plist-get msg :headers)) + (from (plist-get headers :From)) + (sigstatus (car (plist-get part :sigstatus)))) + (notmuch-crypto-insert-sigstatus-button sigstatus from))) (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)) ;; Some of the body part handlers leave point somewhere up in the ;; part, so we make sure that we're down at the end. @@ -711,9 +736,10 @@ current buffer, if possible." (mapc '(lambda (thread) (notmuch-show-insert-thread thread 0)) forest)) (defvar notmuch-show-parent-buffer nil) +(make-variable-buffer-local 'notmuch-show-parent-buffer) ;;;###autoload -(defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name) +(defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch) "Run \"notmuch show\" with the given thread ID and display results. The optional PARENT-BUFFER is the notmuch-search buffer from @@ -733,10 +759,14 @@ function is used. " (let ((buffer (get-buffer-create (generate-new-buffer-name (or buffer-name (concat "*notmuch-" thread-id "*"))))) + (process-crypto (if crypto-switch + (not notmuch-crypto-process-mime) + notmuch-crypto-process-mime)) (inhibit-read-only t)) (switch-to-buffer buffer) (notmuch-show-mode) - (set (make-local-variable 'notmuch-show-parent-buffer) parent-buffer) + (setq notmuch-show-parent-buffer parent-buffer) + (setq notmuch-show-process-crypto process-crypto) (erase-buffer) (goto-char (point-min)) (save-excursion @@ -792,7 +822,7 @@ function is used. " (define-key map (kbd "") 'notmuch-show-previous-button) (define-key map (kbd "TAB") 'notmuch-show-next-button) (define-key map "s" 'notmuch-search) - (define-key map "m" 'notmuch-mua-mail) + (define-key map "m" 'notmuch-mua-new-mail) (define-key map "f" 'notmuch-show-forward-message) (define-key map "r" 'notmuch-show-reply) (define-key map "|" 'notmuch-show-pipe-message) @@ -1098,16 +1128,16 @@ any effects from previous calls to ;; Move to the previous message. (notmuch-show-previous-message))))) -(defun notmuch-show-reply () +(defun notmuch-show-reply (&optional prompt-for-sender) "Reply to the current message." - (interactive) - (notmuch-mua-reply (notmuch-show-get-message-id))) + (interactive "P") + (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sender)) -(defun notmuch-show-forward-message () +(defun notmuch-show-forward-message (&optional prompt-for-sender) "Forward the current message." - (interactive) + (interactive "P") (with-current-notmuch-show-message - (notmuch-mua-forward-message))) + (notmuch-mua-new-forward-message prompt-for-sender))) (defun notmuch-show-next-message () "Show the next message." @@ -1218,10 +1248,8 @@ the result." (new-tags (notmuch-show-add-tags-worker current-tags toadd))) (unless (equal current-tags new-tags) - (apply 'notmuch-call-notmuch-process - (append (cons "tag" - (mapcar (lambda (s) (concat "+" s)) toadd)) - (cons (notmuch-show-get-message-id) nil))) + (apply 'notmuch-tag (notmuch-show-get-message-id) + (mapcar (lambda (s) (concat "+" s)) toadd)) (notmuch-show-set-tags new-tags)))) (defun notmuch-show-remove-tag (&rest toremove) @@ -1234,10 +1262,8 @@ the result." (new-tags (notmuch-show-del-tags-worker current-tags toremove))) (unless (equal current-tags new-tags) - (apply 'notmuch-call-notmuch-process - (append (cons "tag" - (mapcar (lambda (s) (concat "-" s)) toremove)) - (cons (notmuch-show-get-message-id) nil))) + (apply 'notmuch-tag (notmuch-show-get-message-id) + (mapcar (lambda (s) (concat "-" s)) toremove)) (notmuch-show-set-tags new-tags)))) (defun notmuch-show-toggle-headers ()