From 81df7d1780c7bfd76b72b1c4d3221e043c5df73a Mon Sep 17 00:00:00 2001 From: JSDurand Date: Tue, 20 Jul 2021 20:31:43 +0800 Subject: change: durand-focus * view-conf.el (durand-focus-focus): Toggle font-size and/or variable-pitch-mode, depending on the argument. (durand-focus): Now focus mode won't increase font-size and variable-pitch-mode by default. Instead use the following binding to toggle these settings if desired. (durand-focus-map): Bind to "M-s-f". --- view-conf.el | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'view-conf.el') diff --git a/view-conf.el b/view-conf.el index 7e00f5c..a2cecc2 100644 --- a/view-conf.el +++ b/view-conf.el @@ -286,6 +286,7 @@ options to choose from." (define-key durand-focus-map (vector ?\s-v) #'view-mode) (define-key durand-focus-map (vector ?\s-x) #'durand-focus) +(define-key durand-focus-map (vector ?\M-\s-f) #'durand-focus-focus) (define-key view-mode-map (vector ?f) #'durand-scroll-next-paragraph) (define-key view-mode-map (vector ?b) #'durand-scroll-prev-paragraph) @@ -296,11 +297,41 @@ options to choose from." (durand-focus (setq olivetti-body-width 65) (olivetti-mode 1) - (text-scale-increase 2) - (variable-pitch-mode 1) (cond (current-prefix-arg (view-mode 1)))) ((setq olivetti-body-width 80) (variable-pitch-mode -1) (view-mode -1) (olivetti-mode -1) (text-scale-increase 0)))) + +;;;###autoload +(defun durand-focus-focus (&optional arg) + "Toggle the font size and `variable-pitch-mode'. +ARG will be (prefix-numeric-value prefix-arg) in interactive +uses. + +If ARG is non-zero and odd, toggle font-size. + +If ARG is non-zero and the second bit is non-zero, toggle +`variable-pitch-mode'." + (interactive "p") + (setq arg (prefix-numeric-value arg)) + (cond + ((= arg 0) + (cond + ((and text-scale-mode + (/= text-scale-mode-amount 0)) + (text-scale-increase 0)) + ((text-scale-increase 2))) + (variable-pitch-mode 'toggle)) + (t + (cond + ((= (% arg 2) 1) + (cond + ((and text-scale-mode + (/= text-scale-mode-amount 0)) + (text-scale-increase 0)) + ((text-scale-increase 2))))) + (cond + ((= (logand arg 2) 2) + (variable-pitch-mode 'toggle)))))) -- cgit v1.2.3-18-g5258