summaryrefslogtreecommitdiff
path: root/view-conf.el
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-03-01 13:27:32 +0800
committerJSDurand <mmemmew@gmail.com>2021-03-01 13:27:32 +0800
commitf76ba0b6608072532f9a13b5b607c43aad12f159 (patch)
tree4fee2628553834cd614ddcf68e7ea72b2ccabcdd /view-conf.el
parent41ded7cd3b9129826d7caa4da51275628b2638c0 (diff)
Refine the focus command
Diffstat (limited to 'view-conf.el')
-rw-r--r--view-conf.el34
1 files 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))))
+