[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iedit ed52608a0d 268/301: Fix conjoined occurrences issues
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iedit ed52608a0d 268/301: Fix conjoined occurrences issues |
Date: |
Mon, 10 Jan 2022 22:59:09 -0500 (EST) |
branch: elpa/iedit
commit ed52608a0de7ef7b972f749511dac8d0a29b2ea5
Author: Victor Ren <yren@sonicwall.com>
Commit: Victor <victorhge@gmail.com>
Fix conjoined occurrences issues
---
iedit-lib.el | 78 +++++++++++++++++++++++++++++++++++-----------------------
iedit-tests.el | 7 ++----
2 files changed, 49 insertions(+), 36 deletions(-)
diff --git a/iedit-lib.el b/iedit-lib.el
index 5a2dfb9dcf..970d16bacc 100644
--- a/iedit-lib.el
+++ b/iedit-lib.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2020-07-28 22:59:25 Victor Ren>
+;; Time-stamp: <2020-08-26 19:29:09 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous rectangle refactoring
;; Version: 0.9.9.9
@@ -104,7 +104,7 @@ the traverse of the long `iedit-occurrences-overlays' list."
:type 'integer
:group 'iedit)
-(defcustom iedit-increment-format-string "%03d "
+(defcustom iedit-increment-format-string "%03d"
"Format string used to format incremented numbers.
This is used by `iedit-number-occurrences'."
:type 'string
@@ -576,14 +576,20 @@ If the point is already in the last occurrences, you are
asked to type
another `iedit-next-occurrence', it starts again from the
beginning of the buffer."
(interactive)
- (let ((pos (point))
- (in-occurrence (get-char-property (point)
'iedit-occurrence-overlay-name)))
- (when in-occurrence
- (setq pos (next-single-char-property-change pos
'iedit-occurrence-overlay-name)))
- (setq pos (next-single-char-property-change pos
'iedit-occurrence-overlay-name))
+ (let* ((pos (point))
+ (ov (iedit-find-current-occurrence-overlay)))
+ (if ov
+ (if (iedit-find-overlay-at-point (overlay-end ov)
'iedit-occurrence-overlay-name)
+ (setq pos (overlay-end ov)) ; conjoined overlay
+ ;; from inside
+ (setq pos (next-single-char-property-change pos
'iedit-occurrence-overlay-name))
+ (setq pos (next-single-char-property-change pos
'iedit-occurrence-overlay-name)))
+ ;; from outside
+ (setq pos (next-single-char-property-change pos
'iedit-occurrence-overlay-name)))
+
(if (/= pos (point-max))
(setq iedit-forward-success t)
- (if (and iedit-forward-success in-occurrence)
+ (if (and iedit-forward-success ov)
(progn (message "This is the last occurrence.")
(setq iedit-forward-success nil))
(progn
@@ -605,22 +611,25 @@ another `iedit-prev-occurrence', it starts again from the
end of
the buffer."
(interactive)
(let ((pos (point))
- (in-occurrence (get-char-property (point)
'iedit-occurrence-overlay-name)))
- (when in-occurrence
- (setq pos (previous-single-char-property-change pos
'iedit-occurrence-overlay-name)))
- (setq pos (previous-single-char-property-change pos
'iedit-occurrence-overlay-name))
+ (ov (iedit-find-current-occurrence-overlay))
+ (previous-overlay))
+ (when (/= pos (point-min))
+ (when ov (setq pos (overlay-start ov)))
+ (if (and ov
+ (setq previous-overlay (iedit-find-overlay-at-point
(1- pos) 'iedit-occurrence-overlay-name)))
+ (setq pos (overlay-start previous-overlay))
+ (setq pos (previous-single-char-property-change pos
'iedit-occurrence-overlay-name))
+ (setq pos (previous-single-char-property-change pos
'iedit-occurrence-overlay-name))))
;; At the start of the first occurrence
(if (or (and (eq pos (point-min))
(not (get-char-property (point-min)
'iedit-occurrence-overlay-name)))
(and (eq (point) (point-min))
- in-occurrence))
- (if (and iedit-forward-success in-occurrence)
+ ov))
+ (if (and iedit-forward-success ov)
(progn (message "This is the first occurrence.")
(setq iedit-forward-success nil))
(progn
- (setq pos (previous-single-char-property-change (point-max)
'iedit-occurrence-overlay-name))
- (if (not (get-char-property (- (point-max) 1)
'iedit-occurrence-overlay-name))
- (setq pos (previous-single-char-property-change pos
'iedit-occurrence-overlay-name)))
+ (setq pos (iedit-last-occurrence))
(setq iedit-forward-success t)
(message "Located the last occurrence.")))
(setq iedit-forward-success t))
@@ -653,10 +662,12 @@ the buffer."
(defun iedit-last-occurrence ()
"return the position of the last occurrence."
- (let ((pos (previous-single-char-property-change (point-max)
'iedit-occurrence-overlay-name)))
- (if (not (get-char-property (- (point-max) 1)
'iedit-occurrence-overlay-name))
- (setq pos (previous-single-char-property-change pos
'iedit-occurrence-overlay-name)))
- pos))
+ (let ((ov (iedit-find-overlay-at-point (1- (point-max))
'iedit-occurrence-overlay-name))
+ (pos (point-max)))
+ (if ov
+ (overlay-start ov)
+ (setq pos (previous-single-char-property-change pos
'iedit-occurrence-overlay-name))
+ (overlay-start (iedit-find-overlay-at-point (1- pos)
'iedit-occurrence-overlay-name)))))
(defun iedit-show/hide-context-lines (&optional arg)
"Show or hide context lines.
@@ -794,16 +805,21 @@ FORMAT."
(let ((number start-at)
(iedit-updating t))
(save-excursion
- (cl-loop for occurrence in (reverse iedit-occurrences-overlays)
- for counter from number
- for beg = (overlay-start occurrence)
- for end = (overlay-end occurrence)
- do (progn
- (goto-char beg)
- (if (re-search-forward "\\\\#" end t)
- (replace-match (format
format-string counter) t)
- (insert (format format-string
counter)))
- (iedit-move-conjoined-overlays
occurrence))))))
+ (goto-char (iedit-first-occurrence))
+ (cl-loop for counter from number
+ for ov = (iedit-find-current-occurrence-overlay)
+ while (/= (point) (point-max))
+ do (progn
+ (if (re-search-forward "\\\\#" (overlay-end ov) t)
+ (replace-match (format format-string counter) t)
+ (insert (format format-string counter)))
+ (iedit-move-conjoined-overlays ov)
+ ;; goto the beginning of the next occourrence overlay
+ (if (iedit-find-overlay-at-point (overlay-end ov)
'iedit-occurrence-overlay-name)
+ (goto-char (overlay-end ov)) ; conjoined overlay
+ (when (< (point) (overlay-end ov))
+ (goto-char (next-single-char-property-change (point)
'iedit-occurrence-overlay-name)))
+ (goto-char (next-single-char-property-change (point)
'iedit-occurrence-overlay-name))))))))
;;; Don't downcase from-string to allow case freedom!
(defun iedit-replace-occurrences(&optional to-string)
diff --git a/iedit-tests.el b/iedit-tests.el
index 704df6a0e6..4b322e097b 100644
--- a/iedit-tests.el
+++ b/iedit-tests.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2020-07-21 01:58:10 Victor Ren>
+;; Time-stamp: <2020-08-26 19:33:45 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Version: 0.9.9.9
;; X-URL: https://github.com/victorhge/iedit
@@ -329,9 +329,6 @@ fob")))))
(should (= iedit-occurrence-index 2))
(goto-char (point-max))
(iedit-prev-occurrence)
- (should (= (point) 27))
- (should (= iedit-occurrence-index 3))
- (iedit-prev-occurrence)
(should (= (point) 24))
(should (= iedit-occurrence-index 3))
(iedit-prev-occurrence)
@@ -462,7 +459,7 @@ fob")))))
bar
barfoo
bar"))
- (iedit-number-occurrences 1)
+ (iedit-number-occurrences 1 "%d ")
(should (string= (buffer-string)
"1 bar
2 bar
- [nongnu] elpa/iedit 67ad83f7fc 192/301: Rewrite iedit-expand-by-a-line, (continued)
- [nongnu] elpa/iedit 67ad83f7fc 192/301: Rewrite iedit-expand-by-a-line, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit d1326bdef1 136/301: release.sh: New file., ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit d6c99fa91a 130/301: set `iedit-rectangle` to the actual rectangle corners, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit f36e6fcf0d 143/301: Move iedit-apply-global-modification to iedit, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 8d58171240 145/301: bugfix for iedit-hide-unmatched-lines, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit a55fcae6d0 175/301: Bind <tab> to iedit-next-occurrence, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 232cd0e5ec 146/301: tweak to use isearch case sensitivity, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 5883f9af54 211/301: Avoid overriding user's key bindings, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 95e7731a91 147/301: bugfix for when there are no occurrences, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 19abf6e871 247/301: Update URLs to emacswiki, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit ed52608a0d 268/301: Fix conjoined occurrences issues,
ELPA Syncer <=
- [nongnu] elpa/iedit 890a11657c 226/301: Merge pull request #66 from pstray/master, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit a5ce38a9c3 123/301: fix deleting char at end of overlay with mirror at EOB, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 8219304d9c 051/301: Fix problem when iedit-stop-buffering is called when current point is at any occurrence., ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit d872cb77e5 058/301: Update comments for restricting, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 75552aa1c8 090/301: Rename, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 33d1b24e04 080/301: Fix compatible with Emacs 22 problem, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit ad8fd96f86 215/301: Add support for markup tags, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 5b14cc9fca 241/301: Add a demo gif and update document, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 03b647be8b 234/301: Expand or collapse mutiple lines, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 88101571fe 288/301: Make it an option to save occurrence in the kill ring, ELPA Syncer, 2022/01/10