X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=emacs%2Fnotmuch-show.el;h=a080134ff7e5dbea69528267c277dad6fef062fd;hb=6bbb91f8b64c20a491cc3501b625753f97e52882;hp=acaef8ef2afd3871b071e468025fec44ab9f124c;hpb=16aa65ba2575fd504c31d9671d8c5150f8e8adf1;p=notmuch diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index acaef8ef..a080134f 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -38,8 +38,8 @@ (require 'notmuch-print) (declare-function notmuch-call-notmuch-process "notmuch" (&rest args)) -(declare-function notmuch-fontify-headers "notmuch" nil) (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") @@ -158,6 +158,7 @@ indentation." '(("Gmane" . "http://mid.gmane.org/") ("MARC" . "http://marc.info/?i=") ("Mail Archive, The" . "http://mail-archive.com/search?l=mid&q=") + ("LKML" . "http://lkml.kernel.org/r/") ;; FIXME: can these services be searched by `Message-Id' ? ;; ("MarkMail" . "http://markmail.org/") ;; ("Nabble" . "http://nabble.com/") @@ -362,8 +363,7 @@ operation on the contents of the current buffer." (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t) (let ((inhibit-read-only t)) (replace-match (concat "(" - (propertize (mapconcat 'identity tags " ") - 'face 'notmuch-tag-face) + (notmuch-tag-format-tags tags) ")")))))) (defun notmuch-clean-address (address) @@ -441,8 +441,7 @@ message at DEPTH in the current thread." " (" date ") (" - (propertize (mapconcat 'identity tags " ") - 'face 'notmuch-tag-face) + (notmuch-tag-format-tags tags) ")\n") (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face))) @@ -530,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 @@ -565,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)) @@ -799,9 +795,9 @@ message at DEPTH in the current thread." (defun notmuch-show-insert-part-text/x-vcalendar (msg part content-type nth depth declared-type) (notmuch-show-insert-part-text/calendar msg part content-type nth depth declared-type)) -(defun notmuch-show-insert-part-application/octet-stream (msg part content-type nth depth declared-type) +(defun notmuch-show-get-mime-type-of-application/octet-stream (part) ;; If we can deduce a MIME type from the filename of the attachment, - ;; do so and pass it on to the handler for that type. + ;; we return that. (if (plist-get part :filename) (let ((extension (file-name-extension (plist-get part :filename))) mime-type) @@ -811,13 +807,13 @@ message at DEPTH in the current thread." (setq mime-type (mailcap-extension-to-mime extension)) (if (and mime-type (not (string-equal mime-type "application/octet-stream"))) - (notmuch-show-insert-bodypart-internal msg part mime-type nth depth content-type) + mime-type nil)) nil)))) ;; 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 @@ -888,11 +884,16 @@ message at DEPTH in the current thread." "Insert the body part PART at depth DEPTH in the current thread. If HIDE is non-nil then initially hide this part." - (let ((content-type (downcase (plist-get part :content-type))) - (nth (plist-get part :id)) - (beg (point))) - - (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type) + (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))) + + (notmuch-show-insert-bodypart-internal msg part mime-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. (goto-char (point-max)) @@ -1270,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) @@ -1831,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.