[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/anzu 9b772435ea 090/288: Support backward replace
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/anzu 9b772435ea 090/288: Support backward replace |
Date: |
Thu, 6 Jan 2022 03:58:43 -0500 (EST) |
branch: elpa/anzu
commit 9b772435eadb20232a729e077c0d0f8a40bfd82f
Author: Syohei YOSHIDA <syohex@gmail.com>
Commit: Syohei YOSHIDA <syohex@gmail.com>
Support backward replace
---
anzu.el | 47 ++++++++++++++++++++++++++++++++++-------------
1 file changed, 34 insertions(+), 13 deletions(-)
diff --git a/anzu.el b/anzu.el
index 09b2b9f3ef..4386aa80f3 100644
--- a/anzu.el
+++ b/anzu.el
@@ -473,12 +473,14 @@
(let ((bound (bounds-of-thing-at-point thing)))
(and bound (cdr bound))))
-(defun anzu--region-begin (use-region thing)
+(defun anzu--region-begin (use-region thing backward)
(if thing
(or (anzu--thing-begin thing) (point))
(if use-region
(region-beginning)
- (point))))
+ (if backward
+ (point-min)
+ (point)))))
(defun anzu--region-end (use-region thing)
(if thing
@@ -492,14 +494,31 @@
((and at-cursor (not thing)) 'symbol)
(t nil)))
-(defun anzu--query-replace-common (use-regexp &optional at-cursor thing)
+(defun anzu--replace-backward-p (prefix)
+ ;; This variable is introduced at Emacs 24.4, I should fix this variable to
+ ;; version variable
+ (and (boundp 'list-matching-lines-prefix-face)
+ (< prefix 0)))
+
+(defun anzu--construct-perform-replace-arguments (from to delimited beg end
backward)
+ (if backward
+ (list from to t t delimited nil nil beg end backward)
+ (list from to t t delimited nil nil beg end)))
+
+(defun anzu--construct-query-replace-arguments (from to delimited beg end
backward)
+ (if backward
+ (list from to delimited beg end backward)
+ (list from to delimited beg end)))
+
+(defun anzu--query-replace-common (use-regexp &optional at-cursor thing
prefix-arg)
(anzu--cons-mode-line 'replace)
(let* ((use-region (use-region-p))
+ (backward (anzu--replace-backward-p prefix-arg))
(overlay-limit (anzu--overlay-limit))
- (beg (anzu--region-begin use-region (anzu--begin-thing at-cursor
thing)))
+ (beg (anzu--region-begin use-region (anzu--begin-thing at-cursor
thing) backward))
(end (anzu--region-end use-region thing))
(prompt (anzu--query-prompt use-region use-regexp))
- (delimited current-prefix-arg)
+ (delimited (and current-prefix-arg (not (eq current-prefix-arg '-))))
(curbuf (current-buffer))
(clear-overlay nil))
(when (and anzu-deactivate-region use-region)
@@ -517,8 +536,10 @@
(anzu--clear-overlays curbuf beg end)
(setq clear-overlay t)
(if use-regexp
- (perform-replace from to t t delimited nil nil beg end)
- (query-replace from to delimited beg end)))
+ (apply 'perform-replace
(anzu--construct-perform-replace-arguments
+ from to delimited beg end backward))
+ (apply 'query-replace (anzu--construct-query-replace-arguments
+ from to delimited beg end backward))))
(progn
(unless clear-overlay
(anzu--clear-overlays curbuf beg end))
@@ -536,14 +557,14 @@
(anzu--query-replace-common t t anzu-replace-at-cursor-thing))
;;;###autoload
-(defun anzu-query-replace ()
- (interactive)
- (anzu--query-replace-common nil))
+(defun anzu-query-replace (arg)
+ (interactive "p")
+ (anzu--query-replace-common nil nil nil arg))
;;;###autoload
-(defun anzu-query-replace-regexp ()
- (interactive)
- (anzu--query-replace-common t))
+(defun anzu-query-replace-regexp (arg)
+ (interactive "p")
+ (anzu--query-replace-common t nil nil arg))
(provide 'anzu)
;;; anzu.el ends here
- [nongnu] elpa/anzu 4cfbddbc07 020/288: Reset match count variables in isearch-mode-end-hook, (continued)
- [nongnu] elpa/anzu 4cfbddbc07 020/288: Reset match count variables in isearch-mode-end-hook, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu de70e2fa4a 031/288: Enable mode unconditionally in examples, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 2b88e1fcbc 021/288: Improve for not regexp search commands, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 5e6bad85d4 036/288: bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 169cf55674 044/288: Use previous result if regexp validation is failed, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu d256c967f3 052/288: Fix message in mode-line at replace command, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 413bd09ebc 079/288: Fix different behavior from query-replace-regexp, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu b310647932 085/288: Add separator parameter of 'to' string, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 047c5eee99 083/288: add anzu replace command screencast, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 630d663238 087/288: Fix invalid return type, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 9b772435ea 090/288: Support backward replace,
ELPA Syncer <=
- [nongnu] elpa/anzu 81b4eb6e29 093/288: Fix increasing anzu information in mode-line issue(#13), ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 1ea6980019 106/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu caf83591e4 134/288: Merge pull request #28 from syohex/improve-replace-mode-line, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 5d209726cd 156/288: Merge pull request #36 from syohex/case-sensitive-for-at-cursor-command, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu ee53798dc2 160/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 1c2705bb2c 164/288: Merge pull request #38 from syohex/improve-replacement, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu d4dcd76f47 190/288: Merge pull request #48 from syohex/improve-history, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 370b9f162f 181/288: Merge pull request #45 from syohex/fix-zero-width-replacement, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 8a1eb22317 174/288: Merge pull request #42 from syohex/fix-replace-command-bug, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu a1f56b6dad 193/288: Merge pull request #50 from syohex/fix-default-input-49, ELPA Syncer, 2022/01/06