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

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

[nongnu] elpa/idle-highlight-mode eaac86a1a2 49/59: Add idle-highlight-v


From: ELPA Syncer
Subject: [nongnu] elpa/idle-highlight-mode eaac86a1a2 49/59: Add idle-highlight-visible-buffers to apply to all buffers
Date: Thu, 7 Jul 2022 12:00:32 -0400 (EDT)

branch: elpa/idle-highlight-mode
commit eaac86a1a255188b58ee275ee1fd571db55f0235
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>

    Add idle-highlight-visible-buffers to apply to all buffers
    
    Optionally highlight all visible buffers using the current highlighted
    symbol.
---
 changelog.rst          |  1 +
 idle-highlight-mode.el | 49 ++++++++++++++++++++++++++++++++++++-------------
 readme.rst             |  2 ++
 3 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/changelog.rst b/changelog.rst
index 974683b79e..baae007619 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -1,6 +1,7 @@
 - In development (2021-08-29)
 
   - Fix highlighting with multiple windows sharing one buffer.
+  - Add ``idle-highlight-visible-buffers`` to support highlighting all buffers 
with the current symbol.
   - Add ``idle-highlight-exceptions-syntax`` so the characters used in the 
syntax-table used can be customized.
   - Support setting ``idle-highlight-exceptions`` to a function that takes the 
word as an argument.
   - Support setting ``idle-highlight-exceptions-face`` to a function that 
takes list of faces as an argument.
diff --git a/idle-highlight-mode.el b/idle-highlight-mode.el
index f337a48fbb..5431b3640e 100755
--- a/idle-highlight-mode.el
+++ b/idle-highlight-mode.el
@@ -98,6 +98,11 @@ See documentation for `skip-syntax-forward', nil to ignore."
   :group 'idle-highlight
   :type 'boolean)
 
+(defcustom idle-highlight-visible-buffers nil
+  "Apply the current highlight to all other visible buffers."
+  :group 'idle-highlight
+  :type 'boolean)
+
 (defcustom idle-highlight-idle-time 0.35
   "Time after which to highlight the word at point."
   :group 'idle-highlight
@@ -251,16 +256,21 @@ Argument VISIBLE-RANGES is a list of (min . max) ranges 
to highlight."
                   (overlay-put ov 'face 'idle-highlight)
                   (push ov idle-highlight--overlays))))))))))
 
-(defun idle-highlight--word-at-point (visible-ranges)
-  "Highlight the word under the point across all VISIBLE-RANGES."
-  (idle-highlight--unhighlight)
+(defun idle-highlight--word-at-point-args ()
   (when (idle-highlight--check-symbol-at-point (point))
     (let ((target-range (bounds-of-thing-at-point 'symbol)))
       (when (and target-range (idle-highlight--check-faces-at-point (point)))
         (pcase-let ((`(,target-beg . ,target-end) target-range))
           (let ((target (buffer-substring-no-properties target-beg 
target-end)))
             (when (idle-highlight--check-word target)
-              (idle-highlight--highlight target target-beg target-end 
visible-ranges))))))))
+              (cons target target-range))))))))
+
+(defun idle-highlight--word-at-point-highlight (target target-range 
visible-ranges)
+  "Highlight the word under the point across all VISIBLE-RANGES."
+  (idle-highlight--unhighlight)
+  (when target
+    (pcase-let ((`(,target-beg . ,target-end) target-range))
+      (idle-highlight--highlight target target-beg target-end 
visible-ranges))))
 
 
 ;; ---------------------------------------------------------------------------
@@ -294,7 +304,8 @@ Argument VISIBLE-RANGES is a list of (min . max) ranges to 
highlight."
     ( ;; Ensure all other buffers are highlighted on request.
       (is-mode-active (bound-and-true-p idle-highlight-mode))
       (buf-current (current-buffer))
-      (dirty-buffer-list (list)))
+      (dirty-buffer-list (list))
+      (force-all idle-highlight-visible-buffers))
 
     ;; When this buffer is not in the mode, flush all other buffers.
     (cond
@@ -305,6 +316,9 @@ Argument VISIBLE-RANGES is a list of (min . max) ranges to 
highlight."
         ;; a previous buffer may need a final refresh, ensure this happens.
         (setq idle-highlight--dirty-flush-all t)))
 
+    (when force-all
+      (setq idle-highlight--dirty-flush-all t))
+
     ;; Accumulate visible ranges in each buffers `idle-highlight--dirty'
     ;; value which is temporarily used as a list to store ranges.
     (dolist (frame (frame-list))
@@ -315,7 +329,7 @@ Argument VISIBLE-RANGES is a list of (min . max) ranges to 
highlight."
               (idle-highlight--dirty-flush-all
                 (and
                   (buffer-local-value 'idle-highlight-mode buf)
-                  (buffer-local-value 'idle-highlight--dirty buf)))
+                  (or (buffer-local-value 'idle-highlight--dirty buf) 
force-all)))
               (t
                 (eq buf buf-current)))
 
@@ -338,14 +352,23 @@ Argument VISIBLE-RANGES is a list of (min . max) ranges 
to highlight."
                       (line-end-position)))
                   idle-highlight--dirty)))))))
 
-    (dolist (buf dirty-buffer-list)
-      (with-current-buffer buf
-        (let ((visible-ranges idle-highlight--dirty))
-          ;; Restore this values status as a boolean.
-          (setq idle-highlight--dirty nil)
 
-          (setq visible-ranges (idle-highlight--merge-overlapping-ranges 
visible-ranges))
-          (idle-highlight--word-at-point visible-ranges))))
+    (let ((target-args (and force-all (idle-highlight--word-at-point-args))))
+      (dolist (buf dirty-buffer-list)
+        (with-current-buffer buf
+          (let ((visible-ranges idle-highlight--dirty))
+            ;; Restore this values status as a boolean.
+            (setq idle-highlight--dirty nil)
+
+            (setq visible-ranges (idle-highlight--merge-overlapping-ranges 
visible-ranges))
+
+            (unless force-all
+              (setq target-args (idle-highlight--word-at-point-args)))
+
+            (pcase-let ((`(,target . ,target-range) target-args))
+              (when (and force-all (not (eq buf buf-current)))
+                (setq target-range nil))
+              (idle-highlight--word-at-point-highlight target target-range 
visible-ranges))))))
 
     (cond
       (is-mode-active
diff --git a/readme.rst b/readme.rst
index f04b9c7dba..6068b28774 100644
--- a/readme.rst
+++ b/readme.rst
@@ -60,6 +60,8 @@ Global Settings
    see documentation for ``skip-syntax-forward``, use ``nil`` to skip this 
check.
 ``idle-highlight-exclude-point``: ``nil``
    When non-nil, don't highlight the symbol under the cursor.
+``idle-highlight-visible-buffers``: ``nil``
+   Apply the current highlighting to all visible buffers.
 ``idle-highlight-idle-time``: ``0.35``
    Delay before highlighting (in seconds).
 ``global-idle-highlight-ignore-modes``: ``nil``



reply via email to

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