Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Add digit prefix argment 0 to enable restricting match in a function

  • Loading branch information...
commit 90ef2d5ac9ca10f28f175d11867eb2ea02ef33af 1 parent b579dd0
@victorhge authored
Showing with 26 additions and 13 deletions.
  1. +1 −1  README
  2. +25 −12 iedit.el
2  README
@@ -8,7 +8,7 @@ Most common scenario of using this package is renaming refactoring
during programming. Several enhancements are done to make it easier:
- The symbol under point can be selected as occurrence by one key and only complete
symbols are matched
- - Restrict symbols in current defun only by one command
+ - Restricting symbols in current function matched could be done by one command
- Remember the renaming refactoring and re-apply to other buffers later
This package also provides rectangle support with visible rectangle
37 iedit.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-02-24 01:23:14 Victor Ren>
+;; Time-stamp: <2012-02-25 00:37:29 Victor Ren>
;; Author: Victor Ren <>
;; Keywords: occurrence region replace simultaneous
;; Version: 0.94
@@ -356,12 +356,13 @@ occurrences simultaneously.
If Transient Mark mode is disabled or the region is not active,
the current symbol (returns from `current-word') is used as the
-occurrence by default. The occurrences of the current
-symbol, but not include occurrences that are part of other
-symbols, are highlighted. This is good for renaming refactoring
-during programming. If you still want to match all the
-occurrences, even though they are parts of other symbols, you may
-have to select the symbol first.
+occurrence by default. The occurrences of the current symbol,
+but not include occurrences that are part of other symbols, are
+highlighted. With digit prefix argument 0, only symbols in
+current function are matched. This is good for renaming
+refactoring during programming. If you still want to match all
+the occurrences, even though they are parts of other symbols, you
+may have to select the symbol first.
You can also switch to iedit mode from isearch mode directly. The
current search string is used as occurrence. All occurrences of
@@ -402,7 +403,9 @@ Commands:
(iedit-restrict-region beg end arg)
- (let (occurrence complete-symbol rect-string)
+ (let (occurrence complete-symbol rect-string
+ (beg (point-min))
+ (end (point-max)))
(cond ((and arg
(or (not transient-mark-mode) (not mark-active)
(equal (mark) (point))))
@@ -414,6 +417,16 @@ Commands:
(setq occurrence iedit-last-initial-string-global)
(setq complete-symbol iedit-only-complete-symbol-global))
+ ((and (= 0 (prefix-numeric-value arg))
+ iedit-current-symbol-default
+ (current-word t))
+ (setq occurrence (current-word))
+ (when iedit-only-at-symbol-boundaries
+ (setq complete-symbol t))
+ (save-excursion
+ (mark-defun)
+ (setq beg (region-beginning))
+ (setq end (region-end))))
(t (error "No candidate of the occurrence, cannot enable iedit mode."))))
((and arg
transient-mark-mode mark-active (not (equal (mark) (point))))
@@ -438,15 +451,15 @@ Commands:
(iedit-rectangle-start beg end))
(setq iedit-case-sensitive-local iedit-case-sensitive-default)
- (iedit-start occurrence)))))
+ (iedit-start occurrence beg end)))))
-(defun iedit-start (occurrence-exp)
+(defun iedit-start (occurrence-exp beg end)
"Start an iedit for the occurrence-exp in the current buffer."
(setq iedit-unmatched-lines-invisible iedit-unmatched-lines-invisible-default)
(setq iedit-aborting nil)
(setq iedit-rectangle nil)
(setq iedit-current-keymap iedit-occurrence-keymap)
- (iedit-refresh occurrence-exp (point-min) (point-max))
+ (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))
@@ -1009,7 +1022,7 @@ Return nil if occurrence string is empty string."
(setq iedit-last-occurrence-local (iedit-current-occurrence-string))
- (iedit-cleanup-occurrences-overlays beg end arg)
+ (iedit-cleanup-occurrences-overlays beg end inclusive)
(if iedit-unmatched-lines-invisible
(iedit-hide-unmatched-lines iedit-occurrence-context-lines))
(setq iedit-mode (propertize

0 comments on commit 90ef2d5

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