* mu4e: add `mu4e-view-prefer-html' (with obvious meaning), and document it.
This commit is contained in:
@ -188,15 +188,21 @@ complete list of available headers, see `mu4e-header-names'."
|
|||||||
:type 'string
|
:type 'string
|
||||||
:group 'mu4e-view)
|
:group 'mu4e-view)
|
||||||
|
|
||||||
|
(defcustom mu4e-view-prefer-html nil
|
||||||
|
"Whether to base the body display on the HTML-version of the
|
||||||
|
e-mail message (if there is any."
|
||||||
|
:type 'boolean
|
||||||
|
:group 'mu4e-view)
|
||||||
|
|
||||||
(defcustom mu4e-html2text-command nil
|
(defcustom mu4e-html2text-command nil
|
||||||
"Shel command that converts HTML from stdin into plain text on
|
"Shel command that converts HTML from stdin into plain text on
|
||||||
stdout. If this is not defined, the emacs `html2text' tool will be
|
stdout. If this is not defined, the emacs `html2text' tool will be
|
||||||
used when faced with html-only message."
|
used when faced with html-only message. If you use htmltext, it's
|
||||||
|
recommended you use \"html2text -utf8 -width 72\"."
|
||||||
:type 'string
|
:type 'string
|
||||||
:group 'mu4e-view
|
:group 'mu4e-view
|
||||||
:safe 'stringp)
|
:safe 'stringp)
|
||||||
|
|
||||||
|
|
||||||
;; Composing / Sending messages
|
;; Composing / Sending messages
|
||||||
(defgroup mu4e-compose nil
|
(defgroup mu4e-compose nil
|
||||||
"Customizations for composing/sending messages."
|
"Customizations for composing/sending messages."
|
||||||
@ -438,7 +444,8 @@ maildirs under `mu4e-maildir."
|
|||||||
(lambda (item)
|
(lambda (item)
|
||||||
(concat
|
(concat
|
||||||
"["
|
"["
|
||||||
(propertize (make-string 1 (cdr item)) 'face 'mu4e-view-link-face)
|
(propertize (make-string 1 (cdr item))
|
||||||
|
'face 'mu4e-view-link-face)
|
||||||
"]"
|
"]"
|
||||||
(car item)))
|
(car item)))
|
||||||
mlist ", "))
|
mlist ", "))
|
||||||
@ -463,7 +470,9 @@ maildirs under `mu4e-maildir."
|
|||||||
(lambda (bm)
|
(lambda (bm)
|
||||||
(let ((query (nth 0 bm)) (title (nth 1 bm)) (key (nth 2 bm)))
|
(let ((query (nth 0 bm)) (title (nth 1 bm)) (key (nth 2 bm)))
|
||||||
(concat
|
(concat
|
||||||
"[" (propertize (make-string 1 key) 'face 'mu4e-view-link-face) "]"
|
"[" (propertize (make-string 1 key)
|
||||||
|
'face 'mu4e-view-link-face)
|
||||||
|
"]"
|
||||||
title))) mu4e-bookmarks ", "))
|
title))) mu4e-bookmarks ", "))
|
||||||
(kar (read-char (concat prompt bmarks))))
|
(kar (read-char (concat prompt bmarks))))
|
||||||
(mu4e-get-bookmark-query kar)))
|
(mu4e-get-bookmark-query kar)))
|
||||||
@ -559,36 +568,41 @@ Also see `mu/flags-to-string'.
|
|||||||
((and (>= size 1000) (< size 1000000))
|
((and (>= size 1000) (< size 1000000))
|
||||||
(format "%2.1fK" (/ size 1000.0)))
|
(format "%2.1fK" (/ size 1000.0)))
|
||||||
((< size 1000) (format "%d" size))
|
((< size 1000) (format "%d" size))
|
||||||
(t "<unknown>")))
|
(t (propertize "?" 'face 'mu4e-system-face))))
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e-body-text (msg)
|
(defun mu4e-body-text (msg)
|
||||||
"Get the body in text form for this message, which is either :body-txt,
|
"Get the body in text form for this message, which is either :body-txt,
|
||||||
or if not available, :body-html converted to text. By default, it
|
or if not available, :body-html converted to text. By default, it
|
||||||
uses the emacs built-in `html2text'. Alternatively, if
|
uses the emacs built-in `html2text'. Alternatively, if
|
||||||
`mu4e-html2text-command' is non-nil, it will use that."
|
`mu4e-html2text-command' is non-nil, it will use that. Normally,
|
||||||
|
function prefers the text part, but this can be changed by setting
|
||||||
|
`mu4e-view-prefer-html'."
|
||||||
(let* ((txt (plist-get msg :body-txt))
|
(let* ((txt (plist-get msg :body-txt))
|
||||||
(html (plist-get msg :body-html))
|
(html (plist-get msg :body-html))
|
||||||
;; get the html body if there is no text, or if the text body is super
|
(body))
|
||||||
;; short compared to the html one -- ie., it's probably just some lame 'this
|
;; is there an appropriate text body?
|
||||||
;; message requires html' message
|
(when (and txt
|
||||||
(body (if (not html)
|
(not (and mu4e-view-prefer-html html))
|
||||||
(if (not txt) "" txt)
|
(> (* 10 (length txt))
|
||||||
;; there's an html part
|
(if html (length html) 0))) ;; real text part?
|
||||||
(if (or (not txt) (< (* 10 (length txt)) (length html)))
|
(setq body txt))
|
||||||
;; there's no text part, or it's very small
|
;; no body yet? try html
|
||||||
(with-temp-buffer
|
(unless body
|
||||||
(insert html)
|
(when html
|
||||||
;; if defined, use the external tool
|
(setq body
|
||||||
(if mu4e-html2text-command
|
(with-temp-buffer
|
||||||
(shell-command-on-region (point-min) (point-max)
|
(insert html)
|
||||||
mu4e-html2text-command
|
;; if defined, use the external tool
|
||||||
nil t)
|
(if mu4e-html2text-command
|
||||||
;; otherwise...
|
(shell-command-on-region (point-min) (point-max)
|
||||||
(html2text))
|
mu4e-html2text-command nil t)
|
||||||
(buffer-string))
|
;; otherwise...
|
||||||
;; there's a normal sized text part
|
(html2text))
|
||||||
txt))))
|
(buffer-string)))))
|
||||||
|
;; still no body?
|
||||||
|
(unless body
|
||||||
|
(setq body (propertize "No body" 'face 'mu4e-system-face)))
|
||||||
;; and finally, remove some crap from the remaining string.
|
;; and finally, remove some crap from the remaining string.
|
||||||
(replace-regexp-in-string "[
|
(replace-regexp-in-string "[
|
||||||
]" " " body nil nil nil)))
|
]" " " body nil nil nil)))
|
||||||
|
|||||||
@ -426,7 +426,7 @@ This looks something like the following:
|
|||||||
|
|
||||||
|
|
||||||
@verbatim
|
@verbatim
|
||||||
------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------
|
||||||
Date Flgs From/To Subject
|
Date Flgs From/To Subject
|
||||||
2011-12-16 18:38 uN To Edmund Dantès + Re: Extension security?
|
2011-12-16 18:38 uN To Edmund Dantès + Re: Extension security?
|
||||||
2011-12-16 21:44 uN Abbé Busoni + Re: Extension security?
|
2011-12-16 21:44 uN Abbé Busoni + Re: Extension security?
|
||||||
@ -434,11 +434,11 @@ This looks something like the following:
|
|||||||
2011-12-17 04:04 uN Jacopo + Re: Extension security?
|
2011-12-17 04:04 uN Jacopo + Re: Extension security?
|
||||||
2011-12-17 14:36 uN Mercédès + Re: Extension security?
|
2011-12-17 14:36 uN Mercédès + Re: Extension security?
|
||||||
2011-12-18 06:05 uN Beachamp \ Re: Extension security?
|
2011-12-18 06:05 uN Beachamp \ Re: Extension security?
|
||||||
2011-12-16 18:23 uN Eric Schulte + Re: [O] A presentation tool for org-mode
|
2011-12-16 18:23 uN Albert de Moncerf + Re: [O] A presentation tool
|
||||||
2011-12-17 01:53 usaN Gaspard Caderousse \ Re: [O] A presentation tool for org-mode
|
2011-12-17 01:53 usaN Gaspard Caderousse \ Re: [O] A presentation tool
|
||||||
2011-12-16 16:31 uN Baron Danglars | [O] imaxima?
|
2011-12-16 16:31 uN Baron Danglars | [O] imaxima?
|
||||||
End of search results
|
End of search results
|
||||||
------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------
|
||||||
@end verbatim
|
@end verbatim
|
||||||
|
|
||||||
It should be fairly obvious what this means, but some notes:
|
It should be fairly obvious what this means, but some notes:
|
||||||
@ -565,16 +565,25 @@ q@t{open} program. If you want to use another program, you specify this by
|
|||||||
setting the @t{MU_PLAY_PROGRAM} environment variable.
|
setting the @t{MU_PLAY_PROGRAM} environment variable.
|
||||||
|
|
||||||
For displaying messages, @t{mu4e} normally prefers the plain-text version for
|
For displaying messages, @t{mu4e} normally prefers the plain-text version for
|
||||||
messages consisting of both a plain-text and an html (rich-text_ version of
|
messages consisting of both a plain-text and an html (rich-text) version of
|
||||||
its body-text. If there is only an html-version, or if the plaint-text version
|
its body-text. If there is only an html-version, or if the plaint-text version
|
||||||
is too short in comparison with the html part, @t{mu4e} tries to convert the
|
is too short in comparison with the html part, @t{mu4e} tries to convert the
|
||||||
html into plain-text for display. The default way to do that is to use the
|
html into plain-text for display. The default way to do that is to use the
|
||||||
Emacs built-in @code{html2text} function, but if you set the variable
|
Emacs built-in @code{html2text} function, but if you set the variable
|
||||||
@code{mu4e-html2text-command} to some external program, that will be
|
@code{mu4e-html2text-command} to some external program, that program will be
|
||||||
used. This program is expected to take html from standard input and write
|
used. This program is expected to take html from standard input and write
|
||||||
plain text on standard output. An obvious choice for this is the program that
|
plain text in @t{utf-8} encoding on standard output.
|
||||||
is actually called
|
|
||||||
@t{html2text}@footnote{@url{http://www.mbayer.de/html2text/}}.
|
An obvious choice for this is the program that is actually @emph{called}
|
||||||
|
@t{html2text}@footnote{@url{http://www.mbayer.de/html2text/}}, which you could
|
||||||
|
set up with something like the following in your initialization files:
|
||||||
|
|
||||||
|
@lisp
|
||||||
|
(setq mu4e-html2text-command "html2text -utf8 -width 72")
|
||||||
|
@end lisp
|
||||||
|
|
||||||
|
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}.
|
||||||
|
|
||||||
@node Editor view
|
@node Editor view
|
||||||
@section Editor view
|
@section Editor view
|
||||||
|
|||||||
Reference in New Issue
Block a user