Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 24 additions and 23 deletions.
  1. +4 −6 iedit-lib.el
  2. +5 −5 iedit-tests.el
  3. +15 −12 iedit.el
View
10 iedit-lib.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-09-07 16:28:18 Victor Ren>
+;; Time-stamp: <2012-10-17 08:48:28 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous rectangle refactoring
;; Version: 0.97
@@ -376,16 +376,14 @@ occurrence, it will abort Iedit mode."
(iedit-move-conjoined-overlays another-occurrence)))
;; deletion
(dolist (another-occurrence (remove occurrence iedit-occurrences-overlays))
- (let* ((beginning (+ (overlay-start another-occurrence) offset))
- (ending (+ beginning change)))
- (delete-region beginning ending)
+ (let ((beginning (+ (overlay-start another-occurrence) offset)))
+ (delete-region beginning (+ beginning change))
(unless (eq beg end) ;; replacement
(goto-char beginning)
(insert-and-inherit value))
(run-hook-with-args 'after-change-functions
beginning
- (min ending
- (point-max))
+ (+ beginning (- beg end))
change)))))))))))))
(defun iedit-next-occurrence ()
View
10 iedit-tests.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-08-09 17:17:03 Victor Ren>
+;; Time-stamp: <2012-10-15 16:12:02 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Version: 0.97
;; X-URL: http://www.emacswiki.org/emacs/Iedit
@@ -30,6 +30,7 @@
;;; Code:
(require 'ert)
(require 'iedit)
+(require 'iedit-rect)
(ert-deftest iedit-compile-test ()
(let ((byte-compile-error-on-warn t ))
@@ -162,7 +163,7 @@ fob")))))
(isearch-process-search-char ?f)
(isearch-process-search-char ?o)
(isearch-process-search-char ?o)
- (iedit-mode)
+ (iedit-mode-from-isearch)
(should (string= iedit-initial-string-local "foo"))
(should (= 4 (length iedit-occurrences-overlays)))
(iedit-mode)
@@ -361,8 +362,7 @@ fob")))))
(iedit-mode) ; turn off iedit
(goto-char 2)
(set-mark-command nil)
- (forward-char 1)
- (forward-line 1)
+ (goto-char 7)
(iedit-rectangle-mode)
(iedit-blank-occurrences)
(should (string= (buffer-string) "f o
@@ -482,7 +482,7 @@ arfoo
(should (= 1 (length iedit-occurrences-overlays)))
(iedit-mode)
(goto-char 13)
- (iedit-mode-on-function)
+ (iedit-mode-toggle-on-function)
(should (= 4 (length iedit-occurrences-overlays)))
(iedit-mode)
(iedit-mode)
View
27 iedit.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-09-12 15:22:33 Victor Ren>
+;; Time-stamp: <2012-10-15 15:09:14 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous refactoring
;; Version: 0.97
@@ -340,30 +340,32 @@ Keymap used within overlays:
(setq iedit-only-complete-symbol-local complete-symbol)
(setq mark-active nil)
(run-hooks 'deactivate-mark-hook)
+ (setq iedit-initial-string-local occurrence)
(iedit-start (iedit-regexp-quote occurrence) beg end))))
-(defun iedit-mode-from-isearch (regexp)
+(defun iedit-mode-from-isearch ()
"Start Iedit mode using last search string as the regexp."
- (interactive
- (let ((regexp (cond
- ((functionp isearch-word)
- (funcall isearch-word isearch-string))
+ (interactive)
+ (let ((regexp (cond
(isearch-word (word-search-regexp isearch-string))
(isearch-regexp isearch-string)
(t (regexp-quote isearch-string)))))
- (list regexp)))
- (isearch-exit)
- (iedit-start regexp (point-min) (point-max))
+ (if (or isearch-regexp isearch-word)
+ nil
+ (setq iedit-initial-string-local isearch-string))
+ (isearch-exit)
+ (setq mark-active nil)
+ (run-hooks 'deactivate-mark-hook)
+ (iedit-start regexp (point-min) (point-max))
;; TODO: reconsider how to avoid the loop in iedit-same-length
- (if (iedit-same-length)
+ (if (iedit-same-length)
nil
(iedit-done)
- (message "Matches are not the same length.")))
+ (message "Matches are not the same length."))))
(defun iedit-start (occurrence-regexp beg end)
"Start Iedit mode for the `occurrence-regexp' in the current buffer."
(setq iedit-unmatched-lines-invisible iedit-unmatched-lines-invisible-default)
- (setq iedit-initial-string-local occurrence-regexp)
(setq iedit-initial-region (list beg end))
(iedit-start2 occurrence-regexp beg end)
(run-hooks 'iedit-mode-hook)
@@ -401,6 +403,7 @@ the initial string globally."
(iedit-cleanup)
+ (setq iedit-initial-string-local nil)
(setq iedit-mode nil)
(force-mode-line-update)
(remove-hook 'kbd-macro-termination-hook 'iedit-done t)

No commit comments for this range

Something went wrong with that request. Please try again.