[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/idle-highlight-mode 3d785f0f1d 44/59: Support *-exceptions
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/idle-highlight-mode 3d785f0f1d 44/59: Support *-exceptions & *-exceptions-face to be callback functions |
Date: |
Thu, 7 Jul 2022 12:00:32 -0400 (EDT) |
branch: elpa/idle-highlight-mode
commit 3d785f0f1d5a41ec70453c3000ba3a3e5f0f7dbb
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Support *-exceptions & *-exceptions-face to be callback functions
This allows flexible user defined functionality when filtering
symbols to highlight.
---
changelog.rst | 4 +++-
idle-highlight-mode.el | 43 ++++++++++++++++++++++++++++++-------------
readme.rst | 9 ++++++++-
3 files changed, 41 insertions(+), 15 deletions(-)
diff --git a/changelog.rst b/changelog.rst
index 6f02aafccc..bfbe7a616f 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -1,5 +1,7 @@
-- In development (2021-08-27)
+- In development (2021-08-29)
+ - 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.
- Add ``idle-highlight-exclude-point`` option to exclude the current word
from highlighting.
- Add ``idle-highlight-exceptions-face`` to support excluding words by face.
- Add ``global-idle-highlight-mode`` (globalized minor mode).
diff --git a/idle-highlight-mode.el b/idle-highlight-mode.el
index 3d86713e33..ca7827f3a9 100755
--- a/idle-highlight-mode.el
+++ b/idle-highlight-mode.el
@@ -71,12 +71,20 @@
(defcustom idle-highlight-exceptions nil
"List of words to be excepted from highlighting."
:group 'idle-highlight
- :type '(repeat string))
+ :type
+ '
+ (choice
+ (repeat :tag "A list of string literals that will be excluded." string)
+ (function :tag "A function taking a string, non-nil result excludes.")))
(defcustom idle-highlight-exceptions-face '(font-lock-keyword-face
font-lock-string-face)
"List of exception faces."
:group 'idle-highlight
- :type '(repeat symbol))
+ :type
+ '
+ (choice
+ (repeat :tag "A list of face symbols that will be ignored." symbol)
+ (function :tag "A function that takes a list of faces, non-nil result
excludes.")))
(defcustom idle-highlight-exclude-point nil
"Exclude the current symbol from highlighting."
@@ -128,16 +136,20 @@ Argument POS return faces at this point."
"Check if the position POS has faces that match the exclude argument."
(cond
(idle-highlight-exceptions-face
- (let
- (
- (result t)
- (faces-at-pos (idle-highlight--faces-at-point pos)))
- (while faces-at-pos
- (let ((face (pop faces-at-pos)))
- (when (memq face idle-highlight-exceptions-face)
- (setq result nil)
- ;; Break.
- (setq faces-at-pos nil))))
+ (let ((result t))
+ (let ((faces-at-pos (idle-highlight--faces-at-point pos)))
+ (when faces-at-pos
+ (cond
+ ((functionp idle-highlight-exceptions-face)
+ (when (funcall idle-highlight-exceptions-face faces-at-pos)
+ (setq result nil)))
+ (t
+ (while faces-at-pos
+ (let ((face (pop faces-at-pos)))
+ (when (memq face idle-highlight-exceptions-face)
+ (setq result nil)
+ ;; Break.
+ (setq faces-at-pos nil))))))))
result))
(t ;; Default to true, if there are no exceptions.
t)))
@@ -190,7 +202,12 @@ Argument POS return faces at this point."
(looking-at-p "\\s_\\|\\sw"))
(pcase-let* ((`(,beg . ,end) target-range))
(let ((target (buffer-substring-no-properties beg end)))
- (when (not (member target idle-highlight-exceptions))
+ (unless
+ (cond
+ ((functionp idle-highlight-exceptions)
+ (funcall idle-highlight-exceptions target))
+ (t
+ (member target idle-highlight-exceptions)))
(idle-highlight--highlight target beg end)))))))
diff --git a/readme.rst b/readme.rst
index 91b511b2e9..16544ff0ab 100644
--- a/readme.rst
+++ b/readme.rst
@@ -45,9 +45,15 @@ Global Settings
``idle-highlight``
Face used for highlighting the symbol.
``idle-highlight-exceptions``: ``nil``
- Words to exclude from highlighting.
+ A list of words to exclude from highlighting.
+
+ This may also be set to a function that takes the word as an argument,
+ returning non-nil to exclude the word.
``idle-highlight-exceptions-face``: ``'(font-lock-keyword-face
font-lock-string-face)``
Faces to exclude from highlighting (defaults to ignore keywords & strings).
+
+ This may also be set to a function that takes a list of faces,
+ returning non-nil to exclude the word.
``idle-highlight-exclude-point``: ``nil``
When non-nil, don't highlight the symbol under the cursor.
``idle-highlight-idle-time``: ``0.35``
@@ -55,6 +61,7 @@ Global Settings
``global-idle-highlight-ignore-modes``: ``nil``
A list of modes that won't enable idle-highlight from
``global-idle-highlight-mode``.
+
Buffer Local Settings
^^^^^^^^^^^^^^^^^^^^^
- [nongnu] elpa/idle-highlight-mode c7af42119a 38/59: Cleanup: remove unnecessary variable, (continued)
- [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, 2022/07/07
- [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 <=
- [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