[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/symbol-overlay 6c7ec584b6 074/152: 170826
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/symbol-overlay 6c7ec584b6 074/152: 170826 |
Date: |
Thu, 7 Jul 2022 12:04:16 -0400 (EDT) |
branch: elpa/symbol-overlay
commit 6c7ec584b62b7922a5398a552a1bf60f8144306c
Author: wolray <290061869@qq.com>
Commit: wolray <290061869@qq.com>
170826
---
readme.md | 11 +++++++++
symbol-overlay.el | 74 +++++++++++++++++++++++++++++++++----------------------
2 files changed, 55 insertions(+), 30 deletions(-)
diff --git a/readme.md b/readme.md
index 9d42a985ac..354c0e94b5 100644
--- a/readme.md
+++ b/readme.md
@@ -9,6 +9,10 @@ Highlight symbols with overlays while providing a keymap for
various operations
What's New!
---
+### 20170826:
+
+`symbol-overlay-toggle-in-scope` now affects both global and in-scope
highlighting. `symbol-overlay-rename` now uses the original symbol name as the
initial text in minibuffer. New command `symbol-overlay-count` for counting
symbol at point. And other improvements.
+
### 20170426:
Minor-mode `symbol-overlay-mode` for auto-highlighting is now enabled.
@@ -81,3 +85,10 @@ Default key-bindings defined in `symbol-overlay-map`:
You can re-bind the commands to any keys you prefer by simply writing
(define-key symbol-overlay-map (kbd "your-prefer-key") 'any-command)
+
+Or you may prefer to overwrite the keymap
+
+ (let ((map (make-sparse-keymap)))
+ (define-key map (kbd "key1") 'command-1)
+ (define-key map (kbd "key2") 'command-2)
+ (setq symbol-overlay-map map))
diff --git a/symbol-overlay.el b/symbol-overlay.el
index a15d5361bc..e986e71609 100644
--- a/symbol-overlay.el
+++ b/symbol-overlay.el
@@ -156,7 +156,7 @@ If NOERROR is non-nil, just return nil when no symbol is
found."
"Get SYMBOL's associated list in `symbol-overlay-keywords-alist'."
(assoc symbol symbol-overlay-keywords-alist))
-(defun symbol-overlay-remove (keyword)
+(defun symbol-overlay-maybe-remove (keyword)
"Delete the KEYWORD list and all its overlays."
(when keyword
(mapc 'delete-overlay (symbol-overlay-get-list (car keyword)))
@@ -172,7 +172,7 @@ If NOERROR is non-nil, just return nil when no symbol is
found."
(defun symbol-overlay-narrow (scope &optional window)
"Narrow to a specific region.
-Region might be current scope or displayed window or a specific one,
+Region might be current scope or displayed window,
depending on SCOPE and WINDOW."
(if scope
(let ((pt (point))
@@ -207,7 +207,7 @@ depending on SCOPE and WINDOW."
(mapc 'delete-overlay (symbol-overlay-get-list ""))
(setq symbol-overlay-temp-symbol nil))
-(defun symbol-overlay-put-temp ()
+(defun symbol-overlay-maybe-put-temp ()
"Highlight symbol at point when there are more than 2 occurrences.
This only effects symbols in the current displayed window."
(when symbol-overlay-mode
@@ -237,7 +237,7 @@ This only effects symbols in the current displayed window."
(and symbol-overlay-timer (cancel-timer symbol-overlay-timer))
(setq symbol-overlay-timer
(and value (> value 0)
- (run-with-idle-timer value t 'symbol-overlay-put-temp))))
+ (run-with-idle-timer value t 'symbol-overlay-maybe-put-temp))))
(defun symbol-overlay-post-command ()
"Installed on `post-command-hook'."
@@ -264,7 +264,7 @@ If SCOPE is non-nil, put overlays only on occurrences in
scope.
If KEYWORD is non-nil, remove it then use its color on new overlays."
(let* ((case-fold-search nil)
(limit (length symbol-overlay-colors))
- (color (or (symbol-overlay-remove keyword)
+ (color (or (symbol-overlay-maybe-remove keyword)
(elt symbol-overlay-colors (random limit))))
(alist symbol-overlay-keywords-alist)
(colors (mapcar 'cddr alist))
@@ -272,7 +272,7 @@ If KEYWORD is non-nil, remove it then use its color on new
overlays."
(if (< (length alist) limit)
(while (seq-position colors color)
(setq color (elt symbol-overlay-colors (random limit))))
- (setq color (symbol-overlay-remove (car (last alist)))))
+ (setq color (symbol-overlay-maybe-remove (car (last alist)))))
(and symbol-overlay-temp-symbol (symbol-overlay-remove-temp))
(save-excursion
(save-restriction
@@ -284,7 +284,7 @@ If KEYWORD is non-nil, remove it then use its color on new
overlays."
(push keyword symbol-overlay-keywords-alist)
keyword))
-(defun symbol-overlay-count (keyword &optional show-color)
+(defun symbol-overlay-maybe-count (keyword &optional show-color)
"Show the number of KEYWORD's occurrences.
If SHOW-COLOR is non-nil, display the color used by current overlay."
(when keyword
@@ -308,14 +308,23 @@ If SHOW-COLOR is non-nil, display the color used by
current overlay."
(keyword (symbol-overlay-assoc symbol)))
(if keyword
(if (symbol-overlay-maybe-reput symbol keyword)
- (symbol-overlay-count keyword)
- (symbol-overlay-remove keyword)
- (symbol-overlay-put-temp))
+ (symbol-overlay-maybe-count keyword)
+ (symbol-overlay-maybe-remove keyword)
+ (symbol-overlay-maybe-put-temp))
(and (looking-at-p "\\_>") (backward-char))
- (symbol-overlay-count
+ (symbol-overlay-maybe-count
(symbol-overlay-put-all symbol symbol-overlay-scope)
t)))))
+;;;###autoload
+(defun symbol-overlay-count ()
+ "Show count of symbol at point."
+ (interactive)
+ (unless (minibufferp)
+ (let* ((symbol (symbol-overlay-get-symbol))
+ (keyword (symbol-overlay-assoc symbol)))
+ (symbol-overlay-maybe-count keyword))))
+
;;;###autoload
(defun symbol-overlay-remove-all ()
"Remove all highlighted symbols in the buffer."
@@ -344,24 +353,29 @@ If SHOW-COLOR is non-nil, display the color used by
current overlay."
(keyword (symbol-overlay-assoc symbol)))
(if keyword
(let ((scope (not (cadr keyword))))
- (symbol-overlay-count (symbol-overlay-put-all symbol scope
keyword))
+ (symbol-overlay-maybe-count (symbol-overlay-put-all symbol scope
keyword))
(setq symbol-overlay-scope scope))
(setq symbol-overlay-scope (not symbol-overlay-scope))))))
-(defun symbol-overlay-maybe-reput (&optional symbol keyword)
- (let* ((symbol (or symbol (symbol-overlay-get-symbol)))
- (keyword (or keyword (symbol-overlay-assoc symbol))))
- (unless (seq-find #'(lambda (ov)
- (string= (overlay-get ov 'symbol) symbol))
- (overlays-at (car (bounds-of-thing-at-point 'symbol))))
- (symbol-overlay-put-all symbol t keyword))))
+(defun symbol-overlay-maybe-reput (symbol keyword)
+ "Put overlays on SYMBOL that is not highlighted in scope.
+KEYWORD provides the scope information."
+ (when (and (cadr keyword)
+ (not (seq-find #'(lambda (ov)
+ (string= (overlay-get ov 'symbol) symbol))
+ (overlays-at
+ (car (bounds-of-thing-at-point 'symbol))))))
+ (symbol-overlay-put-all symbol t keyword)))
;;;###autoload
(defun symbol-overlay-echo-mark ()
"Jump back to the mark."
(interactive)
- (let ((pt (mark))) (and pt (goto-char pt)))
- (symbol-overlay-maybe-reput))
+ (let* ((pt (mark))
+ (symbol (symbol-overlay-get-symbol))
+ (keyword (symbol-overlay-assoc symbol)))
+ (and pt (goto-char pt))
+ (symbol-overlay-maybe-reput symbol keyword)))
(defun symbol-overlay-jump-call (jump-function dir)
"A general jumping process during which JUMP-FUNCTION is called to jump.
@@ -374,9 +388,8 @@ DIR must be 1 or -1."
(if keyword
(progn
(symbol-overlay-maybe-reput symbol keyword)
- (symbol-overlay-count keyword))
- (symbol-overlay-mode)
- (symbol-overlay-put-temp)))))
+ (symbol-overlay-maybe-count keyword))
+ (symbol-overlay-mode)))))
(defun symbol-overlay-basic-jump (symbol dir)
"Jump to SYMBOL's next location in the direction DIR. DIR must be 1 or -1."
@@ -440,7 +453,7 @@ DIR must be 1 or -1."
" symbols")))
(push-mark nil t)
(goto-char (overlay-start (car list)))
- (symbol-overlay-count
+ (symbol-overlay-maybe-count
(symbol-overlay-assoc (symbol-overlay-get-symbol))))))
;;;###autoload
@@ -482,14 +495,14 @@ DIR must be 1 or -1."
new (symbol-overlay-get-symbol txt)
defaults (cons symbol txt))
(unless (string= new symbol)
- (symbol-overlay-remove (symbol-overlay-assoc new))
+ (symbol-overlay-maybe-remove (symbol-overlay-assoc new))
(setq keyword (symbol-overlay-put-all new scope keyword))
(query-replace-regexp symbol txt)
(setq query-replace-defaults
(if (< emacs-major-version 25) `,defaults `(,defaults))))
(when (string= new (symbol-overlay-get-symbol nil t))
(beginning-of-thing 'symbol)
- (symbol-overlay-count keyword)))))
+ (symbol-overlay-maybe-count keyword)))))
;;;###autoload
(defun symbol-overlay-rename ()
@@ -503,10 +516,11 @@ DIR must be 1 or -1."
txt new)
(beginning-of-thing 'symbol)
(push-mark nil t)
- (setq txt (read-string (concat "Rename" (and scope " in scope") ": "))
+ (setq txt (read-string (concat "Rename" (and scope " in scope") ": ")
+ (substring symbol 3 -3))
new (symbol-overlay-get-symbol txt))
(unless (string= new symbol)
- (symbol-overlay-remove (symbol-overlay-assoc new))
+ (symbol-overlay-maybe-remove (symbol-overlay-assoc new))
(save-excursion
(save-restriction
(symbol-overlay-narrow scope)
@@ -515,7 +529,7 @@ DIR must be 1 or -1."
(while (re-search-forward symbol nil t) (replace-match txt t)))))
(setq keyword (symbol-overlay-put-all new scope keyword)))
(when (string= new (symbol-overlay-get-symbol nil t))
- (symbol-overlay-count keyword)))))
+ (symbol-overlay-maybe-count keyword)))))
(defun symbol-overlay-refresh (beg end len)
"Refresh overlays. Installed on `after-change-functions'.
- [nongnu] elpa/symbol-overlay 909ea9074b 070/152: Add missing parens in face definition, (continued)
- [nongnu] elpa/symbol-overlay 909ea9074b 070/152: Add missing parens in face definition, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 7d77f2e962 091/152: Declare symbol-overlay-ignore-functions's custom type, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay ccf791377a 109/152: Preserve highlighting after buffer was reverted, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 8b8888c8b2 123/152: Merge pull request #54 from dakra/ignore-java, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 39f772b531 137/152: Prefer to check for selected window in timer callback, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay f2734ce633 132/152: Merge pull request #60 from cireu/fix-percentage-prefix-symbol, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay a6683f1089 003/152: init, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 0a03aecead 041/152: fix errors when renaming in scope, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay e19f7adcdf 062/152: Merge pull request #7 from Bad-ptr/patch-1, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay dd7b910402 065/152: Use defvar-local to avoid needing make-variable-buffer-local, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 6c7ec584b6 074/152: 170826,
ELPA Syncer <=
- [nongnu] elpa/symbol-overlay 4f60487e45 124/152: Add new variable symbol-overlay-inhibit-map, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 8096a684c2 129/152: Prefer "Rename to" in prompt for symbol renaming, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 35bd60ead7 127/152: Don't make symbol-overlay-inhibit-map local by default, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 4528aa0e62 130/152: Link to transient snippet from README, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 0707b8cc3e 146/152: Cancel a buffer’s ‘symbol-overlay-cancel-timer’ when it is killed, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay d08c33dc85 149/152: Merge pull request #79 from minad/lexical-binding, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 7ddebd54d3 107/152: Consistently use spaces for indentation, ELPA Syncer, 2022/07/07