branch: externals/olivetti
commit 4bec5f243fe88703fe6c3f3d062afb1899c2033f
Author: Paul Rankin <[email protected]>
Commit: Paul Rankin <[email protected]>
Added expand/shrink interactive funs
---
olivetti.el | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/olivetti.el b/olivetti.el
index 5ebdda4..f80f0bc 100644
--- a/olivetti.el
+++ b/olivetti.el
@@ -182,7 +182,27 @@ Toggles the value of `olivetti-hide-mode-line' and runs
(interactive)
(olivetti-set-mode-line 'toggle))
-;; Mode Definition
=============================================================
+(defun olivetti-expand (&optional arg)
+ "Incrementally increase the value of `olivetti-body-width'.
+If prefixed with ARG, incrementally decrease."
+ (interactive "P")
+ (let* ((p (if arg -1 1))
+ (n (cond ((integerp olivetti-body-width)
+ (+ olivetti-body-width (* 2 p)))
+ ((floatp olivetti-body-width)
+ (+ olivetti-body-width (* 0.01 p))))))
+ (setq olivetti-body-width (olivetti-safe-width n)))
+ (olivetti-set-environment)
+ (message "Text body width set to %s" olivetti-body-width))
+
+(defun olivetti-shrink (&optional arg)
+ "incrementally decrease the value of `olivetti-body-width'.
+If prefixed with ARG, incrementally increase."
+ (interactive "P")
+ (let ((p (unless arg t)))
+ (olivetti-expand p)))
+
+;; Mode Definition =====================================================
;;;###autoload
(defun turn-on-olivetti-mode ()