Skip to content
Browse files

Fix iedit-blank-occurrences broken with rectangles problem

Fix iedit-blank-occurrences broken with rectangles problem

Add .bzrignore
  • Loading branch information...
1 parent c5ab2c5 commit b9d97fa50ee96176021b0acbdd216cd39e853b97 @victorhge victorhge committed Jul 9, 2012
Showing with 29 additions and 5 deletions.
  1. +2 −1 .gitignore
  2. +18 −2 iedit-tests.el
  3. +9 −2 iedit.el
View
3 .gitignore
@@ -1,2 +1,3 @@
*.elc
-
+.bzr
+.bzrignore
View
20 iedit-tests.el
@@ -2,9 +2,9 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-03-05 17:25:42 Victor Ren>
+;; Time-stamp: <2012-07-09 11:01:56 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
-;; Version: 0.94
+;; Version: 0.97
;; X-URL: http://www.emacswiki.org/emacs/Iedit
;; This file is not part of GNU Emacs, but it is distributed under
@@ -289,6 +289,22 @@ foo"
(iedit-blank-occurrences)
(should (string= (buffer-string) " barfoo ")))))
+(ert-deftest iedit-blank-occurrences-rectangle-test ()
+ "Test functions deal with the whole occurrences"
+ (with-iedit-test-fixture
+"foo
+ foo barfoo foo"
+ (lambda ()
+ (iedit-mode) ; turn off iedit
+ (goto-char 2)
+ (set-mark-command nil)
+ (forward-char 1)
+ (forward-line 1)
+ (iedit-rectangle-mode)
+ (iedit-blank-occurrences)
+ (should (string= (buffer-string) "f o
+ oo barfoo foo")))))
+
(ert-deftest iedit-delete-occurrences-test ()
"Test functions deal with the whole occurrences"
(with-iedit-test-fixture
View
11 iedit.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-07-04 10:07:47 Victor Ren>
+;; Time-stamp: <2012-07-09 10:45:56 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous rectangle refactoring
;; Version: 0.97
@@ -365,6 +365,7 @@ This is like `describe-bindings', but displays only Iedit keys."
(or (assq 'iedit-mode minor-mode-map-alist)
(setq minor-mode-map-alist
(cons (cons 'iedit-mode iedit-mode-map) minor-mode-map-alist)))
+
;; Avoid to restore Iedit mode when restoring desktop
(add-to-list 'desktop-minor-mode-handlers
'(iedit-mode . nil))
@@ -896,8 +897,14 @@ This function preserves case."
"Replace occurrences with blank spaces."
(interactive "*")
(let* ((ov (car iedit-occurrences-overlays))
+ (offset (- (point) (overlay-start ov)))
(count (- (overlay-end ov) (overlay-start ov))))
- (iedit-replace-occurrences (make-string count 32))))
+ (iedit-apply-on-occurrences
+ (lambda (beg end )
+ (delete-region beg end)
+ (goto-char beg)
+ (insert-and-inherit (make-string count 32))))
+ (goto-char (+ (overlay-start ov) offset))))
(defun iedit-delete-occurrences()
"Delete occurrences."

0 comments on commit b9d97fa

Please sign in to comment.
Something went wrong with that request. Please try again.