mu4e: add variable mu4e-view-auto-mark-as-read

When set to nil, do not attempt to mark messages as read when you open
them; this can be useful on read-only file systems.

Fixes issue #515.
This commit is contained in:
djcb 2015-12-27 14:30:02 +02:00
parent 29a44e4371
commit 825881feb3
3 changed files with 47 additions and 27 deletions

View File

@ -47,6 +47,10 @@
- add mu4e-view-toggle-html (keybinding: 'h') to toggle between - add mu4e-view-toggle-html (keybinding: 'h') to toggle between
text and html display. The existing 'mu4e-view-toggle-hide-cited' text and html display. The existing 'mu4e-view-toggle-hide-cited'
gets the new binding '#'. gets the new binding '#'.
- add a customization variable `mu4e-view-auto-mark-as-read'
(defaults to t); if set to nil, mu4e won't mark messages as read
when you open them. This can be useful on read-only file-systems,
since marking-as-read implies a file-move operation.
** 0.9.13 ** 0.9.13

View File

@ -152,6 +152,14 @@ The first letter of NAME is used as a shortcut character.")
map) map)
"Keymap used in the \"Attachements\" header field.") "Keymap used in the \"Attachements\" header field.")
(defcustom mu4e-view-auto-mark-as-read t
"Automatically mark messages are 'read' when you read
them. This is typically the expected behavior, but can be turned
off, for example when using a read-only file-system."
:type 'boolean
:group 'mu4e-view)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -275,12 +283,12 @@ marking if it still had that."
(if embedded (if embedded
(mu4e~view-embedded-winbuf) (mu4e~view-embedded-winbuf)
(get-buffer-create mu4e~view-buffer-name)))) (get-buffer-create mu4e~view-buffer-name))))
;; note: mu4e~view-mark-as-read will pseudo-recursively call mu4e-view again ;; note: mu4e~view-mark-as-read-maybe will pseudo-recursively call mu4e-view again by triggering
;; by triggering mu4e~view again as it marks the message as read ;; mu4e~view again as it marks the message as read
(with-current-buffer buf (with-current-buffer buf
(switch-to-buffer buf) (switch-to-buffer buf)
(setq mu4e~view-msg msg) (setq mu4e~view-msg msg)
(when (or embedded (not (mu4e~view-mark-as-read msg))) (when (or embedded (not (mu4e~view-mark-as-read-maybe msg)))
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(erase-buffer) (erase-buffer)
(mu4e~delete-all-overlays) (mu4e~delete-all-overlays)
@ -745,17 +753,16 @@ FUNC should be a function taking two arguments:
(when (boundp 'autopair-dont-activate) (when (boundp 'autopair-dont-activate)
(setq autopair-dont-activate t))) (setq autopair-dont-activate t)))
(defun mu4e~view-mark-as-read (msg) (defun mu4e~view-mark-as-read-maybe (msg)
"Clear the message MSG New/Unread status and set it to Seen. "Clear the message MSG New/Unread status and set it to Seen.
If the message is not New/Unread, do nothing. Evaluates to t if it If the message is not New/Unread, do nothing. Evaluates to t if it
triggers any changes, nil otherwise. If this function does any triggers any changes, nil otherwise. If this function does any
changes, it triggers a refresh." changes, it triggers a refresh."
(when msg (when (and mu4e-view-auto-mark-as-read msg)
(let ((flags (mu4e-message-field msg :flags)) (let ((flags (mu4e-message-field msg :flags))
(msgid (mu4e-message-field msg :message-id)) (msgid (mu4e-message-field msg :message-id))
(docid (mu4e-message-field msg :docid))) (docid (mu4e-message-field msg :docid)))
;; attached (embedded) messages don't have docids; leave them alone ;; attached (embedded) messages don't have docids; leave them alone if it is a new message
;; is it a new message
(when (and docid (or (member 'unread flags) (member 'new flags))) (when (and docid (or (member 'unread flags) (member 'new flags)))
;; mark /all/ messages with this message-id as read, so all copies of ;; mark /all/ messages with this message-id as read, so all copies of
;; this message will be marked as read. ;; this message will be marked as read.

View File

@ -230,8 +230,8 @@ After these steps, @t{mu4e} should be ready to go!
@node Requirements @node Requirements
@section Requirements @section Requirements
@t{mu}/@t{mu4e} are known to work on a wide variety of Unix- and Unix-like @t{mu}/@t{mu4e} are known to work on a wide variety of Unix- and
systems, including many Linux distributions, MacOS and Unix-like systems, including many Linux distributions, OS X and
FreeBSD. @command{emacs} 23 or 24 (recommended) is required, as well as FreeBSD. @command{emacs} 23 or 24 (recommended) is required, as well as
Xapian@footnote{@url{http://xapian.org/}} and Xapian@footnote{@url{http://xapian.org/}} and
GMime@footnote{@url{http://spruce.sourceforge.net/gmime/}}. GMime@footnote{@url{http://spruce.sourceforge.net/gmime/}}.
@ -1104,8 +1104,11 @@ addresses by clicking on the name, or pressing @key{M-RET}.
defines @key{w} to toggle between the wrapped and unwrapped state. If you want defines @key{w} to toggle between the wrapped and unwrapped state. If you want
to do this automatically when viewing a message, invoke @code{visual-line-mode} to do this automatically when viewing a message, invoke @code{visual-line-mode}
in your @code{mu4e-view-mode-hook}. in your @code{mu4e-view-mode-hook}.
@item You can hide cited parts in messages (the parts starting with ``@t{>}'') @item For messages that support it, you can toggle between html and text versions using
using @code{mu4e-view-hide-cited}, bound to @key{h}. If you want to do this @code{mu4e-view-toggle-html}, bound to @key{h};
@item You can hide cited parts
in messages (the parts starting with ``@t{>}'') using
@code{mu4e-view-hide-cited}, bound to @key{#}. If you want to do this
automatically for every message, invoke the function in your automatically for every message, invoke the function in your
@code{mu4e-view-mode-hook}. @code{mu4e-view-mode-hook}.
@item For search-related operations, see @ref{Searching}. @item For search-related operations, see @ref{Searching}.
@ -1194,7 +1197,7 @@ c copy address at point (with C-u copy long version)
h toggle between html/text (if available) h toggle between html/text (if available)
w toggle line wrapping w toggle line wrapping
# toggle showing cited parts # toggle show/hide cited parts
v show details about the cryptographic signature v show details about the cryptographic signature
@ -1211,10 +1214,10 @@ For the marking commands, please refer to @ref{Marking messages}.
@section Opening and saving attachments @section Opening and saving attachments
By default, @t{mu4e} uses the @t{xdg-open}-program By default, @t{mu4e} uses the @t{xdg-open}-program
@footnote{@url{http://portland.freedesktop.org/wiki/}} or (on MacOS) the @footnote{@url{http://portland.freedesktop.org/wiki/}} or (on OS X) the
@t{open} program for opening attachments. If you want to use another program, @t{open} program for opening attachments. If you want to use another
you do so by setting the @t{MU_PLAY_PROGRAM} environment variable to the program, you do so by setting the @t{MU_PLAY_PROGRAM} environment
program to be used. variable to the program to be used.
The default directory for extracting (saving) attachments is your home The default directory for extracting (saving) attachments is your home
directory (@file{~/}); you can change this using the variable directory (@file{~/}); you can change this using the variable
@ -1309,7 +1312,8 @@ installing that, you can tell @t{mu4e} to use it with something like:
"html2markdown | grep -v '&nbsp_place_holder;'") "html2markdown | grep -v '&nbsp_place_holder;'")
@end lisp @end lisp
OS X, there is a program called @t{textutil} as yet another alternative: On OS X, there is a program called @t{textutil} as yet another
alternative:
@lisp @lisp
(setq mu4e-html2text-command (setq mu4e-html2text-command
@ -1343,6 +1347,12 @@ of the @t{shr} key bindings, with something like:
(local-set-key (kbd "<backtab>") 'shr-previous-link))) (local-set-key (kbd "<backtab>") 'shr-previous-link)))
@end lisp @end lisp
If you're using a dark theme, and the messages are hard to read, it can help to change
the luminosity, e.g.:
@lisp
(setq shr-color-visible-luminance-min 80)
@end lisp
@node MSGV Crypto @node MSGV Crypto
@section Crypto @section Crypto
@ -2926,7 +2936,7 @@ a message to your todo-list, and set a deadline for processing it within
two days, you could add this to @code{org-capture-templates}: two days, you could add this to @code{org-capture-templates}:
@lisp @lisp
("S" "read-soon" entry (file+headline "todo.org" "Reading") ("P" "process-soon" entry (file+headline "todo.org" "Todo")
"* TODO %a %?\nDEADLINE: %(org-insert-time-stamp (org-read-date nil t \"+2d\"))") "* TODO %a %?\nDEADLINE: %(org-insert-time-stamp (org-read-date nil t \"+2d\"))")
@end lisp @end lisp
@ -3566,18 +3576,17 @@ its docstring).
message?} You can toggle between wrapped and non-wrapped states using message?} You can toggle between wrapped and non-wrapped states using
@key{w}. If you want to do this automatically, invoke @code{visual-line-mode} in @key{w}. If you want to do this automatically, invoke @code{visual-line-mode} in
your @code{mu4e-view-mode-hook}. your @code{mu4e-view-mode-hook}.
@item @emph{What about hiding cited parts?} Toggle between hiding and showing
of cited parts with @key{h}. If you want to hide parts automatically, call
@code{mu4e-view-toggle-hide-cited} in your @code{mu4e-view-mode-hook}.
@item @emph{How can I perform custom actions on messages and attachments?} See @item @emph{How can I perform custom actions on messages and attachments?} See
@ref{Actions}. @ref{Actions}.
@item @emph{Does @t{mu4e} support crypto (i.e., decrypting messages and @item @emph{Does @t{mu4e} support crypto (i.e., decrypting messages and
verifying signatures)?} Yes -- if @t{mu} was built with @t{GMime} 2.6 or verifying signatures)?} Yes -- if @t{mu} was built with @t{GMime} 2.6
later, it is possible to do both (note, only PGP/MIME is supported). In the or later, it is possible to do both (note, only PGP/MIME is
@ref{Main view} the support is indicated by a big letter @t{C} on the right supported). In the @ref{Main view} the support is indicated by a big
hand side of the @t{mu4e} version. See @ref{Decryption} and @ref{Verifying letter @t{C} on the right hand side of the @t{mu4e} version. See
signatures}. For encryption and signing messages, see the @ref{Writing @ref{Decryption} and @ref{Verifying signatures}. For encryption and
messages}. signing messages, see @ref{Writing messages}.
@item @emph{How can I prevent @t{mu4e} from automatically marking messages as 'read' when i read them?}
Set @code{mu4e-view-auto-mark-as-read} to nil.
@item @emph{Does @t{mu4e} support including all related messages in a thread, @item @emph{Does @t{mu4e} support including all related messages in a thread,
like Gmail does?} Yes -- see @ref{Including related messages}. like Gmail does?} Yes -- see @ref{Including related messages}.
@item @emph{There seem to be a lot of duplicate messages -- how can I get rid @item @emph{There seem to be a lot of duplicate messages -- how can I get rid