[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/anzu 2bcd549c5a 054/288: Re-factoring: reduce global varia
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/anzu 2bcd549c5a 054/288: Re-factoring: reduce global variables |
Date: |
Thu, 6 Jan 2022 03:58:39 -0500 (EST) |
branch: elpa/anzu
commit 2bcd549c5a8117f60f2c8385336730d19ebc0434
Author: Syohei YOSHIDA <syohex@gmail.com>
Commit: Syohei YOSHIDA <syohex@gmail.com>
Re-factoring: reduce global variables
---
anzu.el | 47 ++++++++++++++++++++---------------------------
1 file changed, 20 insertions(+), 27 deletions(-)
diff --git a/anzu.el b/anzu.el
index 564e3b3fdd..15d1ebdc93 100644
--- a/anzu.el
+++ b/anzu.el
@@ -103,9 +103,6 @@
(defvar anzu--last-command nil)
(defvar anzu--state nil)
(defvar anzu--cached-count 0)
-(defvar anzu--replace-begin nil)
-(defvar anzu--replace-end nil)
-(defvar anzu--window-height 0)
(defun anzu--validate-regexp (regexp)
(condition-case err
@@ -258,23 +255,23 @@
(let ((case-fold-search nil))
(not (string-match-p "[A-Z]" input))))
-(defun anzu--count-matched (buf str use-regexp)
+(defun anzu--count-matched (buf str replace-beg replace-end use-regexp
window-height)
(when (not use-regexp)
(setq str (regexp-quote str)))
(if (not (anzu--validate-regexp str))
anzu--cached-count
(with-current-buffer buf
(save-excursion
- (let* ((overlay-beg anzu--replace-begin)
+ (let* ((overlay-beg replace-beg)
(overlay-end (min (save-excursion
- (forward-line anzu--window-height)
+ (forward-line window-height)
(point))
- anzu--replace-end)))
- (goto-char anzu--replace-begin)
+ replace-end)))
+ (goto-char overlay-beg)
(let ((count 0)
(finish nil)
(case-fold-search (anzu--case-fold-search str)))
- (while (and (not finish) (re-search-forward str anzu--replace-end
t))
+ (while (and (not finish) (re-search-forward str replace-end t))
(incf count)
(let ((beg (match-beginning 0))
(end (match-end 0)))
@@ -286,13 +283,13 @@
(anzu--add-overlay beg end)))))
(setq anzu--cached-count count)))))))
-(defun anzu--check-minibuffer-input (buf use-regexp)
- (let ((content (minibuffer-contents)))
- (let ((matched (if (string= content "")
- (setq anzu--cached-count 0)
- (anzu--count-matched buf content use-regexp))))
- (setq anzu--total-matched matched)
- (force-mode-line-update))))
+(defun anzu--check-minibuffer-input (buf beg end use-regexp window-height)
+ (let* ((content (minibuffer-contents))
+ (matched (if (string= content "")
+ (setq anzu--cached-count 0)
+ (anzu--count-matched buf content beg end use-regexp
window-height))))
+ (setq anzu--total-matched matched)
+ (force-mode-line-update)))
(defun anzu--clear-overlays (buf beg end)
(with-current-buffer buf
@@ -300,7 +297,7 @@
(when (overlay-get ov 'anzu-replace)
(delete-overlay ov)))))
-(defun anzu--read-from-string (prompt use-regexp)
+(defun anzu--read-from-string (prompt beg end use-regexp window-height)
(let ((curbuf (current-buffer))
(timer nil))
(unwind-protect
@@ -313,7 +310,8 @@
(anzu--clear-overlays curbuf nil nil)
(with-selected-window (or
(active-minibuffer-window)
(minibuffer-window))
- (anzu--check-minibuffer-input curbuf
use-regexp))))))
+ (anzu--check-minibuffer-input
+ curbuf beg end use-regexp window-height))))))
(read-from-minibuffer (format "%s: " prompt)
nil nil nil
query-replace-from-history-variable nil t))
@@ -331,8 +329,8 @@
(message "\\t' here doesn't match a tab; to do that, just type
TAB!!")))
(sit-for 2))))
-(defun anzu--query-from-string (prompt use-regexp)
- (let ((from (anzu--read-from-string prompt use-regexp)))
+(defun anzu--query-from-string (prompt beg end use-regexp window-height)
+ (let ((from (anzu--read-from-string prompt beg end use-regexp
window-height)))
(if (and (string= from "") query-replace-defaults)
(cons (car query-replace-defaults)
(query-replace-compile-replacement
@@ -342,23 +340,18 @@
(anzu--query-validate-from-regexp from))
from)))
-(defsubst anzu--set-region-information (beg end)
- (setq anzu--replace-begin beg
- anzu--replace-end end))
-
(defun anzu--query-replace-common (use-regexp)
- (setq anzu--window-height (window-height))
(anzu--cons-mode-line 'replace)
(let* ((use-region (use-region-p))
+ (window-height (window-height))
(beg (if use-region (region-beginning) (point)))
(end (if use-region (region-end) (point-max)))
(prompt (anzu--query-prompt use-region use-regexp))
(delimited current-prefix-arg)
(curbuf (current-buffer))
(clear-overlay nil))
- (anzu--set-region-information beg end)
(unwind-protect
- (let* ((from (anzu--query-from-string prompt use-regexp))
+ (let* ((from (anzu--query-from-string prompt beg end use-regexp
window-height))
(to (if (consp from)
(prog1 (cdr from) (setq from (car from)))
(query-replace-read-to from prompt use-regexp))))
- [nongnu] elpa/anzu ff54963946 232/288: Merge pull request #67 from syohex/refactoring, (continued)
- [nongnu] elpa/anzu ff54963946 232/288: Merge pull request #67 from syohex/refactoring, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 116501bf9e 216/288: Merge pull request #62 from syohex/fix-migemo, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu a35649e401 017/288: Update document, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 84183d2a79 022/288: update document, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu f4618cd335 023/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu cc427254a0 040/288: Introduce search threshold, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 591b27621c 047/288: Merge pull request #11 from syohex/support-query-replace, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 1fc36f460c 046/288: Implement anzu-query-regexp and anzu-query-regexp, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu cdee5811bb 048/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 28953f86f9 051/288: bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 2bcd549c5a 054/288: Re-factoring: reduce global variables,
ELPA Syncer <=
- [nongnu] elpa/anzu 9a055d9b0b 056/288: Add replacement feature like evil replace, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu ce021b7234 057/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 602aa46fe7 070/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 4d50eb8274 072/288: Implement anzu-query-replace-at-cursor-thing, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu ad0d7bce91 073/288: Update document, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 5718f08dc6 066/288: Fix case fold issue, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 17b3ab244b 074/288: Fix case, no symbol at cursor, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu c324833756 080/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu f50be69c0f 082/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu eb2b4ec103 084/288: fix link, ELPA Syncer, 2022/01/06