From f76ba0b6608072532f9a13b5b607c43aad12f159 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Mon, 1 Mar 2021 13:27:32 +0800 Subject: Refine the focus command --- view-conf.el | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/view-conf.el b/view-conf.el index 286fded..bed8495 100644 --- a/view-conf.el +++ b/view-conf.el @@ -328,30 +328,24 @@ If ARG is non-nil, do the same for Bluetooth." ;;; focus mode ;;;###autoload -(defvar durand-focus-p nil - "Whether we are focusing or not.") +(defvar durand-focus-map '(keymap "focus") + "The keymap for the focus mode.") -(make-variable-buffer-local 'durand-focus-p) +(define-key durand-focus-map (vector ?\s-v) #'view-mode) +(define-key durand-focus-map (vector ?\s-x) #'durand-focus) ;;;###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") +(define-minor-mode durand-focus + "Focus mode." nil "Foc" nil (cond - (durand-focus-p - (setq durand-focus-p nil) - (setq olivetti-body-width 80) + (durand-focus + (setq olivetti-body-width 65) + (olivetti-mode 1) + (text-scale-increase 2) + (variable-pitch-mode 1)) + ((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)))))) + (text-scale-increase 0)))) + -- cgit v1.2.3-18-g5258