mirror of https://github.com/djcb/mu.git
mu4e: update html/URL handling
Make mu4e-view-toggle-html _not_ toggle the global value of of mu4e-view-prefer-html, but only the current one. Make the link map 'permanent', so it survives the buffer changes when refreshing. This fixes issue #904.
This commit is contained in:
parent
75412ec3b1
commit
49ea3bec58
|
@ -158,12 +158,16 @@ This is equivalent to:
|
|||
(mu4e-message-field (mu4e-message-at-point) FIELD)."
|
||||
(mu4e-message-field (mu4e-message-at-point) field))
|
||||
|
||||
(defun mu4e-message-body-text (msg)
|
||||
(defvar mu4e~message-body-html nil
|
||||
"Whether the body text uses HTML.")
|
||||
|
||||
(defun mu4e-message-body-text (msg &optional prefer-html)
|
||||
"Get the body in text form for this message.
|
||||
This is either :body-txt, or if not available, :body-html converted
|
||||
to text, using `mu4e-html2text-command' is non-nil, it will use
|
||||
that. Normally, thiss function prefers the text part, but this can
|
||||
be changed by setting `mu4e-view-prefer-html'."
|
||||
This is either :body-txt, or if not available, :body-html
|
||||
converted to text, using `mu4e-html2text-command' is non-nil, it
|
||||
will use that. Normally, this function prefers the text part,
|
||||
unless PREFER-HTML is non-nil."
|
||||
(setq mu4e~message-body-html nil) ;; default
|
||||
(let* ((txt (mu4e-message-field msg :body-txt))
|
||||
(html (mu4e-message-field msg :body-html))
|
||||
(body
|
||||
|
@ -176,7 +180,7 @@ be changed by setting `mu4e-view-prefer-html'."
|
|||
((and (> (* mu4e-view-html-plaintext-ratio-heuristic
|
||||
(length txt)) (length html))
|
||||
;; use html if it's prefered, unless there is no html
|
||||
(or (not mu4e-view-prefer-html) (not html)))
|
||||
(or (not prefer-html) (not html)))
|
||||
txt)
|
||||
;; otherwise, it there some html?
|
||||
(html
|
||||
|
@ -192,6 +196,7 @@ be changed by setting `mu4e-view-prefer-html'."
|
|||
((functionp mu4e-html2text-command)
|
||||
(funcall mu4e-html2text-command))
|
||||
(t (mu4e-error "Invalid `mu4e-html2text-command'")))
|
||||
(setq mu4e~message-body-html t)
|
||||
(buffer-string))
|
||||
)
|
||||
(t ;; otherwise, an empty body
|
||||
|
|
|
@ -247,7 +247,7 @@ found."
|
|||
(mu4e~view-custom-field msg field))))))
|
||||
mu4e-view-fields "")
|
||||
"\n"
|
||||
(let ((body (mu4e-message-body-text msg)))
|
||||
(let ((body (mu4e-message-body-text msg mu4e-view-prefer-html)))
|
||||
(when (fboundp 'add-face-text-property)
|
||||
(add-face-text-property 0 (length body) 'mu4e-view-body-face t body))
|
||||
body)))
|
||||
|
@ -747,6 +747,10 @@ FUNC should be a function taking two arguments:
|
|||
(make-local-variable 'mu4e~view-attach-map)
|
||||
(make-local-variable 'mu4e~view-cited-hidden)
|
||||
|
||||
;; make permanent too, so they'll survive changing the mode
|
||||
(put 'mu4e~view-link-map 'permanent-local t)
|
||||
(put 'mu4e~view-attach-map 'permanent-local t)
|
||||
|
||||
;; show context in mode-string
|
||||
(set (make-local-variable 'global-mode-string) '(:eval (mu4e-context-label)))
|
||||
|
||||
|
@ -932,8 +936,8 @@ the new docid. Otherwise, return nil."
|
|||
(defun mu4e-view-toggle-html ()
|
||||
"Toggle html-display of the message body (if any)."
|
||||
(interactive)
|
||||
(setq mu4e-view-prefer-html (not mu4e-view-prefer-html))
|
||||
(mu4e-view-refresh))
|
||||
(let ((mu4e-view-prefer-html (not mu4e~message-body-html)))
|
||||
(mu4e-view-refresh)))
|
||||
|
||||
(defun mu4e-view-refresh ()
|
||||
"Redisplay the current message."
|
||||
|
|
Loading…
Reference in New Issue