[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/symbol-overlay a88b79fa6a 100/152: Reduce duplication in "
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/symbol-overlay a88b79fa6a 100/152: Reduce duplication in "ignore" functions |
Date: |
Thu, 7 Jul 2022 12:04:18 -0400 (EDT) |
branch: elpa/symbol-overlay
commit a88b79fa6a5c996dc1a17518610b925eca96478b
Author: Steve Purcell <steve@sanityinc.com>
Commit: Steve Purcell <steve@sanityinc.com>
Reduce duplication in "ignore" functions
See #27
---
symbol-overlay.el | 66 +++++++++++++++++++++++++++++++------------------------
1 file changed, 37 insertions(+), 29 deletions(-)
diff --git a/symbol-overlay.el b/symbol-overlay.el
index ac6a99c349..efdf753b47 100644
--- a/symbol-overlay.el
+++ b/symbol-overlay.el
@@ -355,38 +355,47 @@ If SHOW-COLOR is non-nil, display the color used by
current overlay."
(+ count 1)
(+ count (length after))))))
+(defun symbol-overlay-match-keyword-list (symbol keywords)
+ "Return non-nil is SYMBOL is among KEYWORDS.
+KEYWORDS is a list of strings. SYMBOL is expected to include
+leading \\< and trailing \\>, as per the return value of
+`symbol-overlay-get-symbol'."
+ (cl-find (substring symbol 3 -3) keywords :test #'string=))
+
(defvar c-font-lock-extra-types)
(defun symbol-overlay-ignore-function-c (symbol)
"Determine whether SYMBOL should be ignored (C Language)."
- (let ((keywords (append c-font-lock-extra-types
- '("auto" "break" "case" "char" "const" "continue"
- "default" "do" "double" "else" "enum" "extern"
- "float" "for" "goto" "if" "inline" "int" "long"
- "register" "restrict" "return" "short" "signed"
- "sizeof" "static" "struct" "switch" "typedef"
- "union" "unsigned" "void" "volatile" "while"))))
- (string-match-p (concat "\\_<\\(" (mapconcat 'identity keywords "\\|")
"\\)\\_>") symbol)))
+ (symbol-overlay-match-keyword-list
+ symbol
+ (append c-font-lock-extra-types
+ '("auto" "break" "case" "char" "const" "continue"
+ "default" "do" "double" "else" "enum" "extern"
+ "float" "for" "goto" "if" "inline" "int" "long"
+ "register" "restrict" "return" "short" "signed"
+ "sizeof" "static" "struct" "switch" "typedef"
+ "union" "unsigned" "void" "volatile" "while"))))
(defvar c++-font-lock-extra-types)
(defun symbol-overlay-ignore-function-c++ (symbol)
"Determine whether SYMBOL should be ignored (C++)."
- (let ((keywords (append c++-font-lock-extra-types
- '("alignas" "alignof" "asm" "auto" "bool" "break"
- "case" "catch" "char" "char16_t" "char32_t" "class"
- "const" "const_cast" "constexpr" "continue"
- "decltype" "default" "delete" "do" "double"
- "dynamic_cast" "else" "enum" "explicit" "export"
- "extern" "false" "final" "float" "for" "friend"
- "goto" "if" "inline" "int" "long" "mutable"
- "namespace" "new" "noexcept" "nullptr" "operator"
- "override" "private" "protected" "public" "register"
- "reinterpret_cast" "return" "short" "signed"
- "sizeof" "static" "static_assert" "static_cast"
- "struct" "switch" "template" "this" "thread_local"
- "throw" "true" "try" "typedef" "typeid" "typename"
- "union" "unsigned" "using" "virtual" "void"
- "volatile" "wchar_t" "while"))))
- (string-match-p (concat "\\_<\\(" (mapconcat 'identity keywords "\\|")
"\\)\\_>") symbol)))
+ (symbol-overlay-match-keyword-list
+ symbol
+ (append c++-font-lock-extra-types
+ '("alignas" "alignof" "asm" "auto" "bool" "break"
+ "case" "catch" "char" "char16_t" "char32_t" "class"
+ "const" "const_cast" "constexpr" "continue"
+ "decltype" "default" "delete" "do" "double"
+ "dynamic_cast" "else" "enum" "explicit" "export"
+ "extern" "false" "final" "float" "for" "friend"
+ "goto" "if" "inline" "int" "long" "mutable"
+ "namespace" "new" "noexcept" "nullptr" "operator"
+ "override" "private" "protected" "public" "register"
+ "reinterpret_cast" "return" "short" "signed"
+ "sizeof" "static" "static_assert" "static_cast"
+ "struct" "switch" "template" "this" "thread_local"
+ "throw" "true" "try" "typedef" "typeid" "typename"
+ "union" "unsigned" "using" "virtual" "void"
+ "volatile" "wchar_t" "while"))))
(defvar python-font-lock-keywords)
(defun symbol-overlay-ignore-function-python (symbol)
@@ -403,10 +412,9 @@ If SHOW-COLOR is non-nil, display the color used by
current overlay."
(defun symbol-overlay-ignore-function-go (symbol)
"Determine whether SYMBOL should be ignored (Go)."
;; Remove \_< and \_> so we can string compare with keywords
- (let ((symbol (substring symbol 3 -3) ))
- (or (cl-find symbol go-builtins :test #'string=)
- (cl-find symbol go-constants :test #'string=)
- (cl-find symbol go-mode-keywords :test #'string=))))
+ (or (symbol-overlay-match-keyword-list symbol go-builtins)
+ (symbol-overlay-match-keyword-list symbol go-constants)
+ (symbol-overlay-match-keyword-list symbol go-mode-keywords)))
;;;###autoload
(defun symbol-overlay-put ()
- [nongnu] elpa/symbol-overlay 7b638c8418 064/152: Properly define symbol-overlay-temp-face, (continued)
- [nongnu] elpa/symbol-overlay 7b638c8418 064/152: Properly define symbol-overlay-temp-face, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 6971ab0c16 067/152: Declare minor mode earlier to avoid byte compilation warnings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay bce9d9d3c9 069/152: Merge pull request #8 from purcell/master, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 824cefc469 076/152: Use recommended syntax for setting overlay face property, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 6a3c16e506 077/152: Merge pull request #12 from purcell/patch-3, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 72c35dadcc 087/152: wip: add support for major-mode dependent ignored keywords, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay bb02b971b0 086/152: magit test, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 920bf50678 092/152: Remove now-unused symbol-overlay-colors variable, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay f4737b401a 095/152: Merge pull request #22 from LeandroCardoso/master, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 4885b028ee 098/152: Add support to ignore keywords in go-mode, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay a88b79fa6a 100/152: Reduce duplication in "ignore" functions,
ELPA Syncer <=
- [nongnu] elpa/symbol-overlay 103e099e19 102/152: Improve support for fonts in Customize, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 819a62f919 106/152: Use a dedicated unnamed section for the provide form, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay fb00db9e8c 108/152: Move definition of symbol-overlay-refresh, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 63323516b4 117/152: Replaced lisp implementation of window start and end with c primitive, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 213629dc13 120/152: Add a "hook" which is called when overlays are created, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 200b3d2d75 133/152: Ensure timer callback always runs in the triggering buffer, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 3a1ac7e3bf 122/152: Add support to ignore keywords in java-mode, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 4623bd1ab3 131/152: Fix format error while marking a symbol contains "%", ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 0d8900dd78 128/152: Add missing package dependency on "seq", ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 291dd270e3 142/152: Merge pull request #71 from mpenet/feat/add-clojure-kw-list, ELPA Syncer, 2022/07/07