From c9e8196eb61bd9cbd112017340cb018274bf2d6a Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Wed, 6 Nov 2019 16:20:46 -0500 Subject: [PATCH] Add proper justification to epub in #emacs --- emacs/.config/doom/+nov.el | 28 ++++++++++++++++++++++++++++ emacs/.config/doom/config.el | 6 +++--- emacs/.config/doom/packages.el | 4 ++++ 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 emacs/.config/doom/+nov.el diff --git a/emacs/.config/doom/+nov.el b/emacs/.config/doom/+nov.el new file mode 100644 index 0000000..57286f7 --- /dev/null +++ b/emacs/.config/doom/+nov.el @@ -0,0 +1,28 @@ +;;; ~/.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) diff --git a/emacs/.config/doom/config.el b/emacs/.config/doom/config.el index 3ed2560..e5ae08a 100644 --- a/emacs/.config/doom/config.el +++ b/emacs/.config/doom/config.el @@ -15,7 +15,6 @@ (if (display-graphic-p) (setq doom-theme 'doom-peacock)) - ;; Fonts (setq doom-font (font-spec :family "IBM Plex Mono" :size 14)) (setq doom-big-font (font-spec :family "IBM Plex Mono" :size 21)) @@ -170,12 +169,13 @@ (add-to-list 'auto-mode-alist '("\\.plantuml\\'" . planetuml-mode)) (load! "+ui.el") -(load! "+org") ;; Org mode stuff like todos and rebindings +(load! "+org") ;; Org mode stuff like todos and rebindings (load! "+org-cal") ;(load! "+elfeed") +(load! "+nov") ;; nov.el epub mode settings (load! "+mail") ;; Mail stuff (load! "+ranger") -(load! "+wttrin") ;; Weather config +(load! "+wttrin") ;; Weather config (defun mpdel-playlist-play () "Start playing the song at point." diff --git a/emacs/.config/doom/packages.el b/emacs/.config/doom/packages.el index ef5f15d..b78ae5d 100644 --- a/emacs/.config/doom/packages.el +++ b/emacs/.config/doom/packages.el @@ -16,6 +16,10 @@ :recipe (:host github :repo "redguardtoo/evil-matchit")) +(package! justify-kp + :recipe (:host github + :repo "Fuco1/justify-kp")) + ;; eglot instead of lsp (package! eglot)