From 1ddb5dc327e9203f7d889fb0605e455dc075749e Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sun, 11 May 2014 17:43:43 +0200 Subject: Teach eww about --- .emacs.d/init.org | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to '.emacs.d/init.org') diff --git a/.emacs.d/init.org b/.emacs.d/init.org index b025d77..f14f931 100644 --- a/.emacs.d/init.org +++ b/.emacs.d/init.org @@ -790,6 +790,36 @@ (add-hook 'js2-init-hook #'oni:js2-add-conkeror-symbols) #+END_SRC +* Teach eww about tags + + Strangely enough, ~eww~ doesn't seem to be aware of == HTML tags. + Luckily it's trivial to teach it. It does know about =
= HTML
+  tags, and basically I just want == tags to be treated almost as
+  =
= tags, so to do that we just have to define a =shr-tag-code=
+  function. I've copied the =shr-tag-pre= function and removed the calls
+  to =ensure-newline=, because == tags are inline tags.
+
+  In order to remain a little future-proof, it should only be done if
+  it doesn't already exist.
+
+  *Note:* See my [[Vacuous defvar][note]] on vacuous defvar for this use of =defvar=.
+
+  *Note:* See my [[Function declarations][note]] on function declarations about the use of
+  =declare-function=.
+
+  #+BEGIN_SRC emacs-lisp
+    (defvar shr-folding-mode)
+    (declare-function shr-indent "shr")
+    (declare-function shr-generic "shr")
+
+    (with-eval-after-load 'shr
+      (unless (fboundp 'shr-tag-code)
+        (defun shr-tag-code (cont)
+          (let ((shr-folding-mode 'none))
+            (shr-indent)
+            (shr-generic cont)))))
+  #+END_SRC
+
 * Load custom file
 
   I don't really use the Emacs customization interface much, but I
-- 
cgit v1.2.3-54-g00ecf