Skip to content
Newer
Older
100644 511 lines (432 sloc) 19.3 KB
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
1 ;;; iedit.el --- Edit multiple regions in the same way simultaneously.
2
3 ;; Copyright (C) 2010, 2011, 2012 Victor Ren
4
9cfd76f @victorhge Toggle case-sensitive with intial region
authored Sep 12, 2012
5 ;; Time-stamp: <2012-09-12 15:22:33 Victor Ren>
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
6 ;; Author: Victor Ren <victorhge@gmail.com>
6f80f88 @victorhge Differentiate lib keymap and occurrence keymap
authored Aug 24, 2012
7 ;; Keywords: occurrence region simultaneous refactoring
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
8 ;; Version: 0.97
9 ;; X-URL: http://www.emacswiki.org/emacs/Iedit
10 ;; Compatibility: GNU Emacs: 22.x, 23.x, 24.x
11
12 ;; This file is not part of GNU Emacs, but it is distributed under
13 ;; the same terms as GNU Emacs.
14
15 ;; GNU Emacs is free software: you can redistribute it and/or modify
16 ;; it under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation, either version 3 of the License, or
18 ;; (at your option) any later version.
19
20 ;; GNU Emacs is distributed in the hope that it will be useful,
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;; GNU General Public License for more details.
24
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27
28 ;;; Commentary:
29
30 ;; This package is an Emacs minor mode and allows you to edit one occurrence of
31 ;; some text in a buffer (possibly narrowed) or region, and simultaneously have
32 ;; other occurrences edited in the same way.
33 ;;
34 ;; Normal scenario of iedit-mode is like:
35 ;;
36 ;; - Highlight certain contents - by press C-;
6f80f88 @victorhge Differentiate lib keymap and occurrence keymap
authored Aug 24, 2012
37 ;; All occurrences of a symbol, string in the buffer or a region may be
38 ;; highlighted corresponding to current mark, point and prefix argument.
39 ;; Refer to the document of `iedit-mode' for details.
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
40 ;;
41 ;; - Edit one of the occurrences
42 ;; The change is applied to other occurrences simultaneously.
43 ;;
44 ;; - Finish - by pressing C-; again
45 ;;
46 ;; You can also use Iedit mode as a quick way to temporarily show only the
47 ;; buffer lines that match the current text being edited. This gives you the
48 ;; effect of a temporary `keep-lines' or `occur'. To get this effect, hit C-'
49 ;; when in Iedit mode - it toggles hiding non-matching lines.
50 ;;
51 ;; Renaming refactoring is convenient in Iedit mode
52 ;;
53 ;; - The symbol under point is selected as occurrence by default and only
54 ;; complete symbols are matched
55 ;; - With digit prefix argument 0, only symbols in current function are matched
56 ;; - Restricting symbols in current region can be done by pressing C-; again
57 ;; - Last renaming refactoring is remembered and can be applied to other buffers
58 ;; later
59 ;;
60 ;; There are also some other facilities you may never think about. Refer to the
61 ;; document of function `iedit-mode' (C-h f iedit-mode RET) for more details.
62
63 ;; The code was developed and fully tested on Gnu Emacs 24.0.93, partially
64 ;; tested on Gnu Emacs 22. If you have any compatible problem, please let me
65 ;; know.
66
67 ;;; todo:
68 ;; - Add more easy access keys for whole occurrence
69
70 ;;; Contributors
71 ;; Adam Lindberg <eproxus@gmail.com> added a case sensitivity option that can be toggled.
72
73 ;; Tassilo Horn <tassilo@member.fsf.org> added an option to match only complete
74 ;; words, not inside words
75
76 ;; Le Wang <l26wang@gmail.com> proposed to match only complete symbols, not
77 ;; inside symbols, contributed rectangle support
78
79 ;;; Code:
80
81 (eval-when-compile (require 'cl))
82 (require 'iedit-lib)
83
84 (defcustom iedit-current-symbol-default t
85 "If no-nil, use current symbol by default for the occurrence."
86 :type 'boolean
87 :group 'iedit)
88
89 (defcustom iedit-only-at-symbol-boundaries t
90 "If no-nil, matches have to start and end at symbol boundaries.
91 For example, when invoking command `iedit-mode' on the \"in\" in the
92 sentence \"The king in the castle...\", the \"king\" is not
93 edited."
94 :type 'boolean
95 :group 'iedit)
96
9cfd76f @victorhge Toggle case-sensitive with intial region
authored Sep 12, 2012
97 (defcustom iedit-toggle-key-default (kbd "C-;")
21a60f2 @victorhge Add toogle key option
authored Aug 31, 2012
98 "If no-nil, the key is inserted into global-map, isearch-mode-map, esc-map and help-map."
99 :type 'vector
100 :group 'iedit)
101
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
102 (defvar iedit-mode-hook nil
103 "Function(s) to call after starting up an iedit.")
104
105 (defvar iedit-mode-end-hook nil
106 "Function(s) to call after terminating an iedit.")
107
108 (defvar iedit-mode nil) ;; Name of the minor mode
109
110 (defvar iedit-only-complete-symbol-local nil
111 "This is buffer local variable which indicates the occurrence
112 only matches complete symbol.")
113
114 (defvar iedit-only-complete-symbol-global nil
115 "This is global variable which indicates the last global occurrence
116 only matches complete symbol.")
117
118 (defvar iedit-last-occurrence-local nil
119 "This is buffer local variable which is the occurrence when
120 Iedit mode is turned off last time.")
121
122 (defvar iedit-last-occurrence-global nil
123 "This is global variable which is the occurrence when
124 Iedit mode is turned off last time.")
125
126 (defvar iedit-last-initial-string-global nil
127 "This is a global variable which is the last initial occurrence string.")
128
129 (defvar iedit-initial-string-local nil
130 "This is buffer local variable which is the initial string to start Iedit mode.")
9cfd76f @victorhge Toggle case-sensitive with intial region
authored Sep 12, 2012
131 (defvar iedit-initial-region nil
132 "This is buffer local variable which is the initial region
133 where Iedit mode is started from.")
134
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
135
136 (make-variable-buffer-local 'iedit-mode)
137 (make-variable-buffer-local 'iedit-only-complete-symbol-local)
138 (make-variable-buffer-local 'iedit-last-occurrence-local)
6f80f88 @victorhge Differentiate lib keymap and occurrence keymap
authored Aug 24, 2012
139 (make-variable-buffer-local 'iedit-initial-string-local)
9cfd76f @victorhge Toggle case-sensitive with intial region
authored Sep 12, 2012
140 (make-variable-buffer-local 'iedit-initial-region)
141
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
142
143 (or (assq 'iedit-mode minor-mode-alist)
144 (nconc minor-mode-alist
145 (list '(iedit-mode iedit-mode))))
146
b94c75e @victorhge Move iedit-help-keymap to iedit.el
authored Aug 24, 2012
147 ;;; Define iedit help map.
148 (eval-when-compile (require 'help-macro))
149
150 (defvar iedit-help-map
151 (let ((map (make-sparse-keymap)))
152 (define-key map (char-to-string help-char) 'iedit-help-for-help)
153 (define-key map [help] 'iedit-help-for-help)
154 (define-key map [f1] 'iedit-help-for-help)
155 (define-key map "?" 'iedit-help-for-help)
156 (define-key map "b" 'iedit-describe-bindings)
157 (define-key map "k" 'iedit-describe-key)
158 (define-key map "m" 'iedit-describe-mode)
159 (define-key map "q" 'help-quit)
160 map)
161 "Keymap for characters following the Help key for Iedit mode.")
162
163 (make-help-screen
164 iedit-help-for-help-internal
165 (purecopy "Type a help option: [bkm] or ?")
166 "You have typed %THIS-KEY%, the help character. Type a Help option:
167 \(Type \\<help-map>\\[help-quit] to exit the Help command.)
168
169 b Display all Iedit key bindings.
170 k KEYS Display full documentation of Iedit key sequence.
171 m Display documentation of Iedit mode.
172
173 You can't type here other help keys available in the global help map,
174 but outside of this help window when you type them in Iedit mode,
175 they exit Iedit mode before displaying global help."
176 iedit-help-map)
177
178 (defun iedit-help-for-help ()
179 "Display Iedit help menu."
180 (interactive)
181 (let (same-window-buffer-names same-window-regexps)
182 (iedit-help-for-help-internal)))
183
184 (defun iedit-describe-bindings ()
185 "Show a list of all keys defined in Iedit mode, and their definitions.
186 This is like `describe-bindings', but displays only Iedit keys."
187 (interactive)
188 (let (same-window-buffer-names
189 same-window-regexps
190 (keymap (substitute-command-keys "\\{iedit-mode-keymap}\\{iedit-mode-occurrence-keymap}")))
191 (with-help-window "*Help*"
192 (with-current-buffer standard-output
193 (princ "Iedit Mode Bindings: ")
194 (princ keymap)))))
195
196 (defun iedit-describe-key ()
197 "Display documentation of the function invoked by Iedit mode key."
198 (interactive)
199 (let (same-window-buffer-names same-window-regexps)
200 (call-interactively 'describe-key)))
201
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
202 (defun iedit-describe-mode ()
203 "Display documentation of Iedit mode."
204 (interactive)
205 (let (same-window-buffer-names same-window-regexps)
206 (describe-function 'iedit-mode)))
207
208 ;;; Default key bindings:
9cfd76f @victorhge Toggle case-sensitive with intial region
authored Sep 12, 2012
209 (when iedit-toggle-key-default
210 (define-key global-map iedit-toggle-key-default 'iedit-mode)
211 (define-key isearch-mode-map iedit-toggle-key-default 'iedit-mode-from-isearch)
212 (define-key esc-map iedit-toggle-key-default 'iedit-execute-last-modification)
213 (define-key help-map iedit-toggle-key-default 'iedit-mode-toggle-on-function))
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
214
215 ;; Avoid to restore Iedit mode when restoring desktop
216 (add-to-list 'desktop-minor-mode-handlers
217 '(iedit-mode . nil))
218
219 ;;; Define iedit help map.
220 (eval-when-compile (require 'help-macro))
221
6f80f88 @victorhge Differentiate lib keymap and occurrence keymap
authored Aug 24, 2012
222 (defvar iedit-mode-occurrence-keymap
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
223 (let ((map (make-sparse-keymap)))
6f80f88 @victorhge Differentiate lib keymap and occurrence keymap
authored Aug 24, 2012
224 (set-keymap-parent map iedit-occurrence-keymap-default)
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
225 (define-key map (kbd "M-H") 'iedit-restrict-function)
226 (define-key map (kbd "M-C") 'iedit-toggle-case-sensitive)
227 map)
228 "Keymap used within overlays in Iedit mode.")
229
6f80f88 @victorhge Differentiate lib keymap and occurrence keymap
authored Aug 24, 2012
230 (defvar iedit-mode-keymap
231 (let ((map (make-sparse-keymap)))
232 (set-keymap-parent map iedit-lib-keymap)
b94c75e @victorhge Move iedit-help-keymap to iedit.el
authored Aug 24, 2012
233 (define-key map (char-to-string help-char) iedit-help-map)
234 (define-key map [help] iedit-help-map)
235 (define-key map [f1] iedit-help-map)
6f80f88 @victorhge Differentiate lib keymap and occurrence keymap
authored Aug 24, 2012
236 map)
237 "Keymap used while Iedit mode is enabled.")
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
238
239 ;;; Define Iedit mode map
240 (or (assq 'iedit-mode minor-mode-map-alist)
241 (setq minor-mode-map-alist
242 (cons (cons 'iedit-mode iedit-mode-keymap) minor-mode-map-alist)))
243
244 ;; Avoid to restore Iedit mode when restoring desktop
245 (add-to-list 'desktop-minor-mode-handlers
246 '(iedit-mode . nil))
247
248 ;;;###autoload
249 (defun iedit-mode (&optional arg)
250 "Toggle Iedit mode.
251 This command behaves differently, depending on the mark, point,
252 prefix argument and variable `iedit-transient-mark-sensitive'.
253
254 If Iedit mode is off, turn Iedit mode on.
255
256 When Iedit mode is turned on, all the occurrences of the current
257 region in the buffer (possibly narrowed) or a region are
258 highlighted. If one occurrence is modified, the change are
259 propagated to all other occurrences simultaneously.
260
261 If region is not active, the current symbol (returns from
262 `current-word') is used as the occurrence by default. The
263 occurrences of the current symbol, but not include occurrences
264 that are part of other symbols, are highlighted. If you still
265 want to match all the occurrences, even though they are parts of
266 other symbols, you may have to mark the symbol first.
267
268 In the above two situations, with digit prefix argument 0, only
269 occurrences in current function are matched. This is good for
270 renaming refactoring in programming.
271
272 You can also switch to Iedit mode from isearch mode directly. The
273 current search string is used as occurrence. All occurrences of
274 the current search string are highlighted.
275
276 With an universal prefix argument, the occurrence when Iedit mode
277 is turned off last time in current buffer is used as occurrence.
278 This is intended to recover last Iedit mode which is turned off.
279 If region active, Iedit mode is limited within the current
280 region.
281
282 With repeated universal prefix argument, the occurrence when
e4d67bd @victorhge Separate iedit-mode-from-isearch
authored Sep 7, 2012
283 Iedit mode is turned off last time (might be in other buffer) is
284 used as occurrence. If region active, Iedit mode is limited
285 within the current region.
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
286
287 If Iedit mode is on and region is active, Iedit mode is
6f80f88 @victorhge Differentiate lib keymap and occurrence keymap
authored Aug 24, 2012
288 restricted in the region, e.g. the occurrences outside of the
289 region is excluded.
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
290
291 If Iedit mode is on and region is active, with an universal
292 prefix argument, Iedit mode is restricted outside of the region,
293 e.g. the occurrences in the region is excluded.
294
295 Turn off Iedit mode in other situations.
296
297 Commands:
b94c75e @victorhge Move iedit-help-keymap to iedit.el
authored Aug 24, 2012
298 \\{iedit-mode-keymap}
299 Keymap used within overlays:
300 \\{iedit-mode-occurrence-keymap}"
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
301 (interactive "P")
302 (if iedit-mode
303 (progn
304 (iedit-mode-on-action arg)
305 (setq iedit-only-complete-symbol-global iedit-only-complete-symbol-local))
306 (iedit-barf-if-lib-active)
307 (let (occurrence
308 complete-symbol
309 (beg (if (eq major-mode 'occur-edit-mode) ; skip the first occurrence
310 (next-single-char-property-change 1 'read-only)
311 (point-min)))
312 (end (point-max)))
313 (cond ((and arg
314 (= 4 (prefix-numeric-value arg))
315 iedit-last-occurrence-local)
316 (setq occurrence iedit-last-occurrence-local)
317 (setq complete-symbol iedit-only-complete-symbol-local))
318 ((and arg
319 (= 16 (prefix-numeric-value arg))
320 iedit-last-initial-string-global)
321 (setq occurrence iedit-last-initial-string-global)
322 (setq complete-symbol iedit-only-complete-symbol-global))
323 ((iedit-region-active)
324 (setq occurrence (buffer-substring-no-properties
325 (mark) (point))))
326 ((and iedit-current-symbol-default (current-word t))
327 (setq occurrence (current-word))
328 (when iedit-only-at-symbol-boundaries
329 (setq complete-symbol t)))
330 (t (error "No candidate of the occurrence, cannot enable Iedit mode")))
331 (when arg
332 (if (= 0 (prefix-numeric-value arg))
333 (save-excursion
334 (mark-defun)
335 (setq beg (region-beginning))
336 (setq end (region-end)))
337 (when (iedit-region-active)
338 (setq beg (region-beginning))
339 (setq end (region-end)))))
340 (setq iedit-only-complete-symbol-local complete-symbol)
8ff86b7 @victorhge Replace "(set-mark nil)" with (setq mark-active nil)"
authored Aug 31, 2012
341 (setq mark-active nil)
342 (run-hooks 'deactivate-mark-hook)
e4d67bd @victorhge Separate iedit-mode-from-isearch
authored Sep 7, 2012
343 (iedit-start (iedit-regexp-quote occurrence) beg end))))
344
345 (defun iedit-mode-from-isearch (regexp)
346 "Start Iedit mode using last search string as the regexp."
347 (interactive
348 (let ((regexp (cond
349 ((functionp isearch-word)
350 (funcall isearch-word isearch-string))
351 (isearch-word (word-search-regexp isearch-string))
352 (isearch-regexp isearch-string)
353 (t (regexp-quote isearch-string)))))
354 (list regexp)))
355 (isearch-exit)
356 (iedit-start regexp (point-min) (point-max))
357 ;; TODO: reconsider how to avoid the loop in iedit-same-length
358 (if (iedit-same-length)
359 nil
360 (iedit-done)
361 (message "Matches are not the same length.")))
362
363 (defun iedit-start (occurrence-regexp beg end)
364 "Start Iedit mode for the `occurrence-regexp' in the current buffer."
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
365 (setq iedit-unmatched-lines-invisible iedit-unmatched-lines-invisible-default)
e4d67bd @victorhge Separate iedit-mode-from-isearch
authored Sep 7, 2012
366 (setq iedit-initial-string-local occurrence-regexp)
9cfd76f @victorhge Toggle case-sensitive with intial region
authored Sep 12, 2012
367 (setq iedit-initial-region (list beg end))
e4d67bd @victorhge Separate iedit-mode-from-isearch
authored Sep 7, 2012
368 (iedit-start2 occurrence-regexp beg end)
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
369 (run-hooks 'iedit-mode-hook)
370 (add-hook 'kbd-macro-termination-hook 'iedit-done nil t)
371 (add-hook 'change-major-mode-hook 'iedit-done nil t)
372 (add-hook 'iedit-aborting-hook 'iedit-done nil t))
373
e4d67bd @victorhge Separate iedit-mode-from-isearch
authored Sep 7, 2012
374 (defun iedit-regexp-quote (exp)
375 "Return a regexp string."
376 (if iedit-only-complete-symbol-local
377 (concat "\\_<" (regexp-quote exp) "\\_>")
378 (regexp-quote exp)))
379
380 (defun iedit-start2 (occurrence-regexp beg end)
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
381 "Refresh Iedit mode."
29869eb @victorhge Add buffer local variable iedit-occurrence-keymap
authored Sep 5, 2012
382 (setq iedit-occurrence-keymap iedit-mode-occurrence-keymap)
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
383 (setq iedit-mode
384 (propertize
385 (concat " Iedit:"
386 (number-to-string
e4d67bd @victorhge Separate iedit-mode-from-isearch
authored Sep 7, 2012
387 (iedit-make-occurrences-overlays occurrence-regexp beg end)))
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
388 'face
389 'font-lock-warning-face))
390 (force-mode-line-update))
391
392 (defun iedit-done ()
393 "Exit Iedit mode.
394 Save the current occurrence string locally and globally. Save
395 the initial string globally."
396 (when iedit-buffering
397 (iedit-stop-buffering))
398 (setq iedit-last-occurrence-local (iedit-current-occurrence-string))
399 (setq iedit-last-occurrence-global iedit-last-occurrence-local)
400 (setq iedit-last-initial-string-global iedit-initial-string-local)
401
1c410fc @victorhge Fix iedit-number-occurrences with conjointed occurrences problem
authored Aug 10, 2012
402 (iedit-cleanup)
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
403
404 (setq iedit-mode nil)
405 (force-mode-line-update)
406 (remove-hook 'kbd-macro-termination-hook 'iedit-done t)
407 (remove-hook 'change-major-mode-hook 'iedit-done t)
408 (remove-hook 'iedit-aborting-hook 'iedit-done t)
409 (run-hooks 'iedit-mode-end-hook))
410
411 (defun iedit-mode-on-action (&optional arg)
412 "Turn off Iedit mode or restrict it in a region if region is active."
413 (if (iedit-region-active)
414 ;; Restrict iedit-mode
415 (let ((beg (region-beginning))
416 (end (region-end)))
417 (if (null (iedit-find-overlay beg end 'iedit-occurrence-overlay-name arg))
418 (iedit-done)
419 (iedit-restrict-region beg end arg)
420 (iedit-first-occurrence)))
421 (iedit-done)))
422
423
424 ;;;###autoload
425 (defun iedit-mode-toggle-on-function ()
426 "Toggle Iedit mode on current function."
427 (interactive)
428 (iedit-mode 0))
429
430 (defun iedit-execute-last-modification (&optional arg)
431 "Apply last modification in Iedit mode to the current buffer or an active region."
432 (interactive "*P")
433 (or (and iedit-last-initial-string-global
434 (not (string= iedit-last-initial-string-global iedit-last-occurrence-global)))
435 (error "No modification available"))
436 (let ((occurrence-exp (regexp-quote iedit-last-initial-string-global))
437 (replacement iedit-last-occurrence-global)
e4d67bd @victorhge Separate iedit-mode-from-isearch
authored Sep 7, 2012
438 (case-fold-search (not iedit-case-sensitive))
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
439 beg end)
440 (when case-fold-search
441 (setq occurrence-exp (downcase occurrence-exp))
442 (setq replacement (downcase replacement)))
443 (if iedit-only-complete-symbol-global
444 (setq occurrence-exp (concat "\\_<" occurrence-exp "\\_>")))
445 (when (iedit-region-active)
446 (setq beg (region-beginning))
447 (setq end (region-end)))
448 (perform-replace occurrence-exp replacement t t nil nil nil beg end)))
449
450 (defun iedit-apply-global-modification ()
451 "Apply last global modification."
452 (interactive "*")
453 (if (and iedit-last-initial-string-global
454 (string= iedit-initial-string-local iedit-last-initial-string-global)
455 (not (string= iedit-last-initial-string-global iedit-last-occurrence-global)))
456 (iedit-replace-occurrences iedit-last-occurrence-global)
457 (message "No global modification available.")))
458
459
460 (defun iedit-restrict-function(&optional arg)
461 "Restricting Iedit mode in current function."
462 (interactive "P")
463 (save-excursion
464 (mark-defun)
76eeb87 @victorhge Add feekback message for iedit-restrict-function
authored Aug 10, 2012
465 (iedit-restrict-region (region-beginning) (region-end) arg))
466 (message "Restricted in current function, %d matches."
467 (length iedit-occurrences-overlays)))
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
468
469 (defun iedit-restrict-region (beg end &optional inclusive)
470 "Restricting Iedit mode in a region."
471 (when iedit-buffering
472 (iedit-stop-buffering))
473 (setq iedit-last-occurrence-local (iedit-current-occurrence-string))
8ff86b7 @victorhge Replace "(set-mark nil)" with (setq mark-active nil)"
authored Aug 31, 2012
474 (setq mark-active nil)
475 (run-hooks 'deactivate-mark-hook)
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
476 (iedit-show-all)
477 (iedit-cleanup-occurrences-overlays beg end inclusive)
478 (if iedit-unmatched-lines-invisible
479 (iedit-hide-unmatched-lines iedit-occurrence-context-lines))
480 (setq iedit-mode (propertize
481 (concat " Iedit:" (number-to-string
482 (length iedit-occurrences-overlays)))
483 'face 'font-lock-warning-face))
484 (force-mode-line-update))
485
486 (defun iedit-toggle-case-sensitive ()
487 "Toggle case-sensitive matching occurrences.
488 Todo: how about region"
489 (interactive)
e4d67bd @victorhge Separate iedit-mode-from-isearch
authored Sep 7, 2012
490 (setq iedit-case-sensitive (not iedit-case-sensitive))
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
491 (if iedit-buffering
492 (iedit-stop-buffering))
493 (setq iedit-last-occurrence-local (iedit-current-occurrence-string))
494 (when iedit-last-occurrence-local
495 (remove-overlays nil nil iedit-occurrence-overlay-name t)
496 (iedit-show-all)
9cfd76f @victorhge Toggle case-sensitive with intial region
authored Sep 12, 2012
497 (iedit-start2 (iedit-regexp-quote iedit-last-occurrence-local)
498 (car iedit-initial-region)
499 (cadr iedit-initial-region))))
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
500
501 (provide 'iedit)
502
503 ;;; iedit.el ends here
504
505 ;; LocalWords: iedit el MERCHANTABILITY kbd isearch todo ert Lindberg Tassilo
6f80f88 @victorhge Differentiate lib keymap and occurrence keymap
authored Aug 24, 2012
506 ;; LocalWords: eval defgroup defcustom boolean defvar assq alist nconc
d2684ee @victorhge Remove duplicate definations
authored Aug 6, 2012
507 ;; LocalWords: substring cadr keymap defconst purecopy bkm defun princ prev
508 ;; LocalWords: iso lefttab backtab upcase downcase concat setq autoload arg
509 ;; LocalWords: refactoring propertize cond goto nreverse progn rotatef eq elp
510 ;; LocalWords: dolist pos unmatch args ov sReplace iedit's cdr quote'ed
Something went wrong with that request. Please try again.