[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/olivetti d2c54ac 072/134: Add change-major-mode-hook to
From: |
Stefan Monnier |
Subject: |
[elpa] externals/olivetti d2c54ac 072/134: Add change-major-mode-hook to reset margins |
Date: |
Thu, 25 Apr 2019 09:57:31 -0400 (EDT) |
branch: externals/olivetti
commit d2c54acf566a9ee38021261f7d8f43a94c9eee8c
Author: Paul Rankin <address@hidden>
Commit: Paul Rankin <address@hidden>
Add change-major-mode-hook to reset margins
Streamlining hooks, using eq over equal and assq over assoc.
---
olivetti.el | 42 +++++++++++++++++++-----------------------
1 file changed, 19 insertions(+), 23 deletions(-)
diff --git a/olivetti.el b/olivetti.el
index 1cea3c5..a90ad93 100644
--- a/olivetti.el
+++ b/olivetti.el
@@ -159,16 +159,15 @@ If ARG is 'exit, kill `mode-line-format' then rerun.
If ARG is nil and `olivetti-hide-mode-line' is non-nil, hide the
mode line."
- (cond ((equal arg 'toggle)
+ (cond ((eq arg 'toggle)
(setq olivetti-hide-mode-line
- (null olivetti-hide-mode-line))
+ (not olivetti-hide-mode-line))
(olivetti-set-mode-line))
- ((or (equal arg 'exit)
- (null olivetti-hide-mode-line))
+ ((or (eq arg 'exit)
+ (not olivetti-hide-mode-line))
(kill-local-variable 'mode-line-format))
(olivetti-hide-mode-line
(setq-local mode-line-format nil))))
- ;; (redraw-frame (selected-frame)))
(defun olivetti-scale-width (n)
"Scale N in accordance with the face height.
@@ -176,8 +175,8 @@ mode line."
For compatibility with `text-scale-mode', if
`face-remapping-alist' includes a :height property on the default
face, scale N by that factor, otherwise scale by 1."
- (let ((face-height (or (plist-get (cadr (assoc 'default
- face-remapping-alist))
+ (let ((face-height (or (plist-get (cadr (assq 'default
+ face-remapping-alist))
:height)
1)))
(round (* n face-height))))
@@ -232,7 +231,7 @@ care that the maximum size is 0.
Also set the window parameter 'min-margins to half of the margin
current width."
(dolist (window (get-buffer-window-list (current-buffer) nil t))
- (if (equal arg 'exit)
+ (if (eq arg 'exit)
(set-window-margins window nil nil)
(let* ((n (olivetti-safe-width (if (integerp olivetti-body-width)
(olivetti-scale-width
olivetti-body-width)
@@ -241,7 +240,8 @@ current width."
(width (cond ((integerp n) n)
((floatp n) (* (window-total-width window)
n))))
- (margin (max (round (/ (- (window-total-width window) width)
+ (margin (max (round (/ (- (window-total-width window)
+ width)
2))
0))
(min-margin (floor (/ (float margin)
@@ -313,26 +313,22 @@ hidden."
:lighter olivetti-lighter
(if olivetti-mode
(progn
- (add-hook 'window-configuration-change-hook
- #'olivetti-set-environment nil t)
- (add-hook 'after-setting-font-hook
- #'olivetti-set-environment nil t)
- (add-hook 'text-scale-mode-hook
- #'olivetti-set-environment nil t)
+ (dolist (hook '(window-configuration-change-hook
+ after-setting-font-hook
+ text-scale-mode-hook))
+ (add-hook hook 'olivetti-set-environment t t))
+ (add-hook 'change-major-mode-hook
+ '(lambda nil (olivetti-set-environment 'exit)) nil t)
(setq olivetti--visual-line-mode visual-line-mode)
(unless olivetti--visual-line-mode
(visual-line-mode 1))
(if olivetti-hide-mode-line
(olivetti-set-mode-line))
- (if olivetti-patch-emacs-bugs
- (olivetti-patch-emacs-bugs))
(olivetti-set-environment))
- (remove-hook 'window-configuration-change-hook
- #'olivetti-set-environment t)
- (remove-hook 'after-setting-font-hook
- #'olivetti-set-environment t)
- (remove-hook 'text-scale-mode-hook
- #'olivetti-set-environment t)
+ (dolist (hook '(window-configuration-change-hook
+ after-setting-font-hook
+ text-scale-mode-hook))
+ (remove-hook hook 'olivetti-set-environment t))
(olivetti-set-mode-line 'exit)
(olivetti-set-environment 'exit)
(if (and olivetti-recall-visual-line-mode-entry-state
- [elpa] externals/olivetti da1ef8e 114/134: Improving olivetti-safe-width, (continued)
- [elpa] externals/olivetti da1ef8e 114/134: Improving olivetti-safe-width, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti d40a054 126/134: Fixed olivetti-scale-width for integer heights, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 2ae21fa 128/134: Remove redundant turn-on-olivetti-mode function, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 7c4410f 133/134: Rename olivetti-set-environment -> olivetti-set-margins, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 40c64f9 131/134: Remove window-configuration-change-hook, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 26f3db0 050/134: Updated README/Commentary, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 66bdcc7 057/134: lexical-binding: t, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti f53b5f4 062/134: Added mode-map, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti ce4c9f0 068/134: Document split-window-right workaround, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 9d318be 069/134: Added README to Commentary, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti d2c54ac 072/134: Add change-major-mode-hook to reset margins,
Stefan Monnier <=
- [elpa] externals/olivetti 5ac4444 085/134: Use GitHub repo screenshot, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti cefceed 089/134: Added note about buggy display-line-numbers-mode, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 9d9f9ce 090/134: Added hints, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 988d326 092/134: Use HTTPS for README links, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti dd9162f 112/134: Documentation improvements, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 3facf2b 115/134: Change hooks:, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti e70adca 121/134: Add safe custom variable properties, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 3df740c 122/134: Change top-level customization group wp -> text, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 2304ddc 124/134: Refactoring style: if -> when for condition cases without else, Stefan Monnier, 2019/04/25
- [elpa] externals/olivetti 687f2df 129/134: Require Emacs 24.5, Stefan Monnier, 2019/04/25