[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/anzu bb3f7b63ef 059/288: Implement anzu-query-replace-at-c
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/anzu bb3f7b63ef 059/288: Implement anzu-query-replace-at-cursor |
Date: |
Thu, 6 Jan 2022 03:58:40 -0500 (EST) |
branch: elpa/anzu
commit bb3f7b63ef6ed2e7f598a4f7a96ac6c8010da1be
Author: Syohei YOSHIDA <syohex@gmail.com>
Commit: Syohei YOSHIDA <syohex@gmail.com>
Implement anzu-query-replace-at-cursor
---
anzu.el | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/anzu.el b/anzu.el
index 69d866d166..20f9ef5d35 100644
--- a/anzu.el
+++ b/anzu.el
@@ -39,6 +39,8 @@
(require 'cl)
(defvar migemo-isearch-enable-p))
+(require 'thingatpt)
+
(defgroup anzu nil
"Show searched position in mode-line"
:group 'isearch)
@@ -405,18 +407,34 @@
(forward-line 1)
(point)))
-(defun anzu--query-replace-common (use-regexp)
+(defun anzu--query-from-at-cursor (prompt buf beg end overlay-limit)
+ (let ((symbol (thing-at-point 'symbol)))
+ (setq anzu--total-matched
+ (anzu--count-matched buf symbol beg end nil overlay-limit))
+ (force-mode-line-update)
+ symbol))
+
+(defun anzu--symbol-begin ()
+ (let ((bound (bounds-of-thing-at-point 'symbol)))
+ (and bound (car bound))))
+
+(defun anzu--query-replace-common (use-regexp &optional at-cursor)
(anzu--cons-mode-line 'replace)
(let* ((use-region (use-region-p))
(overlay-limit (anzu--overlay-limit))
(beg (if use-region (region-beginning) (point)))
(end (if use-region (region-end) (point-max)))
(prompt (anzu--query-prompt use-region use-regexp))
+ (symbol-beg (and at-cursor (anzu--symbol-begin)))
(delimited current-prefix-arg)
(curbuf (current-buffer))
(clear-overlay nil))
(unwind-protect
- (let* ((from (anzu--query-from-string prompt beg end use-regexp
overlay-limit))
+ (let* ((from (if symbol-beg
+ (progn
+ (setq beg symbol-beg)
+ (anzu--query-from-at-cursor prompt curbuf beg end
overlay-limit))
+ (anzu--query-from-string prompt beg end use-regexp
overlay-limit)))
(to (if (consp from)
(prog1 (cdr from) (setq from (car from)))
(anzu--query-replace-read-to
@@ -432,6 +450,11 @@
(anzu--reset-mode-line)
(force-mode-line-update)))))
+;;;###autoload
+(defun anzu-query-replace-at-cursor ()
+ (interactive)
+ (anzu--query-replace-common nil t))
+
;;;###autoload
(defun anzu-query-replace ()
(interactive)
- [nongnu] elpa/anzu 9fc916b6de 131/288: Fix for symbol search and toggle in isearch-mode, (continued)
- [nongnu] elpa/anzu 9fc916b6de 131/288: Fix for symbol search and toggle in isearch-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 0bdbfcb209 138/288: Improve case when input does not match anything in visiable range(#30), ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu af40f91a98 140/288: Merge pull request #31 from syohex/no-match-case, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 04ac39641e 143/288: Merge pull request #32 from syohex/fix-at-cursor-beginning-point, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu c61f6734b1 152/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 3adcdab743 163/288: Correct saving replacement history, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 9064fc7892 169/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 75bd476be1 045/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 8622c1fa93 049/288: Fix typo, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu b8d328805a 053/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu bb3f7b63ef 059/288: Implement anzu-query-replace-at-cursor,
ELPA Syncer <=
- [nongnu] elpa/anzu 7c56f15f72 068/288: add deactivate-region flag when using region, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu b6672c9bf2 061/288: Improve overlay replace text, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 0e7873a3e7 075/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 68300bc949 078/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 264c36d135 076/288: Fix overlay is not put if match-string is 0 length, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 8bde8ee114 088/288: Update comment, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 29a07403a6 091/288: Merge pull request #12 from syohex/support-backward-replace, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 368a4ebe8c 096/288: Fix no prefix number case, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu a36458386d 107/288: Don't show default replacement in prompt, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu ef489aadb2 118/288: Fix replacement issue(#22), ELPA Syncer, 2022/01/06