[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iedit ac51555341 282/301: New feature: ignore hidden occur
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iedit ac51555341 282/301: New feature: ignore hidden occurrences |
Date: |
Mon, 10 Jan 2022 22:59:10 -0500 (EST) |
branch: elpa/iedit
commit ac51555341163ed74423fd1aca88a56579dce10b
Author: Victor Ren <victorhge@gmail.com>
Commit: Victor <victorhge@gmail.com>
New feature: ignore hidden occurrences
Ignore hidden matches if `search-invisible' is nil.
New mode function `iedit-toggle-search-invisible'.
The behavior is borrowed from 'isearch'.
---
iedit-lib.el | 45 +++++++++++++++++++++++++++++++++++----------
iedit-tests.el | 26 +++++++++++++++++++++++++-
iedit.el | 30 +++++++++++++++++++++++++++++-
3 files changed, 89 insertions(+), 12 deletions(-)
diff --git a/iedit-lib.el b/iedit-lib.el
index 52c7f5b999..1c388e49a7 100755
--- a/iedit-lib.el
+++ b/iedit-lib.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2010 - 2019, 2020 Victor Ren
-;; Time-stamp: <2021-01-06 11:23:22 Victor Ren>
+;; Time-stamp: <2021-01-13 22:27:53 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous rectangle refactoring
;; Version: 0.9.9.9
@@ -130,6 +130,17 @@ If no-nil, matching is case sensitive. If nil and
`case-replace'
is no-nil, iedit try to preserve the case pattern of each
occurrence.")
+(defvar iedit-search-invisible search-invisible
+ "search-invisible while matching.
+Either nil, t, or 'open. 'open means the same as t except that
+opens hidden overlays. ")
+
+(defvar iedit-lib-skip-invisible-count 0
+ "This is buffer local varible which is the number of skipped invisible
occurrence. ")
+
+(defvar iedit-lib-skip-filtered-count 0
+ "This is buffer local varible which is the number of filtered occurrence. ")
+
(defvar iedit-hiding nil
"This is buffer local variable which indicates whether buffer lines are
hided. ")
@@ -208,6 +219,8 @@ It replaces `inhibit-modification-hooks' which prevents
calling
(make-variable-buffer-local 'iedit-occurrence-context-lines)
(make-variable-buffer-local 'iedit-occurrence-index)
(make-variable-buffer-local 'iedit-lib-quit-func)
+(make-variable-buffer-local 'iedit-lib-skip-invisible-count)
+(make-variable-buffer-local 'iedit-lib-skip-filtered-count)
(defconst iedit-occurrence-overlay-name 'iedit-occurrence-overlay-name)
(defconst iedit-invisible-overlay-name 'iedit-invisible-overlay-name)
@@ -314,10 +327,13 @@ Return the number of occurrences."
(setq iedit-aborting nil)
(setq iedit-occurrences-overlays nil)
(setq iedit-read-only-occurrences-overlays nil)
+ (setq iedit-lib-skip-invisible-count 0)
+ (setq iedit-lib-skip-filtered-count 0)
;; Find and record each occurrence's markers and add the overlay to the
occurrences
(let ((counter 0)
(case-fold-search (not iedit-case-sensitive))
- (length 0))
+ (search-invisible iedit-search-invisible)
+ (length 0))
(save-excursion
(save-window-excursion
(goto-char end)
@@ -327,15 +343,22 @@ 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)
+ (if (and (> length 0) (/= (- ending beginning) length))
+ (throw 'not-same-length 'not-same-length)
+ (setq length (- ending beginning)))
+ (cond
+ ((text-property-not-all beginning ending 'read-only nil)
+ (push (iedit-make-read-only-occurrence-overlay beginning ending)
+ iedit-read-only-occurrences-overlays))
+ ((not (or (eq search-invisible t)
+ (not (isearch-range-invisible
beginning ending))))
+ (setq iedit-lib-skip-invisible-count (1+
iedit-lib-skip-invisible-count)))
+ ((not (funcall isearch-filter-predicate beginning
ending))
+ (setq iedit-lib-skip-filtered-count (1+
iedit-lib-skip-filtered-count)))
+ (t
(push (iedit-make-occurrence-overlay beginning ending)
- iedit-occurrences-overlays))
- (setq counter (1+ counter))))))
+ iedit-occurrences-overlays)
+ (setq counter (1+ counter))))))))
(iedit-update-index)
counter))
@@ -420,6 +443,8 @@ there are."
"Clean up occurrence overlay, invisible overlay and local variables."
(remove-hook 'post-command-hook 'iedit-update-occurrences-2 t)
(remove-overlays nil nil iedit-occurrence-overlay-name t)
+ ;; Close overlays opened by `isearch-range-invisible'
+ (isearch-clean-overlays)
(iedit-show-all)
(remove-hook 'before-revert-hook iedit-lib-quit-func t)
(remove-hook 'kbd-macro-termination-hook iedit-lib-quit-func t)
diff --git a/iedit-tests.el b/iedit-tests.el
index 569cbd202b..e79f65bebc 100644
--- a/iedit-tests.el
+++ b/iedit-tests.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010 - 2019, 2020 Victor Ren
-;; Time-stamp: <2020-11-21 21:09:39 Victor Ren>
+;; Time-stamp: <2021-01-13 23:06:19 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Version: 0.9.9.9
;; X-URL: https://github.com/victorhge/iedit
@@ -441,6 +441,30 @@ fob")))))
(iedit-toggle-case-sensitive)
(should (= 1 (length iedit-occurrences-overlays))))))
+(ert-deftest iedit-toggle-search-invisible-test ()
+ (with-iedit-test-fixture
+"foo
+* foo
+** foo"
+ (lambda ()
+ (iedit-mode) ; turn off iedit-mode
+ (outline-mode)
+ (forward-line 1)
+ (call-interactively 'outline-hide-subtree)
+ (setq iedit-search-invisible t)
+ (goto-char 1)
+ (iedit-mode)
+ (should (= 3 (length iedit-occurrences-overlays)))
+ (should (= 0 iedit-lib-skip-invisible-count))
+ (iedit-toggle-search-invisible)
+ (should (= 2 (length iedit-occurrences-overlays)))
+ (should (null iedit-search-invisible))
+ (should (= 1 iedit-lib-skip-invisible-count))
+ (iedit-toggle-search-invisible)
+ (should (= 3 (length iedit-occurrences-overlays)))
+ (should (= 0 iedit-lib-skip-invisible-count))
+ (should (eq 'open iedit-search-invisible)))))
+
(ert-deftest iedit-case-preserve-test ()
(with-iedit-test-fixture
"foo
diff --git a/iedit.el b/iedit.el
index e2f0c4a39e..edc1a8e212 100644
--- a/iedit.el
+++ b/iedit.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010 - 2019, 2020 Victor Ren
-;; Time-stamp: <2021-01-06 11:14:51 Victor Ren>
+;; Time-stamp: <2021-01-13 22:39:04 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous refactoring
;; Version: 0.9.9.9
@@ -300,6 +300,7 @@ This is like `describe-bindings', but displays only Iedit
keys."
(define-key map (kbd "M-n") 'iedit-expand-down-to-occurrence)
(define-key map (kbd "M-G") 'iedit-apply-global-modification)
(define-key map (kbd "M-C") 'iedit-toggle-case-sensitive)
+ (define-key map (kbd "M-S") 'iedit-toggle-search-invisible)
map)
"Keymap used within overlays in Iedit mode.")
@@ -795,6 +796,33 @@ prefix, bring the top of the region back down one
occurrence."
(iedit-printable occurrence-regexp))
(force-mode-line-update))))
+(defun iedit-toggle-search-invisible ()
+ "Toggle search-invisible matching occurrences. "
+ (interactive)
+ (setq iedit-search-invisible
+ (if iedit-search-invisible
+ nil
+ (or search-invisible 'open)))
+ (if iedit-buffering
+ (iedit-stop-buffering))
+ (let ((occurrence-string (iedit-current-occurrence-string)))
+ (when occurrence-string
+ (remove-overlays nil nil iedit-occurrence-overlay-name t)
+ (iedit-show-all)
+ (isearch-clean-overlays)
+ (let* ((occurrence-regexp (iedit-regexp-quote occurrence-string))
+ (begin (car iedit-initial-region))
+ (end (cadr iedit-initial-region))
+ (counter (iedit-make-occurrences-overlays occurrence-regexp begin
end)))
+ (message "iedit %s. %d matches for \"%s\""
+ (if iedit-search-invisible
+ "matching invisible"
+ "matching visible")
+ counter
+ (iedit-printable occurrence-regexp))
+ (setq iedit-last-occurrence-local occurrence-string)
+ (force-mode-line-update)))))
+
(provide 'iedit)
;;; iedit.el ends here
- [nongnu] elpa/iedit 44601e01fa 269/301: fix an issue with electric pair, (continued)
- [nongnu] elpa/iedit 44601e01fa 269/301: fix an issue with electric pair, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 3f9eed229e 232/301: Allow custom mode-line, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 9c08a48c88 281/301: Remove the workaround for slow c-before-change, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 01767ddca3 258/301: Fix a failed testcase in batch mode, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 7e507b370b 255/301: Set the FIXEDCASE argument of replace-match in iedit-replace-occurrences to T to allow preserving case., ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 745ea6f812 239/301: Rename iedit-toggle-unmatched-lines-visible to iedit-show/hide-unmatched-lines, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit dfed75064e 285/301: Save and restore `line-move-ignore-invisible', ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit c448864424 216/301: Remove iedit-unmatched-lines-invisible-default, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 5fdf89edc9 238/301: Fix switch to mc mode problem, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit de54411d0e 220/301: Detect markup tag only if region inactive, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit ac51555341 282/301: New feature: ignore hidden occurrences,
ELPA Syncer <=
- [nongnu] elpa/iedit 31986b640a 289/301: Take iedit-goto-first-occurrence back, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 5e7253c36e 274/301: Update documents and comments, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit d4a878d52e 280/301: Minor docstring typo fix: covert -> convert., ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 4765fa7a4d 271/301: Fix a conjoined overlay issue, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 68233e302d 300/301: Fix some byte-compiler warnings in Emacs 28, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 7d18e5d775 039/301: Add a help command C-? for occurrences, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit e08ad5923a 043/301: Make Iedit mode available for read only buffer, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 78f606d4fc 045/301: Add iedit-number-occurrences function, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 0d4027fe10 046/301: Move save-excursion out of dolist, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 3bca7e2da5 048/301: Fix iedit toggle case-sensitive problem when getting occurrence from history, ELPA Syncer, 2022/01/10