[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/olivetti 6533514 002/134: Added a bunch of custom optio
From: |
Stefan Monnier |
Subject: |
[elpa] externals/olivetti 6533514 002/134: Added a bunch of custom options, allow body-width float |
Date: |
Thu, 25 Apr 2019 09:57:13 -0400 (EDT) |
branch: externals/olivetti
commit 6533514116ab5f7232ea238dc6bfd0fc32b46c5c
Author: Paul Rankin <address@hidden>
Commit: Paul Rankin <address@hidden>
Added a bunch of custom options, allow body-width float
---
olivetti.el | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 67 insertions(+), 13 deletions(-)
diff --git a/olivetti.el b/olivetti.el
index 431cba3..28184af 100644
--- a/olivetti.el
+++ b/olivetti.el
@@ -31,23 +31,67 @@
:group 'fountain
:group 'markdown)
+(defcustom olivetti-mode-hook
+ '(turn-on-visual-line-mode)
+ "Mode hook for `olivetti-mode', run after mode is turned on."
+ :type 'hook
+ :group 'olivetti)
+
(defcustom olivetti-body-width 66
- "Text body width in columns to which to adjust margin width.
+ "Text body width to which to adjust relative margin width.
+
+If an integer, set text body width to that integer in columns; if
+a floating point between 0.0 and 1.0, set text body width to
+that fraction of the total window width.
+
+An integer is best if you want text body width to remain
+constant, while a floating point is best if you want text body
+width to change with window width.
-Does not affect file contents."
- :type 'integer
+The floating point can anything between 0.0 and 1.0 (exclusive),
+but it's better to use a value between about 0.33 and 0.9 for
+best effect.
+
+This option does not affect file contents."
+ :type '(choice (integer 66) (float 0.5))
+ :group 'olivetti)
+
+(defcustom olivetti-hide-tool-bar t
+ "Turn off `tool-bar-mode'."
+ :type 'boolean
:group 'olivetti)
(defcustom olivetti-hide-mode-line t
- "Hide the mode line."
+ "Hide the mode line.
+Can cause display issues in console mode."
:type 'boolean
:group 'olivetti)
-(defun olivetti-set-window-margins ()
- "Set window-body-width to `olivetti-body-width' with relative margins."
- (let ((margin
- (/ (- (window-total-width) olivetti-body-width) 2)))
- (set-window-margins (selected-window) margin margin)))
+(defcustom olivetti-hide-fringes t
+ "Hide fringes."
+ :type 'boolean
+ :group 'olivetti)
+
+(defcustom olivetti-delete-selection t
+ "Turn on `delete-selection-mode'."
+ :type 'boolean
+ :group 'olivetti)
+
+(defun olivetti-set-environment ()
+ "Set text body width to `olivetti-body-width' with relative margins."
+ (let* ((n olivetti-body-width)
+ (width
+ (cond ((integerp n) n)
+ ((and (floatp n)
+ (< n 1)
+ (> n 0))
+ (* (window-total-width) n))
+ ((error "`olivetti-body-width' must be an integer or a
floating point between 0.0 and 1.0"))))
+ (margin
+ (round (/ (- (window-total-width) width) 2))))
+ (set-window-margins (selected-window) margin margin))
+ (when olivetti-hide-fringes
+ (set-window-fringes (selected-window) 0 0 t)))
;; (easy-menu-define olivetti-mode-menu olivetti-mode-map
;; "Menu for Olivetti Mode."
@@ -68,20 +112,30 @@ Does not affect file contents."
;;;###autoload
(define-minor-mode olivetti-mode
- ""
+ "Olivetti provides a nice writing environment.
+
+Window margins are set to relative widths to accomodate a text
+body width in columns of `olivetti-body-width', an integer.
+
+When `olivetti-hide-mode-line' is non-nil, the mode line is also
+hidden."
:init-value nil
:lighter " Olv"
(if olivetti-mode
(progn
(setq-local scroll-conservatively 101)
+ (when olivetti-hide-tool-bar
+ (tool-bar-mode 0))
(when olivetti-hide-mode-line
(setq-local mode-line-format nil))
+ (when olivetti-delete-selection
+ (delete-selection-mode 1))
(add-hook 'window-configuration-change-hook
- 'olivetti-set-window-margins nil t)
- (run-hook-with-args 'window-configuration-change-hook))
+ 'olivetti-set-environment nil t)
+ (run-hooks 'window-configuration-change-hook))
(kill-local-variable 'mode-line-format)
(remove-hook 'window-configuration-change-hook
- 'olivetti-set-window-margins t)
+ 'olivetti-set-environment t)
(set-window-margins nil nil)))
(provide 'olivetti)
- [elpa] branch externals/olivetti created (now 46fdcfe), Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 01af0c7 003/134: Fixed doc, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 997ae52 001/134: Initial, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti bd06cf1 004/134: Added mode-map and menu, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 6533514 002/134: Added a bunch of custom options, allow body-width float,
Stefan Monnier <=
- [elpa] externals/olivetti fd3d39d 006/134: Removed extraneous vars and fns, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 158db93 005/134: Added set-mode-line, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti af1d719 010/134: Revert "Using run-window-configuration-change-hook fn", Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 5cfe277 020/134: Changed body-width standard-value to 80, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 514bc46 009/134: Using run-window-configuration-change-hook fn, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 2363de6 008/134: Fixed margin reset on exit, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 885fb20 019/134: Added minimum-body-width, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 06bf86f 016/134: Add hook when changing fonts, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 30e3cbe 014/134: Added README/Commentary, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 869221a 013/134: Removed delete-selection-mode, Stefan Monnier, 2019/04/25