X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fnotmuch-show.el;h=fb91c83856eb5e248d7bd64ab7a9522593822550;hp=40cf74e8f110f447b9196bd709c12adfa191e27d;hb=d1cbd833a7b3ebfaeb0252b9c7fc98762a5f3961;hpb=a87a6b99f9f94ec7e0b4299b5824477f9056bab1 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 40cf74e8..fb91c838 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -224,22 +224,25 @@ same as that of the previous message." ")")))))) (defun notmuch-show-clean-address (address) - "Clean a single email address for display." - (let* ((parsed (mail-header-parse-address address)) - (address (car parsed)) - (name (cdr parsed))) - ;; Remove double quotes. They might be required during transport, - ;; but we don't need to see them. - (when name - (setq name (replace-regexp-in-string "\"" "" name))) - ;; If the address is 'foo@bar.com ' then show just - ;; 'foo@bar.com'. - (when (string= name address) - (setq name nil)) - - (if (not name) - address - (concat name " <" address ">")))) + "Try to clean a single email ADDRESS for display. Return +unchanged ADDRESS if parsing fails." + (condition-case nil + (let* ((parsed (mail-header-parse-address address)) + (address (car parsed)) + (name (cdr parsed))) + ;; Remove double quotes. They might be required during transport, + ;; but we don't need to see them. + (when name + (setq name (replace-regexp-in-string "\"" "" name))) + ;; If the address is 'foo@bar.com ' then show just + ;; 'foo@bar.com'. + (when (string= name address) + (setq name nil)) + + (if (not name) + address + (concat name " <" address ">"))) + (error address))) (defun notmuch-show-insert-headerline (headers date tags depth) "Insert a notmuch style headerline based on HEADERS for a @@ -280,18 +283,23 @@ message at DEPTH in the current thread." 'face 'message-mml) (defun notmuch-show-insert-part-header (nth content-type declared-type &optional name comment) - (insert-button - (concat "[ " - (if name (concat name ": ") "") - declared-type - (if (not (string-equal declared-type content-type)) - (concat " (as " content-type ")") - "") - (or comment "") - " ]\n") - :type 'notmuch-show-part-button-type - :notmuch-part nth - :notmuch-filename name)) + (let ((button)) + (setq button + (insert-button + (concat "[ " + (if name (concat name ": ") "") + declared-type + (if (not (string-equal declared-type content-type)) + (concat " (as " content-type ")") + "") + (or comment "") + " ]") + :type 'notmuch-show-part-button-type + :notmuch-part nth + :notmuch-filename name)) + (insert "\n") + ;; return button + button)) ;; Functions handling particular MIME parts.