aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasilij Schneidermann <mail@vasilij.de>2017-09-19 17:32:10 +0200
committerVasilij Schneidermann <mail@vasilij.de>2017-09-19 17:38:54 +0200
commit6e29ee309c7f323a446034ea4fefb400b16199e3 (patch)
tree4a0cf7433c7f5ef3999355844d4b98b2d55d04f7
parent81d32c35466b6f70921c477718c5b97a694d00b4 (diff)
Add justify-kp example to README
-rw-r--r--README.rst33
1 files changed, 32 insertions, 1 deletions
diff --git a/README.rst b/README.rst
index 8e55494..e82c121 100644
--- a/README.rst
+++ b/README.rst
@@ -64,7 +64,7 @@ file:
.. code:: elisp
(defun my-nov-font-setup ()
- (face-remap-add-relative 'variable-pitch :family "Liberation Serif"))
+ (face-remap-add-relative 'variable-pitch :font "Liberation Serif-14"))
(add-hook 'nov-mode-hook 'my-nov-font-setup)
To completely disable the variable pitch font, customize
@@ -102,6 +102,37 @@ function by customizing ``nov-render-html-function`` to one that
replaces HTML in a buffer with something nicer than the default
output.
+Here's an advanced example of text justification with the `justify-kp
+<https://github.com/Fuco1/justify-kp>`_ package:
+
+.. code:: elisp
+
+ (setq nov-text-width most-positive-fixnum)
+
+ (defun my-nov-window-configuration-change-hook ()
+ (my-nov-post-html-render-hook)
+ (remove-hook 'window-configuration-change-hook
+ 'my-nov-window-configuration-change-hook
+ t))
+
+ (defun my-nov-post-html-render-hook ()
+ (if (get-buffer-window)
+ (let ((max-width (pj-line-width))
+ buffer-read-only)
+ (save-excursion
+ (goto-char (point-min))
+ (while (not (eobp))
+ (goto-char (line-end-position))
+ (when (> (shr-pixel-column) max-width)
+ (goto-char (line-beginning-position))
+ (pj-justify))
+ (forward-line 1))))
+ (add-hook 'window-configuration-change-hook
+ 'my-nov-window-configuration-change-hook
+ nil t)))
+
+ (add-hook 'nov-post-html-render-hook 'my-nov-post-html-render-hook)
+
Usage
-----