Extract shr-add-font redef with additional explanation

This commit is contained in:
Jeremy Dormitzer 2020-04-21 17:06:10 -04:00
parent 249f51baa7
commit 0254d0134e

View File

@ -3735,21 +3735,7 @@ Then configure it:
(let* ((msg (mu4e-message-at-point t)))
(if (not msg)
(error "No message at point")
(cdar (mu4e-message-field msg :from))))))))
;; Ugly hack to make sure that shr faces end up at the beginning of the face list
(defun shr-add-font (start end type)
(save-excursion
(goto-char start)
(while (< (point) end)
(when (bolp)
(skip-chars-forward " "))
;; Remove the APPEND argument to add-face-text-property
;; so the face ends up at the head of the face list
(add-face-text-property (point) (min (line-end-position) end) type)
(if (< (line-end-position) end)
(forward-line 1)
(goto-char end))))))
(cdar (mu4e-message-field msg :from)))))))))
#+end_src
Global keybindings:
@ -3764,6 +3750,26 @@ Keybindings within mu4e:
(general-def '(normal motion insert emacs) mu4e-view-mode-map "t" #'mu4e-view-mark-thread))
#+end_src
Mu4e uses shr to render HTML emails. Unfortunately the shr function
that sets faces in the rendered document has a bug: it appends the shr
faces to the existing face-list, rather than prepending the shr
face. This means that e.g. links don't actually get rendered correctly
if there is some non-link face already on the text. The fix:
#+BEGIN_SRC emacs-lisp
(defun shr-add-font (start end type)
(save-excursion
(goto-char start)
(while (< (point) end)
(when (bolp)
(skip-chars-forward " "))
;; Remove the APPEND argument to add-face-text-property
;; so the face ends up at the head of the face list
(add-face-text-property (point) (min (line-end-position) end) type)
(if (< (line-end-position) end)
(forward-line 1)
(goto-char end)))))
#+END_SRC
* w3m
Browsing the web from Emacs. Relies on having [[http://w3m.sourceforge.net/][w3m]] installed.
#+BEGIN_SRC emacs-lisp