[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iedit 8559638b9b 076/301: Fix C-u C-u iedit-last-inital-st
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iedit 8559638b9b 076/301: Fix C-u C-u iedit-last-inital-string-global problem |
Date: |
Mon, 10 Jan 2022 22:58:52 -0500 (EST) |
branch: elpa/iedit
commit 8559638b9be1f01d5a334397ddf1e844c2a51426
Author: Victor Ren <victorhge@gmail.com>
Commit: Victor Ren <victorhge@gmail.com>
Fix C-u C-u iedit-last-inital-string-global problem
---
iedit-tests.el | 99 ++++++++++++++++++++++++++++++++++++++++++----------------
iedit.el | 47 ++++++++++++++--------------
2 files changed, 95 insertions(+), 51 deletions(-)
diff --git a/iedit-tests.el b/iedit-tests.el
index 2333b6bd64..187cb8dd0e 100755
--- a/iedit-tests.el
+++ b/iedit-tests.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-03-03 14:43:39 Victor Ren>
+;; Time-stamp: <2012-03-03 17:27:58 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Version: 0.94
;; X-URL: http://www.emacswiki.org/emacs/Iedit
@@ -71,9 +71,31 @@
(forward-line 2)
(iedit-mode)
(should (= 2 (length iedit-occurrences-overlays)))
+ (should (string= iedit-initial-string-local "foo"))
(iedit-mode)
(should (null iedit-occurrences-overlays)))))
+(ert-deftest iedit-mode-with-region-test ()
+ (with-iedit-test-fixture
+"foobar
+ foo
+ foo
+ bar
+foo"
+ (lambda ()
+ (iedit-mode)
+ (goto-char 1)
+ (set-mark-command nil)
+ (forward-char 3)
+ (iedit-mode)
+ (should (= 4 (length iedit-occurrences-overlays)))
+ (should (string= iedit-initial-string-local "foo"))
+ (should (null iedit-only-complete-symbol-local))
+ (goto-char 1)
+ (set-mark-command nil)
+ (forward-line 3)
+ (iedit-mode 4)
+ (should (= 1 (length iedit-occurrences-overlays))))))
(ert-deftest iedit-mode-start-from-isearch-test ()
(with-iedit-test-fixture
"foo
@@ -95,6 +117,52 @@
(iedit-mode)
(should (null iedit-occurrences-overlays)))))
+(ert-deftest iedit-mode-last-local-occurrence-test ()
+ (with-iedit-test-fixture
+"foo
+ foo
+ barfoo
+ foo"
+ (lambda ()
+ (should (= 3 (length iedit-occurrences-overlays)))
+ (should (string= iedit-initial-string-local "foo"))
+ (iedit-mode)
+ (goto-char 15)
+ (iedit-mode 4) ; last local
+ (should (string= iedit-initial-string-local "foo"))
+ (should (= 3 (length iedit-occurrences-overlays))))))
+
+(ert-deftest iedit-mode-last-global-occurrence-test ()
+ (with-iedit-test-fixture
+"foo
+ foo
+ barfoo
+ foo"
+ (lambda ()
+ (should (= 3 (length iedit-occurrences-overlays)))
+ (should (string= iedit-initial-string-local "foo"))
+ (iedit-mode)
+ (with-temp-buffer
+ (insert "bar foo foo")
+ (goto-char 1)
+ (iedit-mode 16)
+ (should (string= iedit-initial-string-local "foo"))
+ (should (= 2 (length iedit-occurrences-overlays)))))))
+
+(ert-deftest iedit-execute-last-modification-test ()
+ (with-iedit-test-fixture
+"foo
+ foo
+ barfoo
+ foo"
+ (lambda ()
+ (should (= 3 (length iedit-occurrences-overlays)))
+ (should (string= iedit-initial-string-local "foo"))
+ (iedit-mode)
+ (with-temp-buffer
+ (insert "bar foo foo")
+ (should-error (iedit-execute-last-modification))))))
+
(ert-deftest iedit-movement-test ()
(with-iedit-test-fixture
"foo
@@ -135,28 +203,6 @@
(should (string= (current-message) "Located the last occurrence."))
)))
-(ert-deftest iedit-mode-with-region-test ()
- (with-iedit-test-fixture
-"foobar
- foo
- foo
- bar
-foo"
- (lambda ()
- (iedit-mode)
- (goto-char 1)
- (set-mark-command nil)
- (forward-char 3)
- (iedit-mode)
- (should (= 4 (length iedit-occurrences-overlays)))
- (should (string= iedit-initial-string-local "foo"))
- (should (null iedit-only-complete-symbol-local))
- (goto-char 1)
- (set-mark-command nil)
- (forward-line 3)
- (iedit-mode 4)
- (should (= 1 (length iedit-occurrences-overlays))))))
-
(ert-deftest iedit-occurrence-update-test ()
(with-iedit-test-fixture
"foo
@@ -330,11 +376,11 @@ arfoo
(emacs-lisp-mode)
(goto-char 5)
(iedit-mode)
- (iedit-restrict-defun)
+ (iedit-restrict-function)
(should (= 1 (length iedit-occurrences-overlays)))
(iedit-mode)
(goto-char 13)
- (iedit-mode 0)
+ (iedit-mode-function)
(should (= 4 (length iedit-occurrences-overlays)))
(iedit-mode)
(iedit-mode)
@@ -356,7 +402,7 @@ arfoo
(transient-mark-mode -1)
(goto-char 5)
(iedit-mode)
- (iedit-restrict-defun)
+ (iedit-restrict-function)
(should (= 1 (length iedit-occurrences-overlays)))
(iedit-mode)
(goto-char 13)
@@ -368,7 +414,6 @@ arfoo
(iedit-mode)
(should (= 0 (length iedit-occurrences-overlays))))))
-
(defvar iedit-printable-test-lists
'(("" "")
("abc" "abc")
diff --git a/iedit.el b/iedit.el
index 00efa5499d..17d1a8528d 100644
--- a/iedit.el
+++ b/iedit.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-03-02 15:49:40 Victor Ren>
+;; Time-stamp: <2012-03-03 17:27:33 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region replace simultaneous
;; Version: 0.95
@@ -67,7 +67,7 @@
;; (define-key global-map (kbd "C-;") 'iedit-mode)
;; (define-key isearch-mode-map (kbd "C-;") 'iedit-mode)
;; (define-key esc-map (kbd "C-;") 'iedit-execute-last-modification)
-;; (define-key help-map (kbd "C-;") 'iedit-mode-defun)
+;; (define-key help-map (kbd "C-;") 'iedit-mode-function)
;; (define-key global-map [C-return] 'iedit-rectangle-mode)
;;; todo:
@@ -144,7 +144,7 @@ For example, when invoking `iedit-mode' on the \"in\" in the
(define-key global-map (kbd "C-;") 'iedit-mode)
(define-key isearch-mode-map (kbd "C-;") 'iedit-mode)
(define-key esc-map (kbd "C-;") 'iedit-execute-last-modification)
-(define-key help-map (kbd "C-;") 'iedit-mode-defun)
+(define-key help-map (kbd "C-;") 'iedit-mode-function)
(define-key global-map [C-return] 'iedit-rectangle-mode)
(defvar iedit-last-initial-string-global nil
@@ -332,7 +332,7 @@ This is like `describe-bindings', but displays only Iedit
keys."
(define-key map (kbd "M-B") 'iedit-toggle-buffering)
(define-key map (kbd "M-<") 'iedit-first-occurrence)
(define-key map (kbd "M->") 'iedit-last-occurrence)
- (define-key map (kbd "M-H") 'iedit-restrict-defun)
+ (define-key map (kbd "M-H") 'iedit-restrict-function)
(define-key map (kbd "C-?") 'iedit-help-for-occurrences)
map)
"Keymap used within overlays in iedit mode.")
@@ -358,7 +358,7 @@ This is like `describe-bindings', but displays only Iedit
keys."
(substitute-command-keys "\\[iedit-toggle-buffering]")
":buffering "
(substitute-command-keys "\\[iedit-first-occurrence]") "/"
(substitute-command-keys "\\[iedit-last-occurrence]")
":first/last "
- (substitute-command-keys "\\[iedit-restrict-defun]")
":restrict "
+ (substitute-command-keys "\\[iedit-restrict-function]")
":restrict "
(if iedit-rectangle
(concat
(substitute-command-keys "\\[iedit-kill-rectangle]")
":kill")))))
@@ -464,8 +464,8 @@ Commands:
(iedit-start occurrence beg end))))
;;;###autoload
-(defun iedit-mode-defun ()
- "Toggle `iedit-mode' on currenct defun."
+(defun iedit-mode-function ()
+ "Toggle `iedit-mode' on currenct function."
(interactive)
(iedit-mode 0))
@@ -501,7 +501,6 @@ Commands:
(setq iedit-current-keymap iedit-occurrence-keymap)
(iedit-refresh occurrence-exp beg end)
(run-hooks 'iedit-mode-hook)
- ;; (add-hook 'mouse-leave-buffer-hook 'iedit-done)
(add-hook 'kbd-macro-termination-hook 'iedit-done))
(defun iedit-refresh (occurrence-exp beg end)
@@ -527,8 +526,8 @@ Commands:
(iedit-hide-unmatched-lines iedit-occurrence-context-lines)))
(message "%d matches for \"%s\"" counter (iedit-printable
occurrence-exp))
(setq iedit-mode (propertize (concat " Iedit:" (number-to-string
counter))
- 'face 'font-lock-warning-face))))
- (force-mode-line-update))
+ 'face 'font-lock-warning-face))
+ (force-mode-line-update))))
(defun iedit-rectangle-start (beg end)
"Start an iedit for the region as a rectangle."
@@ -563,16 +562,17 @@ Commands:
(add-hook 'kbd-macro-termination-hook 'iedit-done))
(defun iedit-done ()
- "Exit iedit mode."
+ "Exit iedit mode.
+Save the current occurrence string locally and globally. Save
+the initial string globally."
(if iedit-buffering
(iedit-stop-buffering))
(when (null iedit-rectangle)
(setq iedit-last-occurrence-local (iedit-current-occurrence-string))
- (when (not (string= iedit-initial-string-local
iedit-last-occurrence-local))
- (setq iedit-last-occurrence-global iedit-last-occurrence-local)
- (setq iedit-only-complete-symbol-global iedit-only-complete-symbol-local)
- (setq iedit-last-initial-string-global iedit-initial-string-local)
- (setq iedit-case-sensitive-global iedit-case-sensitive-local)))
+ (setq iedit-last-occurrence-global iedit-last-occurrence-local)
+ (setq iedit-only-complete-symbol-global iedit-only-complete-symbol-local)
+ (setq iedit-last-initial-string-global iedit-initial-string-local)
+ (setq iedit-case-sensitive-global iedit-case-sensitive-local))
(remove-overlays nil nil iedit-occurrence-overlay-name t)
(iedit-show-all)
(setq iedit-occurrences-overlays nil)
@@ -587,7 +587,8 @@ Commands:
(defun iedit-execute-last-modification (&optional arg)
"Apply last modification in iedit mode to the current buffer or an active
region."
(interactive "*P")
- (or iedit-last-initial-string-global
+ (or (and iedit-last-initial-string-global
+ (not (string= iedit-last-initial-string-global
iedit-last-occurrence-global)))
(error "No modification available"))
(let ((occurrence-exp (regexp-quote iedit-last-initial-string-global))
(replacement iedit-last-occurrence-global)
@@ -598,12 +599,9 @@ Commands:
(setq replacement (downcase replacement)))
(if iedit-only-complete-symbol-global
(setq occurrence-exp (concat "\\_<" occurrence-exp "\\_>")))
- (if (iedit-region-active)
- (progn
+ (when (iedit-region-active)
(setq beg (region-beginning))
(setq end (region-end)))
- (setq beg (point-min))
- (setq end (point-max)))
(perform-replace occurrence-exp replacement t t nil nil nil beg end)))
(defun iedit-make-occurrence-overlay (begin end)
@@ -849,7 +847,8 @@ value of `iedit-occurrence-context-lines' is used for this
time."
"Apply last global modification."
(interactive "*")
(if (and iedit-last-initial-string-global
- (string= iedit-initial-string-local
iedit-last-initial-string-global))
+ (string= iedit-initial-string-local
iedit-last-initial-string-global)
+ (not (string= iedit-last-initial-string-global
iedit-last-occurrence-global)))
(iedit-replace-occurrences iedit-last-occurrence-global)
(message "No global modification available.")))
@@ -997,8 +996,8 @@ The behavior is the same as `kill-rectangle' in rect mode."
(cadr iedit-rectangle)
fill)))
-(defun iedit-restrict-defun(&optional arg)
- "Restricting iedit mode in current defun."
+(defun iedit-restrict-function(&optional arg)
+ "Restricting iedit mode in current function."
(interactive "P")
(save-excursion
(mark-defun)
- [nongnu] elpa/iedit 78f606d4fc 045/301: Add iedit-number-occurrences function, (continued)
- [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
- [nongnu] elpa/iedit 5ab980908c 050/301: Update documents, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 799a0d17d1 053/301: Bump to version 0.94, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 00abe88e13 061/301: Hide line-feed between occurrence, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit bd8c116489 062/301: Add new occurrence function iedit-restrict-defun, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 7ebea0f43b 070/301: Add tests for iedit-rectangle, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit e5f083f977 072/301: Add testcase for iedit-restrict-defun, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 62d2a5ac45 077/301: Fix iedit-kill-rectangle problem, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 8559638b9b 076/301: Fix C-u C-u iedit-last-inital-string-global problem,
ELPA Syncer <=
- [nongnu] elpa/iedit 3ead6c6d3b 074/301: run checkdoc, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit ac2faa29d0 075/301: Add iedit-mode-defun and global key binding, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 09c5063668 088/301: Merge pull request #10 from lewang/master, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 5ad28b5ea0 003/301: updates, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 6e49225083 042/301: Add iedit-toggle-case-sensitive, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit a8cbb6838b 047/301: Add iedit-kill-rectangle to iedit-rect mode and adjust keymap help, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 16ed986c33 066/301: Update document, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit f8c930f073 068/301: Add org markup, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 6300ca95d0 084/301: Update document with "narrowing" information, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 641d062b1b 081/301: Update documents, ELPA Syncer, 2022/01/10