emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/focus b90cfb3c27 50/82: Fix #4


From: ELPA Syncer
Subject: [nongnu] elpa/focus b90cfb3c27 50/82: Fix #4
Date: Tue, 6 Sep 2022 04:58:57 -0400 (EDT)

branch: elpa/focus
commit b90cfb3c2780b201f524c1bc15bd4b512bedd8ec
Author: Lars Tveito <larstvei@ifi.uio.no>
Commit: Lars Tveito <larstvei@ifi.uio.no>

    Fix #4
---
 focus.el | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/focus.el b/focus.el
index 3d492cf1f8..0695179e17 100644
--- a/focus.el
+++ b/focus.el
@@ -153,20 +153,23 @@ each command."
 It sets the `focus-pre-overlay' and `focus-post-overlay' to
 overlays; these are invisible until `focus-move-focus' is run. It
 adds `focus-move-focus' to `post-command-hook'."
-  (setq focus-pre-overlay  (make-overlay (point-min) (point-min))
-        focus-post-overlay (make-overlay (point-max) (point-max)))
-  (let ((color (focus-make-dim-color)))
-    (mapc (lambda (o) (overlay-put o 'face (cons 'foreground-color color)))
-          (list focus-pre-overlay focus-post-overlay)))
-  (add-hook 'post-command-hook 'focus-move-focus nil t))
+  (unless (or focus-pre-overlay focus-post-overlay)
+    (setq focus-pre-overlay  (make-overlay (point-min) (point-min))
+          focus-post-overlay (make-overlay (point-max) (point-max)))
+    (let ((color (focus-make-dim-color)))
+      (mapc (lambda (o) (overlay-put o 'face (cons 'foreground-color color)))
+            (list focus-pre-overlay focus-post-overlay)))
+    (add-hook 'post-command-hook 'focus-move-focus nil t)))
 
 (defun focus-terminate ()
   "This function is run when command `focus-mode' is disabled.
 
 The overlays pointed to by `focus-pre-overlay' and `focus-post-overlay' are
 deleted, and `focus-move-focus' is removed from `post-command-hook'."
-  (progn (mapc 'delete-overlay (list focus-pre-overlay focus-post-overlay))
-         (remove-hook 'post-command-hook 'focus-move-focus t)))
+  (mapc 'delete-overlay (list focus-pre-overlay focus-post-overlay))
+  (remove-hook 'post-command-hook 'focus-move-focus t)
+  (setq focus-pre-overlay  nil
+        focus-post-overlay nil))
 
 (defun focus-goto-thing (bounds)
   "Move point to the middle of BOUNDS."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]