summaryrefslogtreecommitdiff
path: root/view-conf.el
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-07-20 20:31:43 +0800
committerJSDurand <mmemmew@gmail.com>2021-07-20 20:31:43 +0800
commit81df7d1780c7bfd76b72b1c4d3221e043c5df73a (patch)
tree2e46a20500faa9a0b7926250bbc4ffea73df4393 /view-conf.el
parent47ea689f4440b01df9715948f400562251b9778c (diff)
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".
Diffstat (limited to 'view-conf.el')
-rw-r--r--view-conf.el35
1 files changed, 33 insertions, 2 deletions
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))))))