summaryrefslogtreecommitdiff
path: root/view-conf.el
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-02-22 19:20:39 +0800
committerJSDurand <mmemmew@gmail.com>2021-02-22 19:20:39 +0800
commitdf81e44b85cbaf07b80425d5a9069950dcc954ee (patch)
tree46fa00b841ca68609e088c1bf62cb770ca960894 /view-conf.el
parent7743f3ed1b81fbc693d58585596bf7caf783d1c7 (diff)
Focus and elfeed binding
Bind elfeed in global-map. Combine some convenient features to a function that focuses the text.
Diffstat (limited to 'view-conf.el')
-rw-r--r--view-conf.el32
1 files changed, 32 insertions, 0 deletions
diff --git a/view-conf.el b/view-conf.el
index 47ee35d..286fded 100644
--- a/view-conf.el
+++ b/view-conf.el
@@ -96,6 +96,7 @@ If ARG is '(16), view the battery information."
(define-key map (vector ?v) #'view-mode)
(define-key map (vector ?P) #'durand-view-process)
(define-key map (vector ?t) #'durand-view-timers-or-temps)
+ (define-key map (vector ?f) #'durand-focus)
(define-key map (vector ?e) #'eshell)
(define-key map (vector ?p) #'durand-chercher-pdf)
(define-key map (vector ?o) #'olivetti-mode)
@@ -323,3 +324,34 @@ If ARG is non-nil, do the same for Bluetooth."
("on"))))))))))
(define-key global-map (vector 3 ?w) #'durand-wifi-or-bluetooth)
+
+;;; focus mode
+
+;;;###autoload
+(defvar durand-focus-p nil
+ "Whether we are focusing or not.")
+
+(make-variable-buffer-local 'durand-focus-p)
+
+;;;###autoload
+(defun durand-focus (&optional arg)
+ "Focus.
+This is a combination of `variable-pitch-mode', `olivetti-mode',
+and `text-scale-increase'.
+
+If optional ARG is non-nil, then also enables `view-mode'."
+ (interactive "P")
+ (cond
+ (durand-focus-p
+ (setq durand-focus-p nil)
+ (setq olivetti-body-width 80)
+ (variable-pitch-mode -1)
+ (view-mode -1)
+ (olivetti-mode -1)
+ (text-scale-increase 0))
+ ((setq olivetti-body-width 60)
+ (setq durand-focus-p t)
+ (olivetti-mode 1)
+ (text-scale-increase 2)
+ (variable-pitch-mode 1)
+ (cond (arg (view-mode 1))))))