Emacs: Novel Reading Mode

Buy Xah Emacs Tutorial. Master emacs benefits for life.

Here's a command that make current window suitable for reading long text.

emacs novel reading mode screen1 2014-06-03
emacs novel reading mode screen2 2014-06-03

here's the code:

(defun xah-toggle-read-novel-mode ()
  "Setup current window to be suitable for reading long novel/article text.

• Line wrap at word boundaries. 
• Set a right margin.
• line spacing is increased.
• variable width font is used.

Call again to toggle back."
  (if (null (get this-command 'state-on-p))
        (set-window-margins nil 0 
                            (if (> fill-column (window-body-width))
                                (- (window-body-width) fill-column))))
        (variable-pitch-mode 1)
        (setq line-spacing 0.4)
        (setq word-wrap t)
        (put this-command 'state-on-p t))
      (set-window-margins nil 0 0)
      (variable-pitch-mode 0)
      (setq line-spacing nil)
      (setq word-wrap nil)
      (put this-command 'state-on-p nil)))
  (redraw-frame (selected-frame)))
Like it?
Buy Xah Emacs Tutorial
or share
blog comments powered by Disqus