diff options
| author | Dan Nicolaescu | 2008-07-04 00:34:02 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2008-07-04 00:34:02 +0000 |
| commit | f8b4aa4101717e1c0575fab47fc202635798e70e (patch) | |
| tree | 233ada036c18c5ff137d39aadff0375abb16ed87 | |
| parent | adb4665096b4af669f6622a0fedd7382347779a1 (diff) | |
| download | emacs-f8b4aa4101717e1c0575fab47fc202635798e70e.tar.gz emacs-f8b4aa4101717e1c0575fab47fc202635798e70e.zip | |
(vc-dir-query-replace-regexp): New function.
(vc-dir-tool-bar-map, vc-dir-menu-map): Bind it.
(vc-dir-mode-map): Likewise
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/vc-dir.el | 31 |
2 files changed, 35 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 92e6b3b4542..c4b6e2a8414 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2008-07-04 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * vc-dir.el (vc-dir-query-replace-regexp): New function. | ||
| 4 | (vc-dir-tool-bar-map, vc-dir-menu-map): Bind it. | ||
| 5 | (vc-dir-mode-map): Likewise | ||
| 6 | |||
| 1 | 2008-07-03 Juanma Barranquero <lekktu@gmail.com> | 7 | 2008-07-03 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 8 | ||
| 3 | * eshell/esh-arg.el (eshell-quote-backslash): Fix typo in docstring. | 9 | * eshell/esh-arg.el (eshell-quote-backslash): Fix typo in docstring. |
diff --git a/lisp/vc-dir.el b/lisp/vc-dir.el index 5beba0be5b9..981178a67c8 100644 --- a/lisp/vc-dir.el +++ b/lisp/vc-dir.el | |||
| @@ -156,6 +156,9 @@ See `run-hooks'." | |||
| 156 | :help "Mark the current file or all files in the region")) | 156 | :help "Mark the current file or all files in the region")) |
| 157 | 157 | ||
| 158 | (define-key map [sepopn] '("--")) | 158 | (define-key map [sepopn] '("--")) |
| 159 | (define-key map [qr] | ||
| 160 | '(menu-item "Query Replace in Files" vc-dir-query-replace-regexp | ||
| 161 | :help "Replace a string in the marked files")) | ||
| 159 | (define-key map [open-other] | 162 | (define-key map [open-other] |
| 160 | '(menu-item "Open in other window" vc-dir-find-file-other-window | 163 | '(menu-item "Open in other window" vc-dir-find-file-other-window |
| 161 | :help "Find the file on the current line, in another window")) | 164 | :help "Find the file on the current line, in another window")) |
| @@ -211,8 +214,7 @@ See `run-hooks'." | |||
| 211 | ext-binding)))) | 214 | ext-binding)))) |
| 212 | 215 | ||
| 213 | (defvar vc-dir-mode-map | 216 | (defvar vc-dir-mode-map |
| 214 | (let ((map (make-keymap))) | 217 | (let ((map (make-sparse-keymap))) |
| 215 | (suppress-keymap map) | ||
| 216 | ;; VC commands | 218 | ;; VC commands |
| 217 | (define-key map "v" 'vc-next-action) ;; C-x v v | 219 | (define-key map "v" 'vc-next-action) ;; C-x v v |
| 218 | (define-key map "=" 'vc-diff) ;; C-x v = | 220 | (define-key map "=" 'vc-diff) ;; C-x v = |
| @@ -248,6 +250,7 @@ See `run-hooks'." | |||
| 248 | (define-key map [down-mouse-3] 'vc-dir-menu) | 250 | (define-key map [down-mouse-3] 'vc-dir-menu) |
| 249 | (define-key map [mouse-2] 'vc-dir-toggle-mark) | 251 | (define-key map [mouse-2] 'vc-dir-toggle-mark) |
| 250 | (define-key map "x" 'vc-dir-hide-up-to-date) | 252 | (define-key map "x" 'vc-dir-hide-up-to-date) |
| 253 | (define-key map "Q" 'vc-dir-query-replace-regexp) | ||
| 251 | 254 | ||
| 252 | ;; Hook up the menu. | 255 | ;; Hook up the menu. |
| 253 | (define-key map [menu-bar vc-dir-mode] | 256 | (define-key map [menu-bar vc-dir-mode] |
| @@ -293,6 +296,8 @@ If `body' uses `event', it should be a variable, | |||
| 293 | map vc-dir-mode-map) | 296 | map vc-dir-mode-map) |
| 294 | (tool-bar-local-item-from-menu 'nonincremental-search-forward | 297 | (tool-bar-local-item-from-menu 'nonincremental-search-forward |
| 295 | "search" map) | 298 | "search" map) |
| 299 | (tool-bar-local-item-from-menu 'vc-dir-query-replace-regexp | ||
| 300 | "search-replace" map vc-dir-mode-map) | ||
| 296 | (tool-bar-local-item-from-menu 'vc-dir-kill-dir-status-process "cancel" | 301 | (tool-bar-local-item-from-menu 'vc-dir-kill-dir-status-process "cancel" |
| 297 | map vc-dir-mode-map) | 302 | map vc-dir-mode-map) |
| 298 | (tool-bar-local-item-from-menu 'quit-window "exit" | 303 | (tool-bar-local-item-from-menu 'quit-window "exit" |
| @@ -674,6 +679,28 @@ that share the same state." | |||
| 674 | (interactive) | 679 | (interactive) |
| 675 | (find-file-other-window (vc-dir-current-file))) | 680 | (find-file-other-window (vc-dir-current-file))) |
| 676 | 681 | ||
| 682 | (defun vc-dir-query-replace-regexp (from to &optional delimited) | ||
| 683 | "Do `query-replace-regexp' of FROM with TO, on all marked files. | ||
| 684 | If a directory is marked, then use the files displayed for that directory. | ||
| 685 | Third arg DELIMITED (prefix arg) means replace only word-delimited matches. | ||
| 686 | If you exit (\\[keyboard-quit], RET or q), you can resume the query replace | ||
| 687 | with the command \\[tags-loop-continue]." | ||
| 688 | ;; FIXME: this is almost a copy of `dired-do-replace-regexp'. This | ||
| 689 | ;; should probably be made generic and used in both places instead of | ||
| 690 | ;; duplicating it here. | ||
| 691 | (interactive | ||
| 692 | (let ((common | ||
| 693 | (query-replace-read-args | ||
| 694 | "Query replace regexp in marked files" t t))) | ||
| 695 | (list (nth 0 common) (nth 1 common) (nth 2 common)))) | ||
| 696 | (dolist (file (mapcar 'car (vc-dir-marked-only-files-and-states))) | ||
| 697 | (let ((buffer (get-file-buffer file))) | ||
| 698 | (if (and buffer (with-current-buffer buffer | ||
| 699 | buffer-read-only)) | ||
| 700 | (error "File `%s' is visited read-only" file)))) | ||
| 701 | (tags-query-replace from to delimited | ||
| 702 | '(mapcar 'car (vc-dir-marked-only-files-and-states)))) | ||
| 703 | |||
| 677 | (defun vc-dir-current-file () | 704 | (defun vc-dir-current-file () |
| 678 | (let ((node (ewoc-locate vc-ewoc))) | 705 | (let ((node (ewoc-locate vc-ewoc))) |
| 679 | (unless node | 706 | (unless node |