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

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

[nongnu] elpa/focus a80b7b6eba 71/82: Add possibility of customizing the


From: ELPA Syncer
Subject: [nongnu] elpa/focus a80b7b6eba 71/82: Add possibility of customizing the face of the focused region
Date: Tue, 6 Sep 2022 04:58:59 -0400 (EDT)

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

    Add possibility of customizing the face of the focused region
---
 focus.el | 41 +++++++++++++++++++++++++++++------------
 1 file changed, 29 insertions(+), 12 deletions(-)

diff --git a/focus.el b/focus.el
index 64d46617b4..76480aa93d 100644
--- a/focus.el
+++ b/focus.el
@@ -59,12 +59,19 @@ Things that are defined include `symbol', `list', `sexp',
   :type '(float)
   :group 'focus)
 
+(defcustom focus-unfocused-face 'font-lock-comment-face
+  "The face that overlays the unfocused area."
+  :type '(face)
+  :group 'focus)
+
+(defcustom focus-focused-face nil
+  "The face that overlays the focused area."
+  :type '(face)
+  :group 'focus)
+
 (defvar focus-cursor-type cursor-type
   "Used to restore the users `cursor-type'")
 
-(defvar focus-unfocused-face font-lock-comment-face
-  "Overrides the color used for dimmed text.")
-
 (defvar-local focus-current-thing nil
   "Overrides the choice of thing dictated by `focus-mode-to-thing' if set.")
 
@@ -74,6 +81,9 @@ Things that are defined include `symbol', `list', `sexp',
 (defvar-local focus-pre-overlay nil
   "The overlay that dims the text prior to the current-point.")
 
+(defvar-local focus-mid-overlay nil
+  "The overlay that surrounds the text of the current-point.")
+
 (defvar-local focus-post-overlay nil
   "The overlay that dims the text past the current-point.")
 
@@ -105,20 +115,24 @@ command."
         (focus-move-overlays (car bounds) (cdr bounds))))))
 
 (defun focus-move-overlays (low high)
-  "Move `focus-pre-overlay' and `focus-post-overlay'."
-  (move-overlay focus-pre-overlay  (point-min) low)
+  "Move `focus-pre-overlay', `focus-mid-overlay' and `focus-post-overlay'."
+  (move-overlay focus-pre-overlay (point-min) low)
+  (move-overlay focus-mid-overlay low high)
   (move-overlay focus-post-overlay high (point-max)))
 
 (defun focus-init ()
   "This function is run when command `focus-mode' is enabled.
 
-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'."
+It sets the `focus-pre-overlay', `focus-min-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'."
   (unless (or focus-pre-overlay focus-post-overlay)
     (setq focus-pre-overlay  (make-overlay (point-min) (point-min))
+          focus-mid-overlay  (make-overlay (point-min) (point-max))
           focus-post-overlay (make-overlay (point-max) (point-max))
           focus-buffer (current-buffer))
+    (overlay-put focus-mid-overlay 'face focus-focused-face)
     (mapc (lambda (o) (overlay-put o 'face focus-unfocused-face))
           (list focus-pre-overlay focus-post-overlay))
     (add-hook 'post-command-hook 'focus-move-focus nil t)
@@ -127,12 +141,15 @@ adds `focus-move-focus' to `post-command-hook'."
 (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'."
+The overlays pointed to by `focus-pre-overlay',
+`focus-mid-overlay' and `focus-post-overlay' are deleted, and
+`focus-move-focus' is removed from `post-command-hook'."
   (when (and focus-pre-overlay focus-post-overlay)
-    (mapc 'delete-overlay (list focus-pre-overlay focus-post-overlay))
+    (mapc 'delete-overlay
+          (list focus-pre-overlay focus-mid-overlay focus-post-overlay))
     (remove-hook 'post-command-hook 'focus-move-focus t)
-    (setq focus-pre-overlay  nil
+    (setq focus-pre-overlay nil
+          focus-mid-overlay nil
           focus-post-overlay nil)))
 
 (defun focus-goto-thing (bounds)



reply via email to

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