Created
February 9, 2010 13:31
-
-
Save myuhe/299199 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun iedit-mode () | |
"Toggle iedit mode. | |
If iedit mode is off, turn iedit mode on using active region as | |
input, off otherwise. | |
In iedit mode, all the occurrences of the input region are | |
highlighted. If one occurrence is modified, the change are | |
propagated to all other occurrences simultaneously. | |
If the region is not active, the `current-word' is used as | |
input. All the occurrences of the `current-word' are highlighted. | |
You can also switch to iedit mode from isearch mode directly. | |
All occurrences of isearch-string are highlighted. | |
Commands: | |
\\{iedit-mode-map}" | |
;;(interactive "r") | |
(interactive) | |
(if iedit-mode | |
(iedit-done) | |
(let ((occurrence nil)) | |
(cond | |
((and mark-active (not (equal (region-beginning) (region-end)))) | |
(setq occurrence (buffer-substring (region-beginning) (region-end)))) | |
((and isearch-mode (not (string= isearch-string ""))) | |
(setq occurrence isearch-string) | |
(isearch-exit)) | |
((and iedit-symbol-at-point (current-word t)) | |
(setq occurrence (current-word))) | |
(t (error "No region selected, cannot enable iedit mode."))) | |
(deactivate-mark) | |
(iedit-start occurrence)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment