diff options
author | JSDurand <mmemmew@gmail.com> | 2021-02-22 19:20:39 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2021-02-22 19:20:39 +0800 |
commit | df81e44b85cbaf07b80425d5a9069950dcc954ee (patch) | |
tree | 46fa00b841ca68609e088c1bf62cb770ca960894 | |
parent | 7743f3ed1b81fbc693d58585596bf7caf783d1c7 (diff) |
Focus and elfeed binding
Bind elfeed in global-map.
Combine some convenient features to a function that focuses the text.
-rw-r--r-- | init.el | 2 | ||||
-rw-r--r-- | view-conf.el | 32 |
2 files changed, 34 insertions, 0 deletions
@@ -223,6 +223,8 @@ no effect." (load-after-function elfeed "elfeed-conf.el" "Load elfeed and launch it." nil (elfeed)) +(define-key global-map (vector 3 101) #'elfeed) + ;;; magit (load-after-function magit "magit-conf.el" "Load magit and launch it." nil 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)))))) |