From df81e44b85cbaf07b80425d5a9069950dcc954ee Mon Sep 17 00:00:00 2001 From: JSDurand Date: Mon, 22 Feb 2021 19:20:39 +0800 Subject: Focus and elfeed binding Bind elfeed in global-map. Combine some convenient features to a function that focuses the text. --- init.el | 2 ++ view-conf.el | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/init.el b/init.el index 893457e..62d9d28 100644 --- a/init.el +++ b/init.el @@ -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)))))) -- cgit v1.2.3-18-g5258