[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/symbol-overlay 331b14542c 004/152: rename so-keywords to s
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/symbol-overlay 331b14542c 004/152: rename so-keywords to so-keywords-alist |
Date: |
Thu, 7 Jul 2022 12:04:06 -0400 (EDT) |
branch: elpa/symbol-overlay
commit 331b14542cc6e5ca4ac14e7060a0cef339ddfe41
Author: wolray <290061869@qq.com>
Commit: wolray <290061869@qq.com>
rename so-keywords to so-keywords-alist
---
symbol-overlay.el | 67 +++++++++++++++++++++++++++----------------------------
1 file changed, 33 insertions(+), 34 deletions(-)
diff --git a/symbol-overlay.el b/symbol-overlay.el
index 98459e776f..888c94587e 100644
--- a/symbol-overlay.el
+++ b/symbol-overlay.el
@@ -1,29 +1,28 @@
;;; symbol-overlay.el --- Putting overlays on symbol with an useful keymap.
-;; Highlighting symbol and enabling you to jump from one occurrence to another
-;; including the definition of that symbol in the buffer, with a single key
+;; Highlighting symbol while enabling you to jump from one occurrence to
another
+;; or directly to the definition of that symbol in the buffer, with a single
key
;; strike. It was originally inspired by the package 'highlight-symbol. The
-;; difference or improvement is that every symbol in 'symbol-overlay is
-;; highlighted by the emacs built-in function `overlay-put' rather than the
-;; font-lock mechanism used in 'highlight-symbol. Besides, when counting the
-;; occurrences of the symbol,'symbol-overlay needs only to simply obtain the
-;; current occurrence's index in the keywords' alist as well as the length of
it
-;; where all the overlays are stored in order. While in 'highlight-symbol, this
-;; would call the function `how-many' twice, causing a perceivable delay in a
-;; large buffer.
-
-;; In 'symbol-overlay, the highlighting method `overlay-put' is much faster
than
-;; `font-lock-fontify-buffer', especially in a large buffer, or even a
-;; less-than-100-lines small buffer of major-mode with complicated keywords
-;; syntax such as haskell-mode.
-
-;; You can also jump to a symbol's definition from any occurrence using
-;; `so-jump-to-def', as long as the syntax of the definition is specified in
-;; the buffer-local variable `so-def-function'.
-
-;; More importantly, using `overlay-put' to highlight-symbol has an extra
-;; advantage to enable a inside-overlay keymap for quick jump and other related
-;; operations by just making a single key strike.
+;; difference is that every symbol in 'symbol-overlay is highlighted by the
+;; emacs built-in function `overlay-put' rather than the font-lock mechanism
+;; used in 'highlight-symbol.
+
+;; Advantages:
+;; 1. In 'symbol-overlay, `overlay-put' is much faster than traditional
+;; highligting method `font-lock-fontify-buffer', especially in a large buffer,
+;; or even a less-than-100-lines small buffer of major-mode with complicated
+;; keywords syntax such as haskell-mode.
+;; 2. All the overlays of each symbol are stored sequentially in a alist
+;; `so-keywords-alist'. By simply obtain the current overlay's index in the
+;; alist as well as the length of it, the number of occurrences can be
+;; immediately obtained. While in 'highlight-symbol, this would call the
+;; function `how-many' twice, causing unsatisfactory extra costs.
+;; 3. You can also jump to a symbol's definition from any occurrence using
+;; `so-jump-to-def', as long as the syntax of the definition is specified in
the
+;; buffer-local variable `so-def-function'.
+;; 4. More importantly, using `overlay-put' to highlight-symbol has an extra
+;; benifit to enable an auto-activated inside-overlay keymap for quick jump and
+;; other related operations.
;; To use 'symbol-overlay in your Emacs, you need only to bind one key:
;; (global-set-key (kbd "M-i") 'so-put)
@@ -45,8 +44,8 @@
"keymap automatically activated inside overlays.
You can re-bind the commands to any keys you prefer.")
-(defvar so-keywords)
-(make-variable-buffer-local 'so-keywords)
+(defvar so-keywords-alist)
+(make-variable-buffer-local 'so-keywords-alist)
(defvar so-colors '("dodger blue"
"hot pink"
@@ -78,9 +77,9 @@ background color defined in `so-colors'."
(let* ((case-fold-search nil)
(limit (length so-colors))
(index (random limit))
- (indexes (mapcar 'cadr so-keywords))
+ (indexes (mapcar 'cadr so-keywords-alist))
color face keyword overlay)
- (when (>= (length so-keywords) limit) (user-error "No more color"))
+ (when (>= (length so-keywords-alist) limit) (user-error "No more color"))
(while (cl-find index indexes)
(setq index (random limit)))
(setq color (elt so-colors index)
@@ -94,14 +93,14 @@ background color defined in `so-colors'."
keyword (append keyword `(,overlay)))
(overlay-put overlay 'face face)
(overlay-put overlay 'keymap so-overlay-map)))
- (push keyword so-keywords)
+ (push keyword so-keywords-alist)
color))
(defun so-count-s (symbol &optional color-msg)
"Show the number of occurrences of SYMBOL, if COLOR-MSG is non-nil, add the
color used by current overlay in brackets."
(let ((case-fold-search nil)
- (keyword (assoc symbol so-keywords))
+ (keyword (assoc symbol so-keywords-alist))
overlay)
(when keyword
(setq overlay (car (overlays-at (point))))
@@ -117,7 +116,7 @@ color used by current overlay in brackets."
(unless (minibufferp)
(let ((symbol (so-get-s)))
(unless symbol (so-get-s-error))
- (if (assoc symbol so-keywords) (so-remove-s symbol)
+ (if (assoc symbol so-keywords-alist) (so-remove-s symbol)
(when (looking-at-p "\\_>") (backward-char))
(so-count-s symbol (so-put-s symbol))))))
@@ -126,12 +125,12 @@ color used by current overlay in brackets."
"Delete all highlighted symbols in the buffer."
(interactive)
(unless (minibufferp)
- (mapc 'so-remove-s (mapcar 'car so-keywords))))
+ (mapc 'so-remove-s (mapcar 'car so-keywords-alist))))
(defun so-remove-s (symbol)
"Delete the highlighted SYMBOL."
- (let ((keyword (assoc symbol so-keywords)))
- (setq so-keywords (delq keyword so-keywords))
+ (let ((keyword (assoc symbol so-keywords-alist)))
+ (setq so-keywords-alist (delq keyword so-keywords-alist))
(mapc 'delete-overlay (cddr keyword))))
;;;###autoload
@@ -194,7 +193,7 @@ the jumping direction."
(unless (minibufferp)
(let ((symbol (so-get-s)))
(unless symbol (so-get-s-error))
- (if (assoc symbol so-keywords) (so-query-replace-s symbol)
+ (if (assoc symbol so-keywords-alist) (so-query-replace-s symbol)
(message "Symbol not highlighted")))))
(defun so-query-replace-s (symbol)
- [nongnu] elpa/symbol-overlay 07119d9c95 151/152: Make the timer function only affect the current buffer, (continued)
- [nongnu] elpa/symbol-overlay 07119d9c95 151/152: Make the timer function only affect the current buffer, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 3fd1607725 022/152: (v2.5) a totally new architecture, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 368af27599 029/152: fix the image, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay f4fac7d541 030/152: fix the image, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay fdb432babd 034/152: (v3.1) add narrow-function, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 08a6f3d732 035/152: (v3.2) better way to count and filter overlays, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay e288067203 039/152: fix documentation and code style, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 191d07ec35 001/152: (init 1.0), ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 3bbbd22852 002/152: (so-overlay-map) (major-version), ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 8330423db6 005/152: add readme.md, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 331b14542c 004/152: rename so-keywords to so-keywords-alist,
ELPA Syncer <=
- [nongnu] elpa/symbol-overlay 188df4744b 007/152: after auot-insert, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 4da9d67578 008/152: edit the summary, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay e31bbd140a 011/152: Fix some typos, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 8b4e26db1c 014/152: Fix the prefix errors, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 4cf1d3c0d2 024/152: better auto-refresh, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 4a297843fd 016/152: v2.1, add 3 commands for switching and renaming symbols, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 06c5a46ef7 017/152: fix some typos, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 3d1811ca31 021/152: (v2.4) a new auto-refresh, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay f68b908cbb 026/152: fix errors in symbol-replacing, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 2650738135 031/152: a new image, ELPA Syncer, 2022/07/07