X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fnotmuch-show.el;h=7469e2eb8feb6ee8f9ffe0afc8a94a74541e7257;hp=10b3ea91d266e6f74fccf86b398020fb33e15b55;hb=d8d73878815f3038c1a4005e43d35e6b7acf722f;hpb=be05158b69d45b63999707f60b8ee0166438a944 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 10b3ea91..7469e2eb 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -316,15 +316,25 @@ unchanged ADDRESS if parsing fails." (t (setq p-address address))) - ;; Remove elements of the mailbox part that are not relevant for - ;; display, even if they are required during transport. (when p-name - ;; Outer double quotes. - (when (string-match "^\"\\(.*\\)\"$" p-name) - (setq p-name (match-string 1 p-name))) - + ;; Remove elements of the mailbox part that are not relevant for + ;; display, even if they are required during transport: + ;; ;; Backslashes. - (setq p-name (replace-regexp-in-string "\\\\" "" p-name))) + (setq p-name (replace-regexp-in-string "\\\\" "" p-name)) + + ;; Outer single and double quotes, which might be nested. + (loop + with start-of-loop + do (setq start-of-loop p-name) + + when (string-match "^\"\\(.*\\)\"$" p-name) + do (setq p-name (match-string 1 p-name)) + + when (string-match "^'\\(.*\\)'$" p-name) + do (setq p-name (match-string 1 p-name)) + + until (string= start-of-loop p-name))) ;; If the address is 'foo@bar.com ' then show just ;; 'foo@bar.com'. @@ -855,8 +865,6 @@ current buffer, if possible." ;; compatible with the existing implementation. This just sets it ;; to after the first header. (notmuch-show-insert-headers headers) - ;; Headers should include a blank line (backwards compatibility). - (insert "\n") (save-excursion (goto-char content-start) ;; If the subject of this message is the same as that of the @@ -871,6 +879,8 @@ current buffer, if possible." (setq notmuch-show-previous-subject bare-subject) (setq body-start (point-marker)) + ;; A blank line between the headers and the body. + (insert "\n") (notmuch-show-insert-body msg (plist-get msg :body) depth) ;; Ensure that the body ends with a newline. (unless (bolp) @@ -1018,7 +1028,7 @@ buffer." (notmuch-show-next-open-message)) ;; Set the header line to the subject of the first open message. - (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject))) + (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-pretty-subject))) (notmuch-show-mark-read))) @@ -1076,7 +1086,8 @@ thread id. If a prefix is given, crypto processing is toggled." (define-key map "-" 'notmuch-show-remove-tag) (define-key map "+" 'notmuch-show-add-tag) (define-key map "x" 'notmuch-show-archive-thread-then-exit) - (define-key map "a" 'notmuch-show-archive-thread-then-next) + (define-key map "a" 'notmuch-show-archive-message-then-next) + (define-key map "A" 'notmuch-show-archive-thread-then-next) (define-key map "N" 'notmuch-show-next-message) (define-key map "P" 'notmuch-show-previous-message) (define-key map "n" 'notmuch-show-next-open-message) @@ -1249,6 +1260,9 @@ Some useful entries are: (defun notmuch-show-get-depth () (notmuch-show-get-prop :depth)) +(defun notmuch-show-get-pretty-subject () + (notmuch-prettify-subject (notmuch-show-get-subject))) + (defun notmuch-show-set-tags (tags) "Set the tags of the current message." (notmuch-show-set-prop :tags tags) @@ -1363,11 +1377,10 @@ any effects from previous calls to ;; If a small number of lines from the previous message are ;; visible, realign so that the top of the current message is at ;; the top of the screen. - (if (<= (count-screen-lines (window-start) start-of-message) - next-screen-context-lines) - (progn - (goto-char (notmuch-show-message-top)) - (notmuch-show-message-adjust))) + (when (<= (count-screen-lines (window-start) start-of-message) + next-screen-context-lines) + (goto-char (notmuch-show-message-top)) + (notmuch-show-message-adjust)) ;; Move to the top left of the window. (goto-char (window-start))) (t @@ -1390,14 +1403,19 @@ any effects from previous calls to (with-current-notmuch-show-message (notmuch-mua-new-forward-message prompt-for-sender))) -(defun notmuch-show-next-message () - "Show the next message." - (interactive) +(defun notmuch-show-next-message (&optional pop-at-end) + "Show the next message. + +If a prefix argument is given and this is the last message in the +thread, navigate to the next thread in the parent search buffer." + (interactive "P") (if (notmuch-show-goto-message-next) (progn (notmuch-show-mark-read) (notmuch-show-message-adjust)) - (goto-char (point-max)))) + (if pop-at-end + (notmuch-show-next-thread) + (goto-char (point-max))))) (defun notmuch-show-previous-message () "Show the previous message." @@ -1406,9 +1424,13 @@ any effects from previous calls to (notmuch-show-mark-read) (notmuch-show-message-adjust)) -(defun notmuch-show-next-open-message () - "Show the next message." - (interactive) +(defun notmuch-show-next-open-message (&optional pop-at-end) + "Show the next open message. + +If a prefix argument is given and this is the last open message +in the thread, navigate to the next thread in the parent search +buffer." + (interactive "P") (let (r) (while (and (setq r (notmuch-show-goto-message-next)) (not (notmuch-show-message-visible-p)))) @@ -1416,10 +1438,12 @@ any effects from previous calls to (progn (notmuch-show-mark-read) (notmuch-show-message-adjust)) - (goto-char (point-max))))) + (if pop-at-end + (notmuch-show-next-thread) + (goto-char (point-max)))))) (defun notmuch-show-previous-open-message () - "Show the previous message." + "Show the previous open message." (interactive) (while (and (notmuch-show-goto-message-previous) (not (notmuch-show-message-visible-p)))) @@ -1622,6 +1646,23 @@ buffer." (notmuch-show-archive-thread) (notmuch-show-next-thread)) +(defun notmuch-show-archive-message (&optional unarchive) + "Archive the current message. + +If a prefix argument is given, the message will be +\"unarchived\" (ie. the \"inbox\" tag will be added instead of +removed)." + (interactive "P") + (if unarchive + (notmuch-show-add-tag "inbox") + (notmuch-show-remove-tag "inbox"))) + +(defun notmuch-show-archive-message-then-next () + "Archive the current message, then show the next open message in the current thread." + (interactive) + (notmuch-show-archive-message) + (notmuch-show-next-open-message t)) + (defun notmuch-show-stash-cc () "Copy CC field of current message to kill-ring." (interactive)