[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iedit 106185cd95 187/301: Merge branch 'bmag-incremental-s
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iedit 106185cd95 187/301: Merge branch 'bmag-incremental-select' |
Date: |
Mon, 10 Jan 2022 22:59:01 -0500 (EST) |
branch: elpa/iedit
commit 106185cd95d90c8dfb608591e79cc85bc9847d34
Merge: d335d6842a 9d03d5d44e
Author: Victor Ren <victorhge@gmail.com>
Commit: Victor Ren <victorhge@gmail.com>
Merge branch 'bmag-incremental-select'
---
iedit-lib.el | 24 +++++++++++++++---------
iedit-tests.el | 26 +++++++++++++++++++++++++-
iedit.el | 36 +++++++++++++++++++++++++++++++++---
3 files changed, 73 insertions(+), 13 deletions(-)
diff --git a/iedit-lib.el b/iedit-lib.el
index bac0279e83..b02ef5d88d 100644
--- a/iedit-lib.el
+++ b/iedit-lib.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2015-04-13 12:16:14 Victor Ren>
+;; Time-stamp: <2016-05-17 11:24:09 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous rectangle refactoring
;; Version: 0.97
@@ -235,25 +235,29 @@ Return the number of occurrences."
(iedit-add-occurrence-overlay occurrence-exp point nil))
(defun iedit-add-occurrence-overlay (occurrence-exp point forward)
- "Create next or previous occurrence overlay for `occurrence-exp'."
+ "Create next or previous occurrence overlay for `occurrence-exp'.
+Return the start position of the new occurrence if successful."
(or point
(setq point (point)))
- (let ((case-fold-search (not iedit-case-sensitive)))
+ (let ((case-fold-search (not iedit-case-sensitive))
+ (pos nil))
(save-excursion
(goto-char point)
(if (not (if forward
(re-search-forward occurrence-exp nil t)
(re-search-backward occurrence-exp nil t)))
- (message "No match")
+ (message "No more match.")
+ (setq pos (match-beginning 0))
(if (or (iedit-find-overlay-at-point (match-beginning 0)
'iedit-occurrence-overlay-name)
(iedit-find-overlay-at-point (match-end 0)
'iedit-occurrence-overlay-name))
(error "Conflict region"))
(push (iedit-make-occurrence-overlay (match-beginning 0)
(match-end 0))
iedit-occurrences-overlays)
- (message "Add one match for \"%s\"" (iedit-printable occurrence-exp))
+ (message "Add one match for \"%s\"." (iedit-printable occurrence-exp))
(if iedit-unmatched-lines-invisible
- (iedit-hide-unmatched-lines iedit-occurrence-context-lines))))))
+ (iedit-hide-unmatched-lines iedit-occurrence-context-lines))))
+ pos))
(defun iedit-add-region-as-occurrence (beg end)
"Add region as an occurrence.
@@ -582,7 +586,7 @@ value of `iedit-occurrence-context-lines' is used for this
time."
(iedit-barf-if-buffering)
(iedit-apply-on-occurrences 'downcase-region))
-(defun iedit-replace-occurrences()
+(defun iedit-replace-occurrences(&optional to-string)
"Replace occurrences with STRING.
This function preserves case."
(interactive "*")
@@ -592,10 +596,12 @@ This function preserves case."
(from-string (downcase (buffer-substring-no-properties
(overlay-start ov)
(overlay-end ov))))
- (to-string (read-string "Replace with: "
+ (to-string (if (not to-string)
+ (read-string "Replace with: "
nil nil
from-string
- nil)))
+ nil)
+ to-string)))
(iedit-apply-on-occurrences
(lambda (beg end from-string to-string)
(goto-char beg)
diff --git a/iedit-tests.el b/iedit-tests.el
index 6624d4bd2a..b0be63092a 100644
--- a/iedit-tests.el
+++ b/iedit-tests.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2013-06-05 14:36:42 Victor Ren>
+;; Time-stamp: <2016-05-17 11:46:10 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Version: 0.97
;; X-URL: http://www.emacswiki.org/emacs/Iedit
@@ -499,6 +499,30 @@ fob")))))
(should (not (iedit-same-column)))
(should-error (iedit-kill-rectangle)))))
+(ert-deftest iedit-expand-to-occurrence-test ()
+ (with-iedit-test-fixture
+ "a a
+a a a
+a a a"
+ (lambda()
+ (goto-char 5)
+ (iedit-restrict-current-line)
+ (call-interactively 'iedit-expand-down-to-occurrence)
+ (should (equal (length iedit-occurrences-overlays) 4))
+ (should (= (point) 11))
+ (call-interactively 'iedit-expand-up-to-occurrence)
+ (should (equal (length iedit-occurrences-overlays) 5))
+ (should (= (point) 3))
+ (call-interactively 'iedit-expand-up-to-occurrence)
+ (call-interactively 'iedit-expand-up-to-occurrence)
+ (should (equal (length iedit-occurrences-overlays) 6))
+ (should (= (point) 1))
+ (call-interactively 'iedit-expand-down-to-occurrence)
+ (call-interactively 'iedit-expand-down-to-occurrence)
+ (call-interactively 'iedit-expand-down-to-occurrence)
+ (should (equal (length iedit-occurrences-overlays) 8))
+ (should (= (point) 15)))))
+
(ert-deftest iedit-kill-rectangle-test ()
(with-iedit-test-fixture
"foo
diff --git a/iedit.el b/iedit.el
index 7bc992f98f..b20332e838 100644
--- a/iedit.el
+++ b/iedit.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2016-05-13 11:10:36 Victor Ren>
+;; Time-stamp: <2016-05-17 12:25:04 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous refactoring
;; Version: 0.97
@@ -225,11 +225,11 @@ This is like `describe-bindings', but displays only Iedit
keys."
(key-description
iedit-toggle-key-default)
key-def)
:warning)
-
(define-key global-map iedit-toggle-key-default 'iedit-mode)
(define-key isearch-mode-map iedit-toggle-key-default
'iedit-mode-from-isearch)
(define-key esc-map iedit-toggle-key-default
'iedit-execute-last-modification)
- (define-key help-map iedit-toggle-key-default
'iedit-mode-toggle-on-function))))
+ (define-key help-map iedit-toggle-key-default
'iedit-mode-toggle-on-function)
+ (message "Iedit default key binding is %s" (key-description
iedit-toggle-key-default)))))
;; Avoid to restore Iedit mode when restoring desktop
(add-to-list 'desktop-minor-mode-handlers
@@ -245,6 +245,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-occurrence)
+ (define-key map (kbd "M-]") '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)
map)
@@ -592,6 +594,34 @@ the region back up one line."
(iedit-expand-by-a-line 'bottom
(if arg -1 1)))
+(defun iedit-expand-down-to-occurrence ()
+ "Expand the search region downwards until reaching a new occurrence.
+If no such occurrence can be found, throw an error."
+ (interactive)
+ (iedit-expand-to-occurrence t))
+
+(defun iedit-expand-up-to-occurrence ()
+ "Expand the search region upwards until reaching a new occurrence.
+If no such occurrence can be found, throw an error."
+ (interactive)
+ (iedit-expand-to-occurrence nil))
+
+(defun iedit-expand-to-occurrence (forward)
+ "Expand to next or previous occurrence."
+ (let ((pos (iedit-add-occurrence-overlay
+ (iedit-regexp-quote (iedit-current-occurrence-string))
+ (if forward
+ (1+ (iedit-last-occurrence))
+ (iedit-first-occurrence))
+ forward)))
+ (when pos
+ (goto-char pos)
+ (setq iedit-mode (propertize
+ (concat " Iedit:" (number-to-string
+ (length
iedit-occurrences-overlays)))
+ 'face 'font-lock-warning-face))
+ (force-mode-line-update))))
+
(defun iedit-restrict-region (beg end &optional inclusive)
"Restricting Iedit mode in a region."
(when iedit-buffering
- [nongnu] elpa/iedit f79846e639 275/301: Fix issue #117, (continued)
- [nongnu] elpa/iedit f79846e639 275/301: Fix issue #117, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit f74ae491f3 291/301: fix failed test cases, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 3bd4c15e3d 301/301: Add license file with GPLv3, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 344ff8de91 299/301: Add iedit-autoloads.el to .gitignore, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit f88df1072b 116/301: Merge branch 'master' of github.com:victorhge/iedit, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 1bced99a26 109/301: Fix bugs when undo is in progress, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit a5d117a75a 122/301: add test-case for deleting char at end of overlay with mirror at EOB, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 78ac0ea958 105/301: Fix typo, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 6f80f88134 106/301: Differentiate lib keymap and occurrence keymap, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 9cfd76f7c2 121/301: Toggle case-sensitive with intial region, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 106185cd95 187/301: Merge branch 'bmag-incremental-select',
ELPA Syncer <=
- [nongnu] elpa/iedit 9d03d5d44e 186/301: Merge branch 'incremental-select', ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit acb9fa54f3 152/301: Fix the testcase for iedit-hide-unmatched-lines, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 6c6522c7e9 177/301: Minor bugfix: `help-char' need not be acceptable to `char-to-string'., ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 4d50a08dd6 134/301: Add parameter back to iedit-mode-from-isearch, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit d7d5931566 127/301: Fix the arguments for after-change-functions, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 64a7905949 138/301: Rewrite iedit-hide-unmatched-lines, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit bceb12e17b 139/301: Do not jump to the first occurrence after iedit-restrict-region, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 8eb9caaa94 132/301: use real buffer for testing to ease debugging, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 8149b66ce6 140/301: Read-only text handling, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 52a7ead70c 135/301: Fix comiler error for extra ")", ELPA Syncer, 2022/01/10