From 6e29ee309c7f323a446034ea4fefb400b16199e3 Mon Sep 17 00:00:00 2001 From: Vasilij Schneidermann Date: Tue, 19 Sep 2017 17:32:10 +0200 Subject: Add justify-kp example to README --- README.rst | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) 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 +`_ 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 ----- -- cgit v1.2.3