[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iedit adb0d2e92d 179/301: Expand to next occurence ("incre
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iedit adb0d2e92d 179/301: Expand to next occurence ("incremental select") |
Date: |
Mon, 10 Jan 2022 22:59:01 -0500 (EST) |
branch: elpa/iedit
commit adb0d2e92d71023cdc7fdeb65ba77a3e810bd946
Author: Bar Magal <barmagal@gmail.com>
Commit: Bar Magal <barmagal@gmail.com>
Expand to next occurence ("incremental select")
iedit-expand-up-to-occurence and iedit-expand-down-to-occurence expand
the search region up/down to next available occurence. If no such
occurence exists, throw an error.
Because the expansion is based on iedit-expand-by-a-line, when there are
two occurences are on the same, it is impossible to select one of them
without the other.
---
iedit.el | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/iedit.el b/iedit.el
index c71eee3720..eb1308947c 100644
--- a/iedit.el
+++ b/iedit.el
@@ -238,6 +238,8 @@ This is like `describe-bindings', but displays only Iedit
keys."
(define-key map (kbd "M-I") 'iedit-restrict-current-line)
(define-key map (kbd "M-{") 'iedit-expand-up-a-line)
(define-key map (kbd "M-}") 'iedit-expand-down-a-line)
+ (define-key map (kbd "M-[") 'iedit-expand-up-to-occurence)
+ (define-key map (kbd "M-]") 'iedit-expand-down-to-occurence)
(define-key map (kbd "M-G") 'iedit-apply-global-modification)
(define-key map (kbd "M-C") 'iedit-toggle-case-sensitive)
map)
@@ -583,6 +585,38 @@ the region back up one line."
(iedit-expand-by-a-line 'bottom
(if arg -1 1)))
+(defun iedit-down-occurence-pos ()
+ "Get position of next occurence past `iedit-last-occurrence'"
+ (save-excursion
+ (goto-char (1+ (iedit-last-occurrence)))
+ (search-forward-regexp (iedit-current-occurrence-string))))
+
+(defun iedit-expand-down-to-occurence ()
+ "Expand the search region downwards until reaching a new occurence.
+If no such occurence can be found, throw an error."
+ (interactive)
+ (let ((last-pos (iedit-last-occurrence))
+ (next-pos (iedit-down-occurence-pos)))
+ (iedit-expand-by-a-line 'bottom
+ (- (line-number-at-pos next-pos)
+ (line-number-at-pos last-pos)))))
+
+(defun iedit-up-occurrence-pos ()
+ "Get position of next occurence past `iedit-first-occurrence'"
+ (save-excursion
+ (goto-char (iedit-first-occurrence))
+ (search-backward-regexp (iedit-current-occurrence-string))))
+
+(defun iedit-expand-up-to-occurence ()
+ "Expand the search region upwards until reaching a new occurence.
+If no such occurence can be found, throw an error."
+ (interactive)
+ (let ((first-pos (iedit-first-occurrence))
+ (prev-pos (iedit-up-occurrence-pos)))
+ (iedit-expand-by-a-line 'top
+ (- (line-number-at-pos first-pos)
+ (line-number-at-pos prev-pos)))))
+
(defun iedit-restrict-region (beg end &optional inclusive)
"Restricting Iedit mode in a region."
(when iedit-buffering
- [nongnu] elpa/iedit 52a7ead70c 135/301: Fix comiler error for extra ")", (continued)
- [nongnu] elpa/iedit 52a7ead70c 135/301: Fix comiler error for extra ")", ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 50748a5694 160/301: ensure iedit-skip-modification-once is t in case of errors, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 060b359afc 142/301: Merge branch 'master' of github.com:victorhge/iedit, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 70e6d370fb 194/301: Merge branch 'master' of github.com:victorhge/iedit, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 30db1d2ba1 191/301: Remove the key binding to M-[, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 3fae24471f 129/301: fix tests to call iedit-rectangle-mode interactively, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit dbe9e4478b 174/301: Merge pull request #41 from Vifon/iedit-replace-occurrences_default-value, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit c742ae4fa6 196/301: Exit iedit when there is no occurrence, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 46d5f65019 154/301: clean up old occurrences when calling from isearch, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit c55fcd5bac 189/301: avoid error if iedit-toggle-key-default already bound to iedit-mode, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit adb0d2e92d 179/301: Expand to next occurence ("incremental select"),
ELPA Syncer <=
- [nongnu] elpa/iedit d25b655768 207/301: Merge branch 'master' of github.com:victorhge/iedit, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit d31bafa97c 171/301: Refactored for easier to show different messages, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 2d9017daea 181/301: Merge pull request #51 from jasminpatry/fix/restrict-current-line-resets-expand, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 048d8417cf 202/301: *** empty log message ***, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit a8ab03848d 158/301: complete iedit-toggle-selection, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit c0d108da3b 166/301: make the occurrence the latest kill in the kill ring, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit d89ee51834 148/301: Merge branch 'redo-prs' of github.com:lewang/iedit, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit fd801e77df 165/301: Merge pull request #38 from mgalgs/narrow-around-current-line, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 52c4865e5b 197/301: Add special prefix argument 1, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 8d20094a11 182/301: Use the original case in the iedit-replace default value, ELPA Syncer, 2022/01/10