[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/symbol-overlay 0a03aecead 041/152: fix errors when renamin
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/symbol-overlay 0a03aecead 041/152: fix errors when renaming in scope |
Date: |
Thu, 7 Jul 2022 12:04:10 -0400 (EDT) |
branch: elpa/symbol-overlay
commit 0a03aecead1c11355fe4be61d2f6339f6116bc32
Author: wolray <290061869@qq.com>
Commit: wolray <290061869@qq.com>
fix errors when renaming in scope
---
symbol-overlay.el | 39 +++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/symbol-overlay.el b/symbol-overlay.el
index 7f4b00ebec..5505805c91 100644
--- a/symbol-overlay.el
+++ b/symbol-overlay.el
@@ -152,8 +152,8 @@ If NOERROR is non-nil, just return nil when keyword is not
found."
(defun symbol-overlay-narrow (scope)
"Narrow to a specific region when SCOPE is non-nil.
-Use default method `narrow-to-defun' or
-`symbol-overlay-narrow-function' if specified."
+Use default method `narrow-to-defun' or `symbol-overlay-narrow-function'
+if specified."
(when scope
(let ((f symbol-overlay-narrow-function)
region)
@@ -176,11 +176,10 @@ Use COLOR as the overlay's background color."
"Put overlays on all occurrences of SYMBOL in the buffer.
The background color is randomly picked from `symbol-overlay-colors'.
If SCOPE is non-nil, put overlays only on occurrences in scope.
-If KEYWORD is non-nil, remove it and use its color for new overlays."
+If KEYWORD is non-nil, use its color on new overlays."
(let* ((case-fold-search nil)
(limit (length symbol-overlay-colors))
- (color (or (symbol-overlay-remove keyword)
- (elt symbol-overlay-colors (random limit))))
+ (color (or (cddr keyword) (elt symbol-overlay-colors (random limit))))
(colors (mapcar 'cddr symbol-overlay-keywords-alist))
p)
(if (< (length symbol-overlay-keywords-alist) limit)
@@ -253,6 +252,7 @@ If SHOW-COLOR is non-nil, display the color used by current
overlay."
(save-restriction
(symbol-overlay-narrow scope)
(and scope (/= pt (point)) (user-error "Wrong scope"))
+ (symbol-overlay-remove keyword)
(symbol-overlay-count
(symbol-overlay-put-all symbol scope keyword)))))))
@@ -264,7 +264,7 @@ If SHOW-COLOR is non-nil, display the color used by current
overlay."
(defun symbol-overlay-echo-mark ()
"Jump back to the mark `symbol-overlay-mark'."
(interactive)
- (and (not (minibufferp)) symbol-overlay-mark (goto-char
symbol-overlay-mark)))
+ (or (minibufferp) (not symbol-overlay-mark) (goto-char symbol-overlay-mark)))
(defun symbol-overlay-jump-call (jump-function dir)
"A general jumping process during which JUMP-FUNCTION is called to jump.
@@ -281,6 +281,7 @@ DIR must be 1 or -1."
(defun symbol-overlay-basic-jump (symbol dir)
"Jump to SYMBOL's next location in the direction DIR. DIR must be 1 or -1."
(let ((case-fold-search nil)
+ (bounds (bounds-of-thing-at-point 'symbol))
(offset (- (point) (if (> dir 0) (match-end 0) (match-beginning 0))))
target)
(goto-char (- (point) offset))
@@ -376,11 +377,10 @@ DIR must be 1 or -1."
new)
(beginning-of-thing 'symbol)
(setq symbol-overlay-mark (point)
- new (funcall replace-function symbol scope))
+ new (funcall replace-function keyword scope))
(unless (string= new symbol)
- (symbol-overlay-remove (symbol-overlay-assoc new t))
- (setq keyword (symbol-overlay-put-all
- new scope (symbol-overlay-assoc symbol))))
+ (symbol-overlay-remove (symbol-overlay-assoc new t)))
+ (setq keyword (symbol-overlay-put-all new scope keyword))
(when (string= new (symbol-overlay-get-symbol nil t))
(beginning-of-thing 'symbol)
(symbol-overlay-count keyword)))))
@@ -390,23 +390,25 @@ DIR must be 1 or -1."
"Query replace symbol at point."
(interactive)
(symbol-overlay-replace-call
- '(lambda (symbol scope)
+ '(lambda (keyword scope)
(and scope (user-error "Query replace is invalid in scope"))
- (let* ((new (read-string "Replacement: "))
- (defaults (cons symbol new))
- (inhibit-modification-hooks t))
+ (let* ((symbol (car keyword))
+ (new (read-string "Replacement: "))
+ (defaults (cons symbol new)))
+ (symbol-overlay-remove keyword)
(query-replace-regexp symbol new)
(setq query-replace-defaults
- (if (< emacs-major-version 25) `,defaults `(,defaults))))
- (symbol-overlay-get-symbol new))))
+ (if (< emacs-major-version 25) `,defaults `(,defaults)))
+ (symbol-overlay-get-symbol new)))))
;;;###autoload
(defun symbol-overlay-rename ()
"Rename symbol at point on all its occurrences."
(interactive)
(symbol-overlay-replace-call
- '(lambda (symbol scope)
- (let ((new (read-string (concat "Rename"
+ '(lambda (keyword scope)
+ (let ((symbol (car keyword))
+ (new (read-string (concat "Rename"
(and scope " in scope")
": ")))
(inhibit-modification-hooks t))
@@ -414,6 +416,7 @@ DIR must be 1 or -1."
(save-restriction
(symbol-overlay-narrow scope)
(goto-char (point-min))
+ (symbol-overlay-remove keyword)
(while (re-search-forward symbol nil t) (replace-match new))))
(symbol-overlay-get-symbol new)))))
- [nongnu] elpa/symbol-overlay 4a2d6b0e0a 010/152: edit the summary, (continued)
- [nongnu] elpa/symbol-overlay 4a2d6b0e0a 010/152: edit the summary, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 068c6c801a 053/152: narrow to paragraph when scope is not found, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 1c40cd921d 072/152: add symbol-overlay-remove-all to before-revert-hook, ELPA Syncer, 2022/07/07
- [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 <=
- [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, 2022/07/07
- [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