mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 04:18:08 +01:00
Simplify "unread" tag handling in emacs UI.
This patch is intended to greatly simplify the handling of the "unread" tag in the emacs UI. This patch adds a new function 'notmuch-show-mark-read', that removes the "unread" tag in notmuch-show-mode. This function is then executed as a notmuch-show-hook, and by notmuch-show-next-message. All of the functions that explicitly marked messages as unread are removed or renamed. The idea here is that the user should never have to worry about manipulating the "unread" tag. The tag should persist until the user actually views a message, at which point it should be automatically removed. This patch simplifies the notmuch.el quite a bit, removing a lot of somewhat redundant functions, and reducing clutter in the name and key-mapping space.
This commit is contained in:
parent
a7afcee50c
commit
4b9d2e3a4d
1 changed files with 33 additions and 66 deletions
99
notmuch.el
99
notmuch.el
|
@ -88,15 +88,12 @@
|
||||||
(define-key map "h" 'notmuch-show-toggle-current-header)
|
(define-key map "h" 'notmuch-show-toggle-current-header)
|
||||||
(define-key map "-" 'notmuch-show-remove-tag)
|
(define-key map "-" 'notmuch-show-remove-tag)
|
||||||
(define-key map "+" 'notmuch-show-add-tag)
|
(define-key map "+" 'notmuch-show-add-tag)
|
||||||
(define-key map "X" 'notmuch-show-mark-read-then-archive-then-exit)
|
|
||||||
(define-key map "x" 'notmuch-show-archive-thread-then-exit)
|
(define-key map "x" 'notmuch-show-archive-thread-then-exit)
|
||||||
(define-key map "A" 'notmuch-show-mark-read-then-archive-thread)
|
|
||||||
(define-key map "a" 'notmuch-show-archive-thread)
|
(define-key map "a" 'notmuch-show-archive-thread)
|
||||||
(define-key map "p" 'notmuch-show-previous-message)
|
(define-key map "p" 'notmuch-show-previous-message)
|
||||||
(define-key map "N" 'notmuch-show-mark-read-then-next-open-message)
|
|
||||||
(define-key map "n" 'notmuch-show-next-message)
|
(define-key map "n" 'notmuch-show-next-message)
|
||||||
(define-key map (kbd "DEL") 'notmuch-show-rewind)
|
(define-key map (kbd "DEL") 'notmuch-show-rewind)
|
||||||
(define-key map " " 'notmuch-show-advance-marking-read-and-archiving)
|
(define-key map " " 'notmuch-show-advance-and-archive)
|
||||||
map)
|
map)
|
||||||
"Keymap for \"notmuch show\" buffers.")
|
"Keymap for \"notmuch show\" buffers.")
|
||||||
(fset 'notmuch-show-mode-map notmuch-show-mode-map)
|
(fset 'notmuch-show-mode-map notmuch-show-mode-map)
|
||||||
|
@ -321,40 +318,6 @@ pseudoheader summary"
|
||||||
(cons (notmuch-show-get-message-id) nil)))
|
(cons (notmuch-show-get-message-id) nil)))
|
||||||
(notmuch-show-set-tags (sort (set-difference tags toremove :test 'string=) 'string<))))))
|
(notmuch-show-set-tags (sort (set-difference tags toremove :test 'string=) 'string<))))))
|
||||||
|
|
||||||
(defun notmuch-show-archive-thread-maybe-mark-read (markread)
|
|
||||||
(save-excursion
|
|
||||||
(goto-char (point-min))
|
|
||||||
(while (not (eobp))
|
|
||||||
(if markread
|
|
||||||
(notmuch-show-remove-tag "unread" "inbox")
|
|
||||||
(notmuch-show-remove-tag "inbox"))
|
|
||||||
(if (not (eobp))
|
|
||||||
(forward-char))
|
|
||||||
(if (not (re-search-forward notmuch-show-message-begin-regexp nil t))
|
|
||||||
(goto-char (point-max)))))
|
|
||||||
(let ((parent-buffer notmuch-show-parent-buffer))
|
|
||||||
(kill-this-buffer)
|
|
||||||
(if parent-buffer
|
|
||||||
(progn
|
|
||||||
(switch-to-buffer parent-buffer)
|
|
||||||
(forward-line)
|
|
||||||
(notmuch-search-show-thread)))))
|
|
||||||
|
|
||||||
(defun notmuch-show-mark-read-then-archive-thread ()
|
|
||||||
"Remove unread tags from thread, then archive and show next thread.
|
|
||||||
|
|
||||||
Archive each message currently shown by removing the \"unread\"
|
|
||||||
and \"inbox\" tag from each. Then kill this buffer and show the
|
|
||||||
next thread from the search from which this thread was originally
|
|
||||||
shown.
|
|
||||||
|
|
||||||
Note: This command is safe from any race condition of new messages
|
|
||||||
being delivered to the same thread. It does not archive the
|
|
||||||
entire thread, but only the messages shown in the current
|
|
||||||
buffer."
|
|
||||||
(interactive)
|
|
||||||
(notmuch-show-archive-thread-maybe-mark-read t))
|
|
||||||
|
|
||||||
(defun notmuch-show-archive-thread ()
|
(defun notmuch-show-archive-thread ()
|
||||||
"Archive each message in thread, then show next thread from search.
|
"Archive each message in thread, then show next thread from search.
|
||||||
|
|
||||||
|
@ -367,7 +330,21 @@ being delivered to the same thread. It does not archive the
|
||||||
entire thread, but only the messages shown in the current
|
entire thread, but only the messages shown in the current
|
||||||
buffer."
|
buffer."
|
||||||
(interactive)
|
(interactive)
|
||||||
(notmuch-show-archive-thread-maybe-mark-read nil))
|
(save-excursion
|
||||||
|
(goto-char (point-min))
|
||||||
|
(while (not (eobp))
|
||||||
|
(notmuch-show-remove-tag "inbox")
|
||||||
|
(if (not (eobp))
|
||||||
|
(forward-char))
|
||||||
|
(if (not (re-search-forward notmuch-show-message-begin-regexp nil t))
|
||||||
|
(goto-char (point-max)))))
|
||||||
|
(let ((parent-buffer notmuch-show-parent-buffer))
|
||||||
|
(kill-this-buffer)
|
||||||
|
(if parent-buffer
|
||||||
|
(progn
|
||||||
|
(switch-to-buffer parent-buffer)
|
||||||
|
(forward-line)
|
||||||
|
(notmuch-search-show-thread)))))
|
||||||
|
|
||||||
(defun notmuch-show-archive-thread-then-exit ()
|
(defun notmuch-show-archive-thread-then-exit ()
|
||||||
"Archive each message in thread, then exit back to search results."
|
"Archive each message in thread, then exit back to search results."
|
||||||
|
@ -375,12 +352,6 @@ buffer."
|
||||||
(notmuch-show-archive-thread)
|
(notmuch-show-archive-thread)
|
||||||
(kill-this-buffer))
|
(kill-this-buffer))
|
||||||
|
|
||||||
(defun notmuch-show-mark-read-then-archive-then-exit ()
|
|
||||||
"Remove unread tags from thread, then archive and exit to search results."
|
|
||||||
(interactive)
|
|
||||||
(notmuch-show-mark-read-then-archive-thread)
|
|
||||||
(kill-this-buffer))
|
|
||||||
|
|
||||||
(defun notmuch-show-view-raw-message ()
|
(defun notmuch-show-view-raw-message ()
|
||||||
"View the raw email of the current message."
|
"View the raw email of the current message."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
@ -550,7 +521,8 @@ Returns nil if already on the last message in the buffer."
|
||||||
(while (point-invisible-p)
|
(while (point-invisible-p)
|
||||||
(backward-char))
|
(backward-char))
|
||||||
(recenter 0)
|
(recenter 0)
|
||||||
nil))
|
nil)
|
||||||
|
(notmuch-show-mark-read))
|
||||||
|
|
||||||
(defun notmuch-show-find-next-message ()
|
(defun notmuch-show-find-next-message ()
|
||||||
"Returns the position of the next message in the buffer.
|
"Returns the position of the next message in the buffer.
|
||||||
|
@ -613,14 +585,8 @@ it."
|
||||||
(notmuch-show-previous-message)
|
(notmuch-show-previous-message)
|
||||||
(point))))
|
(point))))
|
||||||
|
|
||||||
(defun notmuch-show-mark-read-then-next-open-message ()
|
|
||||||
"Remove unread tag from this message, then advance to next open message."
|
|
||||||
(interactive)
|
|
||||||
(notmuch-show-remove-tag "unread")
|
|
||||||
(notmuch-show-next-open-message))
|
|
||||||
|
|
||||||
(defun notmuch-show-rewind ()
|
(defun notmuch-show-rewind ()
|
||||||
"Backup through the thread, (reverse scrolling compared to \\[notmuch-show-advance-marking-read-and-archiving]).
|
"Backup through the thread, (reverse scrolling compared to \\[notmuch-show-advance-and-archive]).
|
||||||
|
|
||||||
Specifically, if the beginning of the previous email is fewer
|
Specifically, if the beginning of the previous email is fewer
|
||||||
than `window-height' lines from the current point, move to it
|
than `window-height' lines from the current point, move to it
|
||||||
|
@ -630,7 +596,7 @@ Otherwise, just scroll down a screenful of the current message.
|
||||||
|
|
||||||
This command does not modify any message tags, (it does not undo
|
This command does not modify any message tags, (it does not undo
|
||||||
any effects from previous calls to
|
any effects from previous calls to
|
||||||
`notmuch-show-advance-marking-read-and-archiving'."
|
`notmuch-show-advance-and-archive'."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((previous (notmuch-show-find-previous-message)))
|
(let ((previous (notmuch-show-find-previous-message)))
|
||||||
(if (> (count-lines previous (point)) (- (window-height) next-screen-context-lines))
|
(if (> (count-lines previous (point)) (- (window-height) next-screen-context-lines))
|
||||||
|
@ -641,8 +607,8 @@ any effects from previous calls to
|
||||||
(goto-char (window-start)))
|
(goto-char (window-start)))
|
||||||
(notmuch-show-previous-message))))
|
(notmuch-show-previous-message))))
|
||||||
|
|
||||||
(defun notmuch-show-advance-marking-read-and-archiving ()
|
(defun notmuch-show-advance-and-archive ()
|
||||||
"Advance through thread, marking read and archiving.
|
"Advance through thread and archive.
|
||||||
|
|
||||||
This command is intended to be one of the simplest ways to
|
This command is intended to be one of the simplest ways to
|
||||||
process a thread of email. It does the following:
|
process a thread of email. It does the following:
|
||||||
|
@ -651,8 +617,7 @@ If the current message in the thread is not yet fully visible,
|
||||||
scroll by a near screenful to read more of the message.
|
scroll by a near screenful to read more of the message.
|
||||||
|
|
||||||
Otherwise, (the end of the current message is already within the
|
Otherwise, (the end of the current message is already within the
|
||||||
current window), remove the \"unread\" tag (if present) from the
|
current window), advance to the next open message.
|
||||||
current message and advance to the next open message.
|
|
||||||
|
|
||||||
Finally, if there is no further message to advance to, and this
|
Finally, if there is no further message to advance to, and this
|
||||||
last message is already read, then archive the entire current
|
last message is already read, then archive the entire current
|
||||||
|
@ -665,7 +630,7 @@ which this thread was originally shown."
|
||||||
(if (> next (window-end))
|
(if (> next (window-end))
|
||||||
(scroll-up nil)
|
(scroll-up nil)
|
||||||
(let ((last (notmuch-show-last-message-p)))
|
(let ((last (notmuch-show-last-message-p)))
|
||||||
(notmuch-show-mark-read-then-next-open-message)
|
(notmuch-show-next-open-message)
|
||||||
(if last
|
(if last
|
||||||
(notmuch-show-archive-thread))))))
|
(notmuch-show-archive-thread))))))
|
||||||
|
|
||||||
|
@ -1065,17 +1030,15 @@ pressing RET after positioning the cursor on a hidden part, (for
|
||||||
which \\[notmuch-show-next-button] and \\[notmuch-show-previous-button] are helpful).
|
which \\[notmuch-show-next-button] and \\[notmuch-show-previous-button] are helpful).
|
||||||
|
|
||||||
Reading the thread sequentially is well-supported by pressing
|
Reading the thread sequentially is well-supported by pressing
|
||||||
\\[notmuch-show-advance-marking-read-and-archiving]. This will scroll the current message (if necessary),
|
\\[notmuch-show-advance-and-archive]. This will
|
||||||
advance to the next message, or advance to the next thread (if
|
scroll the current message (if necessary), advance to the next
|
||||||
already on the last message of a thread). As each message is
|
message, or advance to the next thread (if already on the last
|
||||||
scrolled away its \"unread\" tag will be removed, and as each
|
message of a thread).
|
||||||
thread is scrolled away the \"inbox\" tag will be removed from
|
|
||||||
each message in the thread.
|
|
||||||
|
|
||||||
Other commands are available to read or manipulate the thread more
|
Other commands are available to read or manipulate the thread more
|
||||||
selectively, (such as '\\[notmuch-show-next-message]' and '\\[notmuch-show-previous-message]' to advance to messages without
|
selectively, (such as '\\[notmuch-show-next-message]' and '\\[notmuch-show-previous-message]' to advance to messages without
|
||||||
removing any tags, and '\\[notmuch-show-archive-thread]' to archive an entire thread without
|
removing any tags, and '\\[notmuch-show-archive-thread]' to archive an entire thread without
|
||||||
scrolling through with \\[notmuch-show-advance-marking-read-and-archiving]).
|
scrolling through with \\[notmuch-show-advance-and-archive]).
|
||||||
|
|
||||||
You can add or remove arbitary tags from the current message with
|
You can add or remove arbitary tags from the current message with
|
||||||
'\\[notmuch-show-add-tag]' or '\\[notmuch-show-remove-tag]'.
|
'\\[notmuch-show-add-tag]' or '\\[notmuch-show-remove-tag]'.
|
||||||
|
@ -1153,10 +1116,14 @@ All currently available key bindings:
|
||||||
|
|
||||||
; Make show mode a bit prettier, highlighting URLs and using word wrap
|
; Make show mode a bit prettier, highlighting URLs and using word wrap
|
||||||
|
|
||||||
|
(defun notmuch-show-mark-read ()
|
||||||
|
(notmuch-show-remove-tag "unread"))
|
||||||
|
|
||||||
(defun notmuch-show-pretty-hook ()
|
(defun notmuch-show-pretty-hook ()
|
||||||
(goto-address-mode 1)
|
(goto-address-mode 1)
|
||||||
(visual-line-mode))
|
(visual-line-mode))
|
||||||
|
|
||||||
|
(add-hook 'notmuch-show-hook 'notmuch-show-mark-read)
|
||||||
(add-hook 'notmuch-show-hook 'notmuch-show-pretty-hook)
|
(add-hook 'notmuch-show-hook 'notmuch-show-pretty-hook)
|
||||||
(add-hook 'notmuch-search-hook
|
(add-hook 'notmuch-search-hook
|
||||||
(lambda()
|
(lambda()
|
||||||
|
|
Loading…
Reference in a new issue