X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=emacs%2Fnotmuch-show.el;h=5b3e70eedb01bc28a7cf13b9b0142433c43f5b86;hb=be66f3f70937454b367b01bdee0238e38fbf12fa;hp=f273eb406cb0daf38aec0a3f13286df7a49a556f;hpb=0db6c7b8be29026df832ef7d7cb02f5183fc9c7f;p=notmuch diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index f273eb40..5b3e70ee 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -815,7 +815,12 @@ message at DEPTH in the current thread." ;; Run the content handlers until one of them returns a non-nil ;; value. (while (and handlers - (not (funcall (car handlers) msg part content-type nth depth declared-type))) + (not (condition-case err + (funcall (car handlers) msg part content-type nth depth declared-type) + (error (progn + (insert "!!! Bodypart insert error: ") + (insert (error-message-string err)) + (insert " !!!\n") nil))))) (setq handlers (cdr handlers)))) t) @@ -991,23 +996,62 @@ message at DEPTH in the current thread." "Insert the forest of threads FOREST." (mapc (lambda (thread) (notmuch-show-insert-thread thread 0)) forest)) +(defvar notmuch-id-regexp + (concat + ;; Match the id: prefix only if it begins a word (to disallow, for + ;; example, matching cid:). + "\\\"-parts into buttons for -a corresponding notmuch search." +This also turns id:\"\"-parts and mid: links into +buttons for a corresponding notmuch search." (goto-address-fontify-region start end) (save-excursion - (goto-char start) - (while (re-search-forward "id:\\(\"?\\)[^[:space:]\"]+\\1" end t) - ;; remove the overlay created by goto-address-mode - (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t) - (make-text-button (match-beginning 0) (match-end 0) - 'action `(lambda (arg) - (notmuch-show ,(match-string-no-properties 0))) - 'follow-link t - 'help-echo "Mouse-1, RET: search for this message" - 'face goto-address-mail-face)))) + (let (links) + (goto-char start) + (while (re-search-forward notmuch-id-regexp end t) + (push (list (match-beginning 0) (match-end 0) + (match-string-no-properties 0)) links)) + (goto-char start) + (while (re-search-forward notmuch-mid-regexp end t) + (let* ((mid-cid (match-string-no-properties 1)) + (mid (save-match-data + (string-match "^[^/]*" mid-cid) + (url-unhex-string (match-string 0 mid-cid))))) + (push (list (match-beginning 0) (match-end 0) + (notmuch-id-to-query mid)) links))) + (dolist (link links) + ;; Remove the overlay created by goto-address-mode + (remove-overlays (first link) (second link) 'goto-address t) + (make-text-button (first link) (second link) + 'action `(lambda (arg) + (notmuch-show ,(third link))) + 'follow-link t + 'help-echo "Mouse-1, RET: search for this message" + 'face goto-address-mail-face))))) ;;;###autoload (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name)