[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iedit 4ef9bf6323 287/301: prefix-arg for `iedit-next-occur
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iedit 4ef9bf6323 287/301: prefix-arg for `iedit-next-occurrence` and `iedit-prev-occurrence` |
Date: |
Mon, 10 Jan 2022 22:59:11 -0500 (EST) |
branch: elpa/iedit
commit 4ef9bf63239993aea65d06ca9e09b80031187d79
Author: Philip "Galli" Rentschler <gallipo@web.de>
Commit: Victor <victorhge@gmail.com>
prefix-arg for `iedit-next-occurrence` and `iedit-prev-occurrence`
---
iedit-lib.el | 148 +++++++++++++++++++++++++++++++----------------------------
1 file changed, 77 insertions(+), 71 deletions(-)
diff --git a/iedit-lib.el b/iedit-lib.el
index 77c724069d..3612eec177 100644
--- a/iedit-lib.el
+++ b/iedit-lib.el
@@ -629,80 +629,86 @@ Apply the change to all the other occurrences. "
value))))))
(iedit-move-conjoined-overlays another-occurrence))))))
-(defun iedit-next-occurrence ()
+(defun iedit-next-occurrence (&optional arg)
"Move forward to the next occurrence in the `iedit'.
-If the point is already in the last occurrences, you are asked to type
+Move ARG occurrences forward (backward if ARG is negative).
+Interactively, ARG is the numeric prefix argument.
+If ARG is omitted or nil, move 1 occurrences forward.
+If point reaches 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))
- (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 ov)
- (progn (message "This is the last occurrence.")
- (setq iedit-forward-success nil))
- (progn
- (if (get-char-property (point-min) 'iedit-occurrence-overlay-name)
- (setq pos (point-min))
- (setq pos (next-single-char-property-change
- (point-min)
- 'iedit-occurrence-overlay-name)))
- (setq iedit-forward-success t)
- (message "Located the first occurrence."))))
- (when iedit-forward-success
- (iedit-update-index pos)
- (goto-char pos))))
-
-(defun iedit-prev-occurrence ()
+beginning of the buffer. If used with prefix argument, wrapping
+from last to first occurrence will cost one repetition."
+ (interactive "p")
+ (cond ((< arg 0) (iedit-prev-occurrence (abs arg)))
+ ((> arg 0)
+ (dotimes (i arg)
+ (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 ov)
+ (progn (message "This is the last occurrence.")
+ (setq iedit-forward-success nil))
+ (progn
+ (if (get-char-property (point-min)
'iedit-occurrence-overlay-name)
+ (setq pos (point-min))
+ (setq pos (next-single-char-property-change
+ (point-min)
+ 'iedit-occurrence-overlay-name)))
+ (setq iedit-forward-success t)
+ (message "Located the first occurrence."))))
+ (when iedit-forward-success
+ (iedit-update-index pos)
+ (goto-char pos)))))))
+
+(defun iedit-prev-occurrence (&optional arg)
"Move backward to the previous occurrence in the `iedit'.
-If the point is already in the first occurrences, you are asked to type
-another `iedit-prev-occurrence', it starts again from the end of
-the buffer."
- (interactive)
- (let ((pos (point))
- (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)) ;conjoined
- (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))
- ov))
- (if (and iedit-forward-success ov)
- (progn (message "This is the first occurrence.")
- (setq iedit-forward-success nil))
- (progn
- (setq pos (iedit-last-occurrence))
- (setq iedit-forward-success t)
- (message "Located the last occurrence.")))
- (setq iedit-forward-success t))
- (when iedit-forward-success
- (iedit-update-index pos)
- (goto-char pos))))
-
-(defun iedit-goto-first-occurrence ()
- "Move to the first occurrence."
- (interactive)
- (goto-char (iedit-first-occurrence))
- (setq iedit-forward-success t)
- (setq iedit-occurrence-index 1)
- (message "Located the first occurrence."))
+Move ARG occurrences backward (forward if ARG is negative).
+Interactively, ARG is the numeric prefix argument.
+If ARG is omitted or nil, move 1 occurrences back.
+If point reaches the first occurrences, you are asked to type
+another `iedit-prev-occurrence', it starts again from the
+end of the buffer. If used with prefix argument, wrapping
+from first to last occurrence will cost one repetition."
+ (interactive "p")
+ (cond ((< arg 0) (iedit-next-occurrence (abs arg)))
+ ((> arg 0)
+ (dotimes (i arg)
+ (let ((pos (point))
+ (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)) ;conjoined
+ (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))
+ ov))
+ (if (and iedit-forward-success ov)
+ (progn (message "This is the first occurrence.")
+ (setq iedit-forward-success nil))
+ (progn
+ (setq pos (iedit-last-occurrence))
+ (setq iedit-forward-success t)
+ (message "Located the last occurrence.")))
+ (setq iedit-forward-success t))
+ (when iedit-forward-success
+ (iedit-update-index pos)
+ (goto-char pos)))))))
(defun iedit-first-occurrence ()
"return the position of the first occurrence."
- [nongnu] elpa/iedit 8b620efacb 262/301: Replace `inhibit-modification-hooks' with `iedit-updating', (continued)
- [nongnu] elpa/iedit 8b620efacb 262/301: Replace `inhibit-modification-hooks' with `iedit-updating', ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 6d2694356c 253/301: Move "declare-function" invocations outside of "when" statement., ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit f6682186f0 242/301: Replace eval-after-load with require check, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 14376a97e0 223/301: Ignore error in `iedit-mark-sgml-pair', ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 9fd1b43170 229/301: Fix failed test cases for Emacs 25.1, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 658c10a249 244/301: fix issue of iedit-restrict-function doesn't update mode-line text correctly, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 06f1f50939 224/301: Merge pull request #65 from pstray/master, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit c11ecd9080 273/301: Update copyright notice, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit e5b51ac0af 278/301: Move hooks setup to iedit-lib to reduce code duplication, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit c00a8ba805 272/301: Add a new feature - preserve case, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 4ef9bf6323 287/301: prefix-arg for `iedit-next-occurrence` and `iedit-prev-occurrence`,
ELPA Syncer <=
- [nongnu] elpa/iedit 3d71392852 276/301: Fix as well issue #118, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit f7184f81d6 284/301: Clean up some lines of unnecessary code, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 2e1fd5b1b2 295/301: fix a byte compile issue, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 012de2e8d8 293/301: A few rephase in doc, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 6bb8d63a97 297/301: Fix several typo errors, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 345431294a 294/301: Unify prefix augument handling, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 61689f6ba4 057/301: Add arg handle for iedit-mode to exclude some occurrences., ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 7479d4c947 079/301: Merge branch 'topic/multi-interface', ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 6cc86d58e6 086/301: Merge pull request #6 from gorakhargosh/master, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 4cf803d9cb 092/301: Skip the first occurrence for occur-edit-mode, ELPA Syncer, 2022/01/10