[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/anzu 349e772b84 019/288: Fix #5 issue
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/anzu 349e772b84 019/288: Fix #5 issue |
Date: |
Thu, 6 Jan 2022 03:58:35 -0500 (EST) |
branch: elpa/anzu
commit 349e772b84033969f82431b0eb560980dec5cb6e
Author: Syohei YOSHIDA <syohex@gmail.com>
Commit: Syohei YOSHIDA <syohex@gmail.com>
Fix #5 issue
If input is anchor such as '^', '$', matched count loop makes infinite loop.
---
anzu.el | 39 ++++++++++++++++++++++++++-------------
1 file changed, 26 insertions(+), 13 deletions(-)
diff --git a/anzu.el b/anzu.el
index f38762c70b..0e332dc5dd 100644
--- a/anzu.el
+++ b/anzu.el
@@ -71,20 +71,33 @@
(defvar anzu--last-isearch-string nil)
(defvar anzu--cached-positions nil)
+(defun anzu--validate-regexp (regexp)
+ (condition-case err
+ (progn
+ (string-match-p regexp "")
+ t)
+ (invalid-regexp nil)))
+
(defun anzu--search-all-position (str)
- (save-excursion
- (goto-char (point-min))
- (let ((positions '())
- (count 0)
- (search-func (if (and anzu-use-migemo migemo-isearch-enable-p)
- 'migemo-forward
- 're-search-forward)))
- (while (funcall search-func str nil t)
- (push (cons (match-beginning 0) (match-end 0)) positions)
- (incf count))
- (let ((result (cons count (reverse positions))))
- (setq anzu--cached-positions (copy-sequence result))
- result))))
+ (when (anzu--validate-regexp str)
+ (save-excursion
+ (goto-char (point-min))
+ (let ((positions '())
+ (count 0)
+ (finish nil)
+ (search-func (if (and anzu-use-migemo migemo-isearch-enable-p)
+ 'migemo-forward
+ 're-search-forward)))
+ (while (and (not finish) (funcall search-func str nil t))
+ (push (cons (match-beginning 0) (match-end 0)) positions)
+ (incf count)
+ (when (= (match-beginning 0) (match-end 0)) ;; Case of anchor such
as "^"
+ (if (eobp)
+ (setq finish t)
+ (forward-char 1))))
+ (let ((result (cons count (reverse positions))))
+ (setq anzu--cached-positions (copy-sequence result))
+ result)))))
(defun anzu--where-is-here (positions here)
(loop for (start . end) in positions
- [nongnu] elpa/anzu 0418c2b6d4 041/288: Update document, (continued)
- [nongnu] elpa/anzu 0418c2b6d4 041/288: Update document, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 218a63ce47 015/288: Highlight code and add screenshot explanation, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 7b3d95d495 183/288: Support Emacs 24 and 25, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 6b217a457f 182/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 3c178f75f3 197/288: Fix matching a literal string, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu b486075ab4 204/288: Update requirement package version, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 5ee99678ca 229/288: Remove needless attribute, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 8667be50aa 240/288: Merge pull request #73 from lunaryorn/patch-1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu acfd0a49de 246/288: Threshold has to be nil or number., ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 532db96e34 026/288: Add doc-string, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 349e772b84 019/288: Fix #5 issue,
ELPA Syncer <=
- [nongnu] elpa/anzu 4cc1b6c9e0 030/288: Merge pull request #7 from bbatsov/doc-improvement, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 16fc5810b3 029/288: Merge pull request #6 from bbatsov/fix-comp-warning, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 30d34084eb 039/288: bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu fd99f06af9 042/288: add screenshot for threshold, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 168d8c7f73 043/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu ff4393fac5 050/288: Add feature that highlight replaced texts, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu e2e8d12905 058/288: Update face documentation, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu ebfbfe7e01 060/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu a8f75879a8 063/288: Don't evaluate not regexp replacement, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu f503b785ef 065/288: Update about anzu-query-replace-at-cursor, ELPA Syncer, 2022/01/06