[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/anzu 29a07403a6 091/288: Merge pull request #12 from syohe
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/anzu 29a07403a6 091/288: Merge pull request #12 from syohex/support-backward-replace |
Date: |
Thu, 6 Jan 2022 03:58:43 -0500 (EST) |
branch: elpa/anzu
commit 29a07403a62192e9634e549ae62c573aa8ddefb5
Merge: 31f1f8b817 9b772435ea
Author: Syohei YOSHIDA <syohex@gmail.com>
Commit: Syohei YOSHIDA <syohex@gmail.com>
Merge pull request #12 from syohex/support-backward-replace
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 75bd476be1 045/288: Bump up version and update Changes, (continued)
- [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, 2022/01/06
- [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 <=
- [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
- [nongnu] elpa/anzu 497864542b 120/288: Bumpup version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu cf07d6a0ec 125/288: Implement specified lines replacement, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 09cc87ad9b 228/288: Merge pull request #66 from syohex/replace-threshold, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu b3b912013d 225/288: Add custom variable of replacement threshold, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 380f5fd232 198/288: Merge pull request #53 from kosh04/fix-literal-match, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 38d49e3664 276/288: Revert "Fix issue #93", ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 799f26ee0e 260/288: Merge pull request #86 from syohex/no-match-face, ELPA Syncer, 2022/01/06