From 0254d0134e4c16df1b38862d0c294d37bcdc295e Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Tue, 21 Apr 2020 17:06:10 -0400 Subject: [PATCH] Extract shr-add-font redef with additional explanation --- emacs/init.org | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/emacs/init.org b/emacs/init.org index 775f669..e30e913 100755 --- a/emacs/init.org +++ b/emacs/init.org @@ -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