aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasilij Schneidermann <mail@vasilij.de>2019-08-21 21:19:44 +0200
committerVasilij Schneidermann <mail@vasilij.de>2019-08-21 21:20:33 +0200
commitecbdecc927a3b3f7e0927d225e6e6464c244c2ae (patch)
treec29474f70de61117938999069602a81e6b7ee94d
parent5184fbb1f3b3540be58a28f6dd469ff212ccc9bd (diff)
Support not filling text at all
Closes #57
-rw-r--r--README.rst10
-rw-r--r--nov.el16
2 files changed, 15 insertions, 11 deletions
diff --git a/README.rst b/README.rst
index 982bd29..20331da 100644
--- a/README.rst
+++ b/README.rst
@@ -82,13 +82,13 @@ By default text is filled by the window width. You can customize
(setq nov-text-width 80)
-It's also possible to set it to a huge number to inhibit text filling,
-this can be used in combination with ``visual-line-mode`` and packages
-such as ``visual-fill-column`` to implement more flexible filling:
+It's also possible to set it to ``t`` to inhibit text filling, this
+can be used in combination with ``visual-line-mode`` and packages such
+as ``visual-fill-column`` to implement more flexible filling:
.. code:: elisp
- (setq nov-text-width most-positive-fixnum)
+ (setq nov-text-width t)
(setq visual-fill-column-center-text t)
(add-hook 'nov-mode-hook 'visual-line-mode)
(add-hook 'nov-mode-hook 'visual-fill-column-mode)
@@ -109,7 +109,7 @@ Here's an advanced example of text justification with the `justify-kp
.. code:: elisp
(require 'justify-kp)
- (setq nov-text-width most-positive-fixnum)
+ (setq nov-text-width t)
(defun my-nov-window-configuration-change-hook ()
(my-nov-post-html-render-hook)
diff --git a/nov.el b/nov.el
index d55f5a5..7389607 100644
--- a/nov.el
+++ b/nov.el
@@ -71,10 +71,11 @@ Otherwise the default face is used."
(defcustom nov-text-width nil
"Width filled text shall occupy.
An integer is interpreted as the number of columns. If nil, use
-the full window's width. Note that this variable only has an
-effect in Emacs 25.1 or greater."
+the full window's width. If t, disable filling completely. Note
+that this variable only has an effect in Emacs 25.1 or greater."
:type '(choice (integer :tag "Fixed width in characters")
- (const :tag "Use the width of the window" nil))
+ (const :tag "Use the width of the window" nil)
+ (const :tag "Disable filling" t))
:group 'nov)
(defcustom nov-render-html-function 'nov-render-html
@@ -489,12 +490,15 @@ chapter title."
(let (;; HACK: make buttons use our own commands
(shr-map nov-mode-map)
(shr-external-rendering-functions nov-shr-rendering-functions)
- (shr-use-fonts nov-variable-pitch)
- (shr-width nov-text-width))
+ (shr-use-fonts nov-variable-pitch))
;; HACK: `shr-external-rendering-functions' doesn't cover
;; every usage of `shr-tag-img'
(cl-letf (((symbol-function 'shr-tag-img) 'nov-render-img))
- (shr-render-region (point-min) (point-max))))
+ (if (eq nov-text-width t)
+ (cl-letf (((symbol-function 'shr-fill-line) 'ignore))
+ (shr-render-region (point-min) (point-max)))
+ (let ((shr-width nov-text-width))
+ (shr-render-region (point-min) (point-max))))))
(run-hooks 'nov-post-html-render-hook))
(defun nov-render-document ()