X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=emacs%2Fnotmuch-show.el;h=a080134ff7e5dbea69528267c277dad6fef062fd;hb=6bbb91f8b64c20a491cc3501b625753f97e52882;hp=652e5dc3c949acb705586dafec273bdc92b0e8b6;hpb=b681aa8235a16630e282626d3938862a6c2f7fd0;p=notmuch diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 652e5dc3..a080134f 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -39,6 +39,7 @@ (declare-function notmuch-call-notmuch-process "notmuch" (&rest args)) (declare-function notmuch-search-next-thread "notmuch" nil) +(declare-function notmuch-search-previous-thread "notmuch" nil) (declare-function notmuch-search-show-thread "notmuch" nil) (defcustom notmuch-message-headers '("Subject" "To" "Cc" "Date") @@ -528,20 +529,15 @@ message at DEPTH in the current thread." (defun notmuch-show-view-part (message-id nth &optional filename content-type ) (notmuch-with-temp-part-buffer message-id nth - ;; set mm-inlined-types to nil to force an external viewer - (let ((handle (mm-make-handle (current-buffer) (list content-type))) - (mm-inlined-types nil)) - ;; We override mm-save-part as notmuch-show-save-part is better - ;; since it offers the filename. We need to lexically bind - ;; everything we need for notmuch-show-save-part to prevent - ;; potential dynamic shadowing. - (lexical-let ((message-id message-id) - (nth nth) - (filename filename) - (content-type content-type)) - (flet ((mm-save-part (&rest args) (notmuch-show-save-part - message-id nth filename content-type))) - (mm-display-part handle)))))) + (let* ((disposition (if filename `(attachment (filename . ,filename)))) + (handle (mm-make-handle (current-buffer) (list content-type) + nil nil disposition)) + ;; Set the default save directory to be consistent with + ;; `notmuch-show-save-part'. + (mm-default-directory (or mailcap-download-directory "~/")) + ;; set mm-inlined-types to nil to force an external viewer + (mm-inlined-types nil)) + (mm-display-part handle)))) (defun notmuch-show-interactively-view-part (message-id nth &optional filename content-type) (notmuch-with-temp-part-buffer message-id nth @@ -563,10 +559,12 @@ message at DEPTH in the current thread." (new-start (button-start button)) (button-label (button-get button :base-label)) (old-point (point)) + (properties (text-properties-at (point))) (inhibit-read-only t)) (overlay-put overlay 'invisible (not show)) (goto-char new-start) (insert "[ " button-label (if show " ]" " (hidden) ]")) + (set-text-properties new-start (point) properties) (let ((old-end (button-end button))) (move-overlay button new-start (point)) (delete-region (point) old-end)) @@ -815,7 +813,7 @@ message at DEPTH in the current thread." ;; Handler for wash generated inline patch fake parts. (defun notmuch-show-insert-part-inline-patch-fake-part (msg part content-type nth depth declared-type) - (notmuch-show-insert-part-*/* msg part "text/x-diff" nth depth "inline patch")) + (notmuch-show-insert-part-*/* msg part content-type nth depth declared-type)) (defun notmuch-show-insert-part-text/html (msg part content-type nth depth declared-type) ;; text/html handler to work around bugs in renderers and our @@ -889,6 +887,8 @@ If HIDE is non-nil then initially hide this part." (let* ((content-type (downcase (plist-get part :content-type))) (mime-type (or (and (string= content-type "application/octet-stream") (notmuch-show-get-mime-type-of-application/octet-stream part)) + (and (string= content-type "inline patch") + "text/x-diff") content-type)) (nth (plist-get part :id)) (beg (point))) @@ -1271,6 +1271,8 @@ reset based on the original query." (define-key map "P" 'notmuch-show-previous-message) (define-key map "n" 'notmuch-show-next-open-message) (define-key map "p" 'notmuch-show-previous-open-message) + (define-key map (kbd "M-n") 'notmuch-show-next-thread-show) + (define-key map (kbd "M-p") 'notmuch-show-previous-thread-show) (define-key map (kbd "DEL") 'notmuch-show-rewind) (define-key map " " 'notmuch-show-advance-and-archive) (define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all) @@ -1832,16 +1834,33 @@ argument, hide all of the messages." (interactive) (backward-button 1)) -(defun notmuch-show-next-thread (&optional show-next) - "Move to the next item in the search results, if any." +(defun notmuch-show-next-thread (&optional show previous) + "Move to the next item in the search results, if any. + +If SHOW is non-nil, open the next item in a show +buffer. Otherwise just highlight the next item in the search +buffer. If PREVIOUS is non-nil, move to the previous item in the +search results instead." (interactive "P") (let ((parent-buffer notmuch-show-parent-buffer)) (notmuch-kill-this-buffer) (when (buffer-live-p parent-buffer) (switch-to-buffer parent-buffer) - (notmuch-search-next-thread) - (if show-next - (notmuch-search-show-thread))))) + (and (if previous + (notmuch-search-previous-thread) + (notmuch-search-next-thread)) + show + (notmuch-search-show-thread))))) + +(defun notmuch-show-next-thread-show () + "Show the next thread in the search results, if any." + (interactive) + (notmuch-show-next-thread t)) + +(defun notmuch-show-previous-thread-show () + "Show the previous thread in the search results, if any." + (interactive) + (notmuch-show-next-thread t t)) (defun notmuch-show-archive-thread (&optional unarchive) "Archive each message in thread.