X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fnotmuch-show.el;h=10fc872141dc03f6e4bac4a87a20130e9bb7925f;hp=9e8b9c09d699f706663e8a5a5ba818f9b1050520;hb=fe8cd90f97a078336612cd441a783096d6350564;hpb=a7964c86d12558396cda0f297ebf8dcc602bab61 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 9e8b9c09..10fc8721 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -44,6 +44,8 @@ (declare-function notmuch-foreach-mime-part "notmuch" (function mm-handle)) (declare-function notmuch-count-attachments "notmuch" (mm-handle)) (declare-function notmuch-save-attachments "notmuch" (mm-handle &optional queryp)) +(declare-function notmuch-tree "notmuch-tree" + (&optional query query-context target buffer-name open-target)) (defcustom notmuch-message-headers '("Subject" "To" "Cc" "Date") "Headers that should be shown in a message, in this order. @@ -157,10 +159,19 @@ indentation." (make-variable-buffer-local 'notmuch-show-indent-content) (put 'notmuch-show-indent-content 'permanent-local t) +(defvar notmuch-show-attachment-debug nil + "If t log stdout and stderr from attachment handlers + +When set to nil (the default) stdout and stderr from attachment +handlers is discarded. When set to t the stdout and stderr from +each attachment handler is logged in buffers with names beginning +\" *notmuch-part*\". This option requires emacs version at least +24.3 to work.") + (defcustom notmuch-show-stash-mlarchive-link-alist '(("Gmane" . "http://mid.gmane.org/") ("MARC" . "http://marc.info/?i=") - ("Mail Archive, The" . "http://mail-archive.com/search?l=mid&q=") + ("Mail Archive, The" . "http://mid.mail-archive.com/") ("LKML" . "http://lkml.kernel.org/r/") ;; FIXME: can these services be searched by `Message-Id' ? ;; ("MarkMail" . "http://markmail.org/") @@ -169,10 +180,21 @@ indentation." ) "List of Mailing List Archives to use when stashing links. -These URIs are concatenated with the current message's -Message-Id in `notmuch-show-stash-mlarchive-link'." +This list is used for generating a Mailing List Archive reference +URI with the current message's Message-Id in +`notmuch-show-stash-mlarchive-link'. + +If the cdr of the alist element is not a function, the cdr is +expected to contain a URI that is concatenated with the current +message's Message-Id to create a ML archive reference URI. + +If the cdr is a function, the function is called with the +Message-Id as the argument, and the function is expected to +return the ML archive reference URI." :type '(alist :key-type (string :tag "Name") - :value-type (string :tag "URL")) + :value-type (choice + (string :tag "URL") + (function :tag "Function returning the URL"))) :group 'notmuch-show) (defcustom notmuch-show-stash-mlarchive-link-default "Gmane" @@ -333,7 +355,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 "(" - (notmuch-tag-format-tags tags) + (notmuch-tag-format-tags tags (notmuch-show-get-prop :orig-tags)) ")")))))) (defun notmuch-clean-address (address) @@ -412,7 +434,7 @@ message at DEPTH in the current thread." " (" date ") (" - (notmuch-tag-format-tags tags) + (notmuch-tag-format-tags tags tags) ")\n") (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face))) @@ -774,7 +796,10 @@ message at DEPTH in the current thread." (while (and handlers (not (condition-case err (funcall (car handlers) msg part content-type nth depth button) - (error (progn + ;; Specifying `debug' here lets the debugger + ;; run if `debug-on-error' is non-nil. + ((debug error) + (progn (insert "!!! Bodypart insert error: ") (insert (error-message-string err)) (insert " !!!\n") nil))))) @@ -1134,6 +1159,7 @@ function is used." ;; Don't track undo information for this buffer (set 'buffer-undo-list t) + (notmuch-tag-clear-cache) (erase-buffer) (goto-char (point-min)) (save-excursion @@ -1156,6 +1182,8 @@ function is used." (jit-lock-register #'notmuch-show-buttonise-links) + (notmuch-show-mapc (lambda () (notmuch-show-set-prop :orig-tags (notmuch-show-get-tags)))) + ;; Set the header line to the subject of the first message. (setq header-line-format (notmuch-sanitize (notmuch-show-strip-re (notmuch-show-get-subject)))) @@ -1230,6 +1258,7 @@ reset based on the original query." (define-key map "t" 'notmuch-show-stash-to) (define-key map "l" 'notmuch-show-stash-mlarchive-link) (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go) + (define-key map "?" 'notmuch-subkeymap-help) map) "Submap for stash commands") (fset 'notmuch-show-stash-map notmuch-show-stash-map) @@ -1240,6 +1269,7 @@ reset based on the original query." (define-key map "v" 'notmuch-show-view-part) (define-key map "o" 'notmuch-show-interactively-view-part) (define-key map "|" 'notmuch-show-pipe-part) + (define-key map "?" 'notmuch-subkeymap-help) map) "Submap for part commands") (fset 'notmuch-show-part-map notmuch-show-part-map) @@ -1247,6 +1277,7 @@ reset based on the original query." (defvar notmuch-show-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map notmuch-common-keymap) + (define-key map "Z" 'notmuch-tree-from-show-current-query) (define-key map (kbd "") 'widget-backward) (define-key map (kbd "M-TAB") 'notmuch-show-previous-button) (define-key map (kbd "") 'notmuch-show-previous-button) @@ -1323,6 +1354,13 @@ All currently available key bindings: (setq buffer-read-only t truncate-lines t)) +(defun notmuch-tree-from-show-current-query () + "Call notmuch tree with the current query" + (interactive) + (notmuch-tree notmuch-show-thread-id + notmuch-show-query-context + (notmuch-show-get-message-id))) + (defun notmuch-show-move-to-message-top () (goto-char (notmuch-show-message-top))) @@ -1760,10 +1798,14 @@ message." (setq shell-command (concat notmuch-command " show --format=raw " (shell-quote-argument (notmuch-show-get-message-id)) " | " command))) - (let ((buf (get-buffer-create (concat "*notmuch-pipe*")))) + (let ((cwd default-directory) + (buf (get-buffer-create (concat "*notmuch-pipe*")))) (with-current-buffer buf (setq buffer-read-only nil) (erase-buffer) + ;; Use the originating buffer's working directory instead of + ;; that of the pipe buffer. + (cd cwd) (let ((exit-code (call-process-shell-command shell-command nil buf))) (goto-char (point-max)) (set-buffer-modified-p nil) @@ -2024,16 +2066,19 @@ This presumes that the message is available at the selected Mailing List Archive If optional argument MLA is non-nil, use the provided key instead of prompting the user (see `notmuch-show-stash-mlarchive-link-alist')." (interactive) - (notmuch-common-do-stash - (concat (cdr (assoc - (or mla - (let ((completion-ignore-case t)) - (completing-read - "Mailing List Archive: " - notmuch-show-stash-mlarchive-link-alist - nil t nil nil notmuch-show-stash-mlarchive-link-default))) - notmuch-show-stash-mlarchive-link-alist)) - (notmuch-show-get-message-id t)))) + (let ((url (cdr (assoc + (or mla + (let ((completion-ignore-case t)) + (completing-read + "Mailing List Archive: " + notmuch-show-stash-mlarchive-link-alist + nil t nil nil + notmuch-show-stash-mlarchive-link-default))) + notmuch-show-stash-mlarchive-link-alist)))) + (notmuch-common-do-stash + (if (functionp url) + (funcall url (notmuch-show-get-message-id t)) + (concat url (notmuch-show-get-message-id t)))))) (defun notmuch-show-stash-mlarchive-link-and-go (&optional mla) "Copy an ML Archive URI for the current message to the kill-ring and visit it. @@ -2079,8 +2124,16 @@ caller is responsible for killing this buffer as appropriate." This ensures that the temporary buffer created for the mm-handle is destroyed when FN returns." (let ((handle (notmuch-show-current-part-handle))) + ;; emacs 24.3+ puts stdout/stderr into the calling buffer so we + ;; call it from a temp-buffer, unless + ;; notmuch-show-attachment-debug is non-nil in which case we put + ;; it in " *notmuch-part*". (unwind-protect - (funcall fn handle) + (if notmuch-show-attachment-debug + (with-current-buffer (generate-new-buffer " *notmuch-part*") + (funcall fn handle)) + (with-temp-buffer + (funcall fn handle))) (kill-buffer (mm-handle-buffer handle))))) (defun notmuch-show-part-button-default (&optional button)