* add user-settable variables mu4e-view-wrap-lines and mu4e-view-hide-cited,

which determine the initial way a message is displayed. document this.
This commit is contained in:
djcb 2012-04-01 12:31:23 +03:00
parent aa952aa430
commit dd1e11289a
3 changed files with 109 additions and 64 deletions

View File

@ -55,7 +55,9 @@ wanting to show specific messages - for example, `mu4e-org'."
"Display the message MSG in a new buffer, and keep in sync with HDRSBUF.
'In sync' here means that moving to the next/previous message in
the the message view affects HDRSBUF, as does marking etc. If
UPDATE is non-nil, the current message will be (visually) updated.
UPDATE is nil, the current message may be (visually) 'massaged',
based on the settings of `mu4e-view-wrap-lines' and
`mu4e-view-hide-cited'.
As a side-effect, a message that is being viewed loses its 'unread'
marking if it still had that."
@ -69,7 +71,6 @@ marking if it still had that."
(let ((fieldname (cdr (assoc field mu4e-header-names)))
(fieldval (plist-get msg field)))
(case field
(:subject (mu4e-view-header fieldname fieldval))
(:path (mu4e-view-header fieldname fieldval))
(:maildir (mu4e-view-header fieldname fieldval))
@ -122,6 +123,15 @@ marking if it still had that."
(mu4e-mark-footer)
(mu4e-make-urls-clickable)
(unless update
;; if we're showing the message for the first time, use the values of
;; user-settable variables `mu4e-view-wrap-lines' and
;; `mu4e-view-hide-cited' to determine whether we should wrap/hide
(progn
(when mu4e-view-wrap-lines (mu4e-view-wrap-lines))
(when mu4e-view-hide-cited (mu4e-view-hide-cited))))
;; no use in trying to set flags again
(unless update
(mu4e-view-mark-as-read-maybe)))))
@ -328,13 +338,8 @@ if IS-OPEN is nil, and otherwise open it."
(fset 'mu4e-view-mode-map mu4e-view-mode-map)
(defvar mu4e-wrap-lines nil
"*internal* Whether to wrap lines or not (variable controlled by
`mu4e-view-toggle-wrap-lines').")
(defvar mu4e-hide-cited nil
"*internal* Whether to hide cited lines or not (the variable can
be changed with `mu4e-view-toggle-hide-cited').")
(defvar mu4e-lines-wrapped nil "*internal* Whether lines are wrapped.")
(defvar mu4e-cited-hidden nil "*internal* Whether cited lines are hidden.")
(define-derived-mode mu4e-view-mode special-mode "mu4e:view"
"Major mode for viewing an e-mail message in mu4e.
@ -345,14 +350,18 @@ if IS-OPEN is nil, and otherwise open it."
(make-local-variable 'mu4e-current-msg)
(make-local-variable 'mu4e-link-map)
(make-local-variable 'mu4e-wrap-lines)
(make-local-variable 'mu4e-hide-cited)
(make-local-variable 'mu4e-lines-wrapped)
(make-local-variable 'mu4e-cited-hidden)
(setq
truncate-lines t))
;; filladapt is much better than the built-in filling
;; esp. with '>' cited parts
(when (fboundp 'filladapt-mode)
(filladapt-mode))
(setq truncate-lines t))
;; we mark messages are as read when we leave the message; ie., when skipping to
;; we mark messages are as read when we leave the message; i.e., when skipping to
;; the next/previous one, or leaving the view buffer altogether.
(defun mu4e-view-mark-as-read-maybe ()
@ -372,7 +381,7 @@ Seen; if the message is not New/Unread, do nothing."
(let ((more-lines t))
(goto-char (point-min))
(while more-lines
;; Get the citation level at point -- ie., the number of '>'
;; Get the citation level at point -- i.e., the number of '>'
;; prefixes, starting with 0 for 'no citation'
(beginning-of-line 1)
(let* ((text (re-search-forward "[[:word:]]" (line-end-position 1) t 1))
@ -422,7 +431,6 @@ Seen; if the message is not New/Unread, do nothing."
(browse-url url))))
;; this is fairly simplistic...
(defun mu4e-make-urls-clickable ()
"Turn things that look like URLs into clickable things, and
@ -553,45 +561,51 @@ See the `org-contacts' documentation for more details."
((eq name-or-email 'email)
(or (cdr-safe from) ""))
(t (error "Not supported: %S" name-or-email))))))
(defun mu4e-view-wrap-lines ()
"Wrap lines in the message body."
(save-excursion
(let ((inhibit-read-only t))
(goto-char (point-min))
(when (search-forward "\n\n") ;; search for the message body
(fill-region (point) (point-max)))
(setq mu4e-lines-wrapped t))))
(defun mu4e-view-hide-cited ()
"Toggle hiding of cited lines in the message body."
(save-excursion
(let ((inhibit-read-only t))
(goto-char (point-min))
(flush-lines "^[:blank:]*>")
(setq mu4e-cited-hidden t))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Interactive functions
(defun mu4e-view-toggle-wrap-lines ()
"Toggle line wrap in the message body."
(interactive)
(if mu4e-wrap-lines
(progn
(setq mu4e-wrap-lines nil)
(mu4e-view-refresh)) ;; back to normal
(save-excursion
(let ((inhibit-read-only t))
(setq mu4e-wrap-lines t)
(goto-char (point-min))
(when (search-forward "\n\n") ;; search for the message body
(fill-region (point) (point-max)))))))
(if mu4e-lines-wrapped
(mu4e-view-refresh)
(mu4e-view-wrap-lines)))
(defun mu4e-view-toggle-hide-cited ()
"Toggle hiding of cited lines in the message body."
(interactive)
(if mu4e-hide-cited
(progn
(setq mu4e-hide-cited nil)
(mu4e-view-refresh))
(save-excursion
(let ((inhibit-read-only t))
(goto-char (point-min))
(flush-lines "^[:blank:]*>")
(setq mu4e-hide-cited t)))))
(if mu4e-cited-hidden
(mu4e-view-refresh)
(mu4e-view-hide-cited)))
(defun mu4e-view-refresh ()
"Redisplay the current message."
"Redisplay the current message, without wrapped lines or hidden
citations."
(interactive)
(mu4e-view mu4e-current-msg mu4e-hdrs-buffer t))
(mu4e-view mu4e-current-msg mu4e-hdrs-buffer t)
(setq
mu4e-lines-wrapped nil
mu4e-cited-hidden nil))
(defun mu4e-view-quit-buffer ()
"Quit the message view and return to the headers."

View File

@ -137,7 +137,7 @@ sent folder."
;; Folders
(defgroup mu4e-folders nil
"Special folders for mm."
"Special folders."
:group 'mu4e)
(defcustom mu4e-sent-folder "/sent"
@ -241,6 +241,31 @@ recommended you use \"html2text -utf8 -width 72\"."
:group 'mu4e-view
:safe 'stringp)
(defcustom mu4e-view-wrap-lines nil
"Whether to automatically wrap lines in the body of messages when
viewing them. Note that wrapping does not work well with all
messages, but you can always toggle between wrapped/unwrapped
display with `mu4e-view-toggle-wrap-lines (default keybinding: <w>)."
:group 'mu4e-view)
(defcustom mu4e-view-wrap-lines nil
"Whether to automatically wrap lines in the body of messages when
viewing them. Note that wrapping does not work well with all
messages, but you can always toggle between wrapped/unwrapped
display with `mu4e-view-toggle-wrap-lines (default keybinding: <w>)."
:group 'mu4e-view)
(defcustom mu4e-view-hide-cited nil
"Whether to automatically hide cited parts of messages (as
determined by the presence of '> ' at the beginning of the
line). Note that you can always toggle between hidden/unhidden
display with `mu4e-view-toggle-hide-cited (default keybinding:
<w>)."
:group 'mu4e-view)
;; Composing / Sending messages
(defgroup mu4e-compose nil
"Customizations for composing/sending messages."
@ -283,18 +308,18 @@ sent folder."
;; Faces
(defgroup mu4e-faces nil
"Faces used in by mm."
"Type faces (fonts) used in mu4e."
:group 'mu4e
:group 'faces)
(defface mu4e-unread-face
'((t :inherit font-lock-keyword-face :bold t))
"Face for an unread mm message header."
"Face for an unread message header."
:group 'mu4e-faces)
(defface mu4e-moved-face
'((t :inherit font-lock-comment-face :slant italic))
"Face for an mm message header that has been moved to some
"Face for a message header that has been moved to some
folder (it's still visible in the search results, since we cannot
be sure it no longer matches)."
:group 'mu4e-faces)
@ -312,22 +337,24 @@ flag set)."
(defface mu4e-header-face
'((t :inherit default))
"Face for an mm header without any special flags."
"Face for a header without any special flags."
:group 'mu4e-faces)
(defface mu4e-title-face
'((t :inherit font-lock-type-face))
"Face for an mm title."
(defface mu4e-header-title-face
'((t :inherit font-lock-type-face :underline t))
"Face for a header title in the headers view."
:group 'mu4e-faces)
(defface mu4e-view-header-key-face
'((t :inherit font-lock-builtin-face :bold t))
"Face for the header title (such as \"Subject\" in the message view)."
"Face for a header title (such as \"Subject\") in the message
view."
:group 'mu4e-faces)
(defface mu4e-view-header-value-face
'((t :inherit font-lock-doc-face))
"Face for the header value (such as \"Re: Hello!\" in the message view)."
"Face for a header value (such as \"Re: Hello!\") in the message
view."
:group 'mu4e-faces)
(defface mu4e-view-link-face
@ -408,7 +435,7 @@ view). Most fields should be self-explanatory. A special one is
in which case it will be equal to `:to'.)")
;; mm startup function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun mu4e-create-maildir-maybe (dir)
"Offer to create DIR if it does not exist yet. Return t if the
dir already existed, or has been created, nil otherwise."
@ -449,7 +476,7 @@ dir already existed, or has been created, nil otherwise."
"*internal* The mu4e update timer.")
(defun mu4e ()
"Start mm. We do this by sending a 'ping' to the mu server
"Start mu4e. We do this by sending a 'ping' to the mu server
process, and start the main view if the 'pong' we receive from the
server has the expected values."
(interactive)
@ -477,7 +504,7 @@ server has the expected values."
(mu4e-proc-ping)))))
(defun mu4e-quit()
"Quit the mm session."
"Quit the mu4e session."
(interactive)
(when (y-or-n-p "Are you sure you want to quit? ")
(message nil)

View File

@ -65,11 +65,11 @@ really @emph{needs} another one, but maybe @emph{I} do! I spend a @emph{lot}
of time, both professionally and privately, dealing with e-mail -- having an
efficient e-mail client is essential for me. Since none of the existing ones
worked they I wanted, I created my own.
Still, even while having been created for such selfish motives, the feedback
of many early adopters has been used to ensure that @t{mu4e} works well for
other people as well.
@node Other mail clients
@section Other mail clients
@ -113,7 +113,7 @@ messages around and so on.
In this chapter, we go through installing @t{mu4e} and see how to set it
up. After we have succeeded in @ref{Getting mail}, and @ref{Indexing your
messages}, we discuss @ref{Basic configuration}.
messages}, we discuss @ref{Basic configuration}.
After going through these steps, @t{mu4e} should be ready for use.
@ -555,11 +555,20 @@ On Sun 21 Dec 2003 09:06:34 PM EET, Paul wrote:
Some notes:
@itemize
@item You can customize the header fields to show by setting the
@item You can determine which header fields are shown by setting the
variable @code{mu4e-view-fields}.
@item You can customize the date format by setting the variable
@code{mu4e-date-format-long}, using the same format that
@code{format-time-string} uses.
@item The body text can be line-wrapped (toggle between wrapped/not-wrapped with
@key{w}) and/or cited parts can be hidden (toggle between hidden/not-hidden
with @key{h}. If you want to do this by default when viewing messages, you can
set, respectively, @code{mu4e-view-wrap-lines} and @code{mu4e-view-hide-cited}
to @code{t}. @footnote{If you have installed the @t{filladapt} package
(@url{http://www.wonderworks.com/download/filladapt.el}), @t{mu4e} will use
it for line-wrapping, as it generally does a better job than the default
mechanism emacs provides.}
@end itemize
You can find most things you can do with this message in the @emph{View} menu,
@ -630,11 +639,6 @@ set up with something like the following in your initialization files:
Normally, @t{mu4e} prefers the text-version of an e-mail message to determine
the message body. You can change this by setting @code{mu4e-view-prefer-html}.
Note: if you have installed the
@t{filladapt}@footnote{@url{http://www.wonderworks.com/download/filladapt.el}}
package, @t{mu4e} will use it for line-wrapping of the body text (@key{w}), as
it generally does a better job than the mechanism emacs provides by default.
@node Editor view
@section Editor view
@ -762,7 +766,7 @@ If you have queries that you use often, you may want to store them as
invoke them in other places as well. Bookmark searches are available in the
main view @ref{Main view}, header view @xref{Headers view}, and message view
@xref{Message view}, using (by default) the key @key{b}
(@code{mu4e-search-bookmark}).
(@code{mu4e-search-bookmark}).
@code{mu4e} provides some default bookmarks, which you can override. The