[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iedit 3c305620ae 250/301: Optimize iedit-mode-from-isearch
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iedit 3c305620ae 250/301: Optimize iedit-mode-from-isearch |
Date: |
Mon, 10 Jan 2022 22:59:07 -0500 (EST) |
branch: elpa/iedit
commit 3c305620ae7638c0152e7ead74ca68f484052ae5
Author: victor <victorhge@gmail.com>
Commit: Victor <victorhge@gmail.com>
Optimize iedit-mode-from-isearch
Jump back if the length of the next occurrence is different.
Remove an old TODO item :)
---
iedit-lib.el | 8 ++++++--
iedit-tests.el | 30 +++++++++++++++++++++++++++++-
iedit.el | 12 +++++++-----
3 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/iedit-lib.el b/iedit-lib.el
index 21a7b36df5..ea1f87b385 100644
--- a/iedit-lib.el
+++ b/iedit-lib.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2018-09-19 11:09:54 Victor Ren>
+;; Time-stamp: <2018-11-16 14:49:24 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous rectangle refactoring
;; Version: 0.9.9.9
@@ -275,7 +275,8 @@ Return the number of occurrences."
(setq iedit-read-only-occurrences-overlays nil)
;; Find and record each occurrence's markers and add the overlay to the
occurrences
(let ((counter 0)
- (case-fold-search (not iedit-case-sensitive)))
+ (case-fold-search (not iedit-case-sensitive))
+ (length 0))
(save-excursion
(save-window-excursion
(goto-char end)
@@ -285,6 +286,9 @@ Return the number of occurrences."
(while (re-search-forward occurrence-regexp end t)
(let ((beginning (match-beginning 0))
(ending (match-end 0)))
+ (if (and (> length 0) (/= (- ending beginning) length))
+ (throw 'not-same-length 'not-same-length)
+ (setq length (- ending beginning)))
(if (text-property-not-all beginning ending 'read-only nil)
(push (iedit-make-read-only-occurrence-overlay beginning
ending)
iedit-read-only-occurrences-overlays)
diff --git a/iedit-tests.el b/iedit-tests.el
index 6b90e20078..bfcd860e4d 100644
--- a/iedit-tests.el
+++ b/iedit-tests.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2018-11-14 17:48:26 Victor Ren>
+;; Time-stamp: <2018-11-16 14:55:04 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Version: 0.9.9.9
;; X-URL: https://www.emacswiki.org/emacs/Iedit
@@ -221,6 +221,34 @@ fob")))))
(iedit-mode)
(should (null iedit-occurrences-overlays)))))
+(ert-deftest iedit-mode-start-from-isearch-regexp-test ()
+ (with-iedit-test-fixture
+"foo
+ fobar
+ foobar
+ fooobar
+ barfoo
+ foo"
+ (lambda ()
+ (iedit-mode)
+ (call-interactively 'isearch-forward-regexp)
+ (isearch-process-search-char ?f)
+ (isearch-process-search-char ?o)
+ (isearch-process-search-char ?*)
+ (isearch-process-search-char ?b)
+ (call-interactively 'iedit-mode-from-isearch)
+ (should (null iedit-occurrences-overlays))
+ (should (string= (current-message) "Matches are not the same length."))
+ (goto-char (point-min))
+ (call-interactively 'isearch-forward-regexp)
+ (isearch-process-search-char ?f)
+ (isearch-process-search-char ?o)
+ (isearch-process-search-char ?.)
+ (isearch-process-search-char ?b)
+ (call-interactively 'iedit-mode-from-isearch)
+ (should (= 1 (length iedit-occurrences-overlays)))
+ )))
+
(ert-deftest iedit-mode-last-local-occurrence-test ()
(with-iedit-test-fixture
"foo
diff --git a/iedit.el b/iedit.el
index 8612abfcc4..d9097e87c7 100644
--- a/iedit.el
+++ b/iedit.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2018-11-14 17:49:13 Victor Ren>
+;; Time-stamp: <2018-11-16 12:11:48 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous refactoring
;; Version: 0.9.9.9
@@ -441,18 +441,20 @@ Keymap used within overlays:
(if (or isearch-regexp isearch-regexp-function)
nil
(setq iedit-initial-string-local isearch-string))
- (let ((iedit-case-sensitive (not isearch-case-fold-search)))
+ (let ((iedit-case-sensitive (not isearch-case-fold-search))
+ result)
(isearch-exit)
(setq mark-active nil)
(run-hooks 'deactivate-mark-hook)
(when iedit-mode
(iedit-cleanup))
- (iedit-start regexp (point-min) (point-max))
- ;; TODO: reconsider how to avoid the loop in iedit-same-length
+ (setq result
+ (catch 'not-same-length
+ (iedit-start regexp (point-min) (point-max))))
(cond ((not iedit-occurrences-overlays)
(message "No matches found for %s" regexp)
(iedit-done))
- ((not (iedit-same-length))
+ ((equal result 'not-same-length)
(message "Matches are not the same length.")
(iedit-done)))))
- [nongnu] elpa/iedit 668ea99c51 195/301: Allow prefix for expand functions, (continued)
- [nongnu] elpa/iedit 668ea99c51 195/301: Allow prefix for expand functions, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 007a6f9c28 206/301: check if mc present, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 7885f4beda 178/301: iedit-restrict-current-line resets expand state, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 79d0f4f3dc 155/301: Merge pull request #32 from mbneedham/master, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit df2de42fa1 149/301: Remove test-util.el, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 83c037d678 156/301: Fix infinite loop problem in iedit-rect-mode, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit b95c35107a 176/301: Merge branch 'master' of github.com:victorhge/iedit, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 0d6193362d 144/301: Follow error convention, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit c2763baaf6 168/301: Do not enable iedit from a failing isearch, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 4e8b9453ac 261/301: Update occurrences in `post-command-hook', ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 3c305620ae 250/301: Optimize iedit-mode-from-isearch,
ELPA Syncer <=
- [nongnu] elpa/iedit 85fad4a3b7 233/301: Merge pull request #73 from lionel-/feature-mode-line, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit a7f5ed7cf9 257/301: Turn off iedit-mode at running `iedit-mode-toggle-on-function` twice, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 5050b7e88e 260/301: Fix a failed test case when Emacs is compiled without GUI, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit afca4e6bbf 213/301: Rename hook functions, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 7ab2509231 225/301: Expand iedit-regexp-quote with passthrough, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit efe98b2015 248/301: fix `iedit-mode-on-fuction problem, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 01fa1e5925 217/301: Fix error if sgml-electric-tag-pair-mode not bound, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit d7db0e5d19 279/301: Replace `iedit-lib-aborting-hook' with a callback function, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit dbf3f9a0e3 290/301: Add iedit-update-key-bindings, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 351bee5e0d 292/301: New iedit-record-changes, ELPA Syncer, 2022/01/10