wasamasa / nov.el, Hacker News

wasamasa / nov.el, Hacker News



nov.elprovides a major mode for reading EPUB documents.


  • Basic navigation ( jump to TOC, previous / next chapter)
  • Remembering and restoring the last read position
  • Jump to next chapter when scrolling beyond end
  • Renders EPUB2 (.ncx) and EPUB3 (
  • Hyperlinks to internal and external targets
  • Supports textual and image documents
  • View source of document files
  • Metadata display
  • Image rescaling



Set up theMELPAorMELPA Stablerepository if you haven’t already and install withMx package-install RET nov RET.


Make sure you have anunzipexecutable onPATH, otherwise the extraction of EPUB files will fail. If you for some reason haveunzipin a non-standard location , customizenov-unzip-programto its path. You’ll also need an Emacs compiled withlibxml2support, otherwise rendering will fail.

Put the following in your init file:

(add-to-list'auto-mode-alist'' ("\. epub\''"nov -mode))


While the defaults make for an acceptable reading experience, it can be improved with any of the following changes:

Default font

To change the default font, useM-x customize-face RET variable-pitch, pick a different family, save and apply. If you dislike globally customizing that face, add the following to your init file:

(Defun(my-nov-font-setup)  ()   (face-remap-add-relative'variable-pitch: Family""Liberation Serif"                                           : height(1.0) )) (add-hook'nov-mode-hook'my-nov-font-setup)

To completely disable the variable pitch font, customizenov-variable-pitch (to) nil. Text will be displayed with the default face instead which should be using a monospace font.

Text width

By default text is filled by the window width. You can customizenov-text-widthto a number of columns to change that:

It’s also possible to set it totto inhibit text filling, this can be used in combination withvisual-line-modeand packages such asvisual-fill-columnto implement more flexible filling:

( (setq)  nov-text-widtht) (setqvisual-fill-column-center-textT) (add-hook'nov-mode-hook'visual-line-mode) (add-hook'nov-mode-hook'visual-fill-column-mode)


In case you’re not happy with the rendering at all, you can either usenov-pre-html-render-hookandnov-post-html-render-hookto adjust the HTML before and after rendering or use your own rendering function by customizingnov-render-html-functionto one that replaces HTML in a buffer with something nicer than the default output.

Here’s an advanced example of text justification with thejustify-kppackage:

(require'justify-kp) (setqnov-text-width  (T) )  (defunmy-nov-window-configuration-change-hook()   (my-nov-post-html-render-hook)   (remove-hook'window-configuration-change-hook               'my-nov-window-configuration-change- hook               t))  (defunmy-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)

This customization yields the following look:


Open the EPUB file withCx Cf ~ / novels / novel.epub, scroll withSPCand switch chapters with (n) andp. More keybinds can be looked up withF1 m.




The first one I’ve heard of isepubmode.elwhich is, well, see for yourself. You might findereadermore useful, especially if you’re after Org integration and annotation support.

  Brave Browser
Read More

What do you think?

Leave a Reply

Your email address will not be published.

GIPHY App Key not set. Please check settings

The Acceleration of Addictiveness (2010), Hacker News

How sleep helps brain to function – The Asian Age,

How sleep helps brain to function – The Asian Age,