Files
dotfiles/emacs/.config/doom/+nov.el
2019-11-12 11:42:09 -05:00

30 lines
1.0 KiB
EmacsLisp

;;; ~/.dotfiles/emacs/.config/doom/+nov.el -*- lexical-binding: t; -*-
(require 'justify-kp)
(setq nov-text-width t)
(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))
(when (not (looking-at "^[[:space:]]*$"))
(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)
(add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))