[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``
- [nongnu] elpa/idle-highlight-mode 5881f796ad 57/59: Minor tweaks to code-comments, (continued)
- [nongnu] elpa/idle-highlight-mode 5881f796ad 57/59: Minor tweaks to code-comments, ELPA Syncer, 2022/07/07
- [nongnu] elpa/idle-highlight-mode e6239e06fd 22/59: Add license file., ELPA Syncer, 2022/07/07
- [nongnu] elpa/idle-highlight-mode ac31f75fd0 28/59: Remove local variable when the mode is disabled, ELPA Syncer, 2022/07/07
- [nongnu] elpa/idle-highlight-mode c7af42119a 38/59: Cleanup: remove unnecessary variable, ELPA Syncer, 2022/07/07
- [nongnu] elpa/idle-highlight-mode 5418252a11 59/59: Change URL to codeberg, ELPA Syncer, 2022/07/07
- [nongnu] elpa/idle-highlight-mode 53b4e3c855 45/59: Add option idle-highlight-exceptions-syntax, ELPA Syncer, 2022/07/07
- [nongnu] elpa/idle-highlight-mode 459720cd2e 29/59: Add `global-idle-highlight-mode` (globalized minor mode), ELPA Syncer, 2022/07/07
- [nongnu] elpa/idle-highlight-mode defcfe2756 54/59: Fix #1 face exceptions interact badly with hl-line-mode, ELPA Syncer, 2022/07/07
- [nongnu] elpa/idle-highlight-mode 1f40f80921 30/59: Remove "end" from idle-highlight-exceptions, ELPA Syncer, 2022/07/07
- [nongnu] elpa/idle-highlight-mode 305e9d4aa0 26/59: Cleanup: remove intermediate symbol type variable, ELPA Syncer, 2022/07/07
- [nongnu] elpa/idle-highlight-mode eaac86a1a2 49/59: Add idle-highlight-visible-buffers to apply to all buffers,
ELPA Syncer <=
- [nongnu] elpa/idle-highlight-mode 7f81263388 11/59: Add configurations for excepted words and what idle time to use., ELPA Syncer, 2022/07/07
- [nongnu] elpa/idle-highlight-mode 7c43cc3d7a 09/59: [Refactor] Lose some weight., ELPA Syncer, 2022/07/07
- [nongnu] elpa/idle-highlight-mode 3d785f0f1d 44/59: Support *-exceptions & *-exceptions-face to be callback functions, ELPA Syncer, 2022/07/07
- [nongnu] elpa/idle-highlight-mode e8f724fec2 35/59: Use a local list of overlays for highlighting, ELPA Syncer, 2022/07/07
- [nongnu] elpa/idle-highlight-mode a801e7113f 43/59: Remove 'idle-highlight-use-hi-lock-mode', ELPA Syncer, 2022/07/07
- [nongnu] elpa/idle-highlight-mode 97047f2574 33/59: Add Campbell Barton as an author, ELPA Syncer, 2022/07/07
- [nongnu] elpa/idle-highlight-mode 98d20252d6 42/59: readme: add "Motivation" & "Other Packages" section, ELPA Syncer, 2022/07/07
- [nongnu] elpa/idle-highlight-mode d0fcf29c7d 46/59: Cleanup: unnecessary pcase-let* use, ELPA Syncer, 2022/07/07