summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2014-05-11 17:43:43 +0200
committerGravatar Tom Willemse2014-05-11 17:43:43 +0200
commit1ddb5dc327e9203f7d889fb0605e455dc075749e (patch)
tree6fabd32e6be5002658f652e8d613333d169f60aa
parent6c3e99fbc14697f4ea4180f59007f73e7af0baf4 (diff)
downloademacs-1ddb5dc327e9203f7d889fb0605e455dc075749e.tar.gz
emacs-1ddb5dc327e9203f7d889fb0605e455dc075749e.zip
Teach eww about <code>
-rw-r--r--.emacs.d/init.org30
1 files changed, 30 insertions, 0 deletions
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 <code> tags
+
+ Strangely enough, ~eww~ doesn't seem to be aware of =<code>= HTML tags.
+ Luckily it's trivial to teach it. It does know about =<pre>= HTML
+ tags, and basically I just want =<code>= tags to be treated almost as
+ =<pre>= 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 =<code>= 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