diff options
| author | Stefan Monnier | 2005-11-28 21:46:51 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2005-11-28 21:46:51 +0000 |
| commit | cedbd3f084c41036b82ade1f7c45eaf1d8e5dfd3 (patch) | |
| tree | dd6c6f47325f9a0260a85a15ed10a598b5623245 | |
| parent | 756bfad5752f35da3dd0b15b1ae2ad0d81726437 (diff) | |
| download | emacs-cedbd3f084c41036b82ade1f7c45eaf1d8e5dfd3.tar.gz emacs-cedbd3f084c41036b82ade1f7c45eaf1d8e5dfd3.zip | |
(query-replace-map): Move initialization into declaration.
(occur-engine): Use with-current-buffer.
(occur-mode-goto-occurrence): Make it work for mouse-clicks as well.
(occur-mode-mouse-goto): Replace with an alias.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/replace.el | 99 |
2 files changed, 55 insertions, 51 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 404eda33c5d..1ffbcb3c91f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2005-11-28 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * replace.el (query-replace-map): Move initialization into declaration. | ||
| 4 | (occur-engine): Use with-current-buffer. | ||
| 5 | (occur-mode-goto-occurrence): Make it work for mouse-clicks as well. | ||
| 6 | (occur-mode-mouse-goto): Replace with an alias. | ||
| 7 | |||
| 1 | 2005-11-28 Juri Linkov <juri@jurta.org> | 8 | 2005-11-28 Juri Linkov <juri@jurta.org> |
| 2 | 9 | ||
| 3 | * simple.el (quoted-insert): Let-bind input-method-function to nil. | 10 | * simple.el (quoted-insert): Let-bind input-method-function to nil. |
diff --git a/lisp/replace.el b/lisp/replace.el index 57326d08ef2..fbfa1be09c2 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -693,6 +693,7 @@ a previously found match." | |||
| 693 | 693 | ||
| 694 | (defvar occur-mode-map | 694 | (defvar occur-mode-map |
| 695 | (let ((map (make-sparse-keymap))) | 695 | (let ((map (make-sparse-keymap))) |
| 696 | ;; We use this alternative name, so we can use \\[occur-mode-mouse-goto]. | ||
| 696 | (define-key map [mouse-2] 'occur-mode-mouse-goto) | 697 | (define-key map [mouse-2] 'occur-mode-mouse-goto) |
| 697 | (define-key map "\C-c\C-c" 'occur-mode-goto-occurrence) | 698 | (define-key map "\C-c\C-c" 'occur-mode-goto-occurrence) |
| 698 | (define-key map "\C-m" 'occur-mode-goto-occurrence) | 699 | (define-key map "\C-m" 'occur-mode-goto-occurrence) |
| @@ -746,20 +747,6 @@ Alternatively, click \\[occur-mode-mouse-goto] on an item to go to it. | |||
| 746 | "Handle `revert-buffer' for Occur mode buffers." | 747 | "Handle `revert-buffer' for Occur mode buffers." |
| 747 | (apply 'occur-1 (append occur-revert-arguments (list (buffer-name))))) | 748 | (apply 'occur-1 (append occur-revert-arguments (list (buffer-name))))) |
| 748 | 749 | ||
| 749 | (defun occur-mode-mouse-goto (event) | ||
| 750 | "In Occur mode, go to the occurrence whose line you click on." | ||
| 751 | (interactive "e") | ||
| 752 | (let (pos) | ||
| 753 | (save-excursion | ||
| 754 | (set-buffer (window-buffer (posn-window (event-end event)))) | ||
| 755 | (save-excursion | ||
| 756 | (goto-char (posn-point (event-end event))) | ||
| 757 | (setq pos (occur-mode-find-occurrence)))) | ||
| 758 | (let (same-window-buffer-names | ||
| 759 | same-window-regexps) | ||
| 760 | (pop-to-buffer (marker-buffer pos))) | ||
| 761 | (goto-char pos))) | ||
| 762 | |||
| 763 | (defun occur-mode-find-occurrence () | 750 | (defun occur-mode-find-occurrence () |
| 764 | (let ((pos (get-text-property (point) 'occur-target))) | 751 | (let ((pos (get-text-property (point) 'occur-target))) |
| 765 | (unless pos | 752 | (unless pos |
| @@ -768,12 +755,22 @@ Alternatively, click \\[occur-mode-mouse-goto] on an item to go to it. | |||
| 768 | (error "Buffer for this occurrence was killed")) | 755 | (error "Buffer for this occurrence was killed")) |
| 769 | pos)) | 756 | pos)) |
| 770 | 757 | ||
| 771 | (defun occur-mode-goto-occurrence () | 758 | (defalias 'occur-mode-mouse-goto 'occur-mode-goto-occurrence) |
| 759 | (defun occur-mode-goto-occurrence (&optional event) | ||
| 772 | "Go to the occurrence the current line describes." | 760 | "Go to the occurrence the current line describes." |
| 773 | (interactive) | 761 | (interactive (list last-nonmenu-event)) |
| 774 | (let ((pos (occur-mode-find-occurrence)) | 762 | (let ((pos |
| 775 | same-window-buffer-names | 763 | (if (null event) |
| 776 | same-window-regexps) | 764 | ;; Actually `event-end' works correctly with a nil argument as |
| 765 | ;; well, so we could dispense with this test, but let's not | ||
| 766 | ;; rely on this undocumented behavior. | ||
| 767 | (occur-mode-find-occurrence) | ||
| 768 | (with-current-buffer (window-buffer (posn-window (event-end event))) | ||
| 769 | (save-excursion | ||
| 770 | (goto-char (posn-point (event-end event))) | ||
| 771 | (occur-mode-find-occurrence))))) | ||
| 772 | same-window-buffer-names | ||
| 773 | same-window-regexps) | ||
| 777 | (pop-to-buffer (marker-buffer pos)) | 774 | (pop-to-buffer (marker-buffer pos)) |
| 778 | (goto-char pos))) | 775 | (goto-char pos))) |
| 779 | 776 | ||
| @@ -1094,8 +1091,7 @@ See also `multi-occur'." | |||
| 1094 | (marker nil) | 1091 | (marker nil) |
| 1095 | (curstring "") | 1092 | (curstring "") |
| 1096 | (headerpt (with-current-buffer out-buf (point)))) | 1093 | (headerpt (with-current-buffer out-buf (point)))) |
| 1097 | (save-excursion | 1094 | (with-current-buffer buf |
| 1098 | (set-buffer buf) | ||
| 1099 | (or coding | 1095 | (or coding |
| 1100 | ;; Set CODING only if the current buffer locally | 1096 | ;; Set CODING only if the current buffer locally |
| 1101 | ;; binds buffer-file-coding-system. | 1097 | ;; binds buffer-file-coding-system. |
| @@ -1228,42 +1224,43 @@ C-l to clear the screen, redisplay, and offer same replacement again, | |||
| 1228 | E to edit the replacement string" | 1224 | E to edit the replacement string" |
| 1229 | "Help message while in `query-replace'.") | 1225 | "Help message while in `query-replace'.") |
| 1230 | 1226 | ||
| 1231 | (defvar query-replace-map (make-sparse-keymap) | 1227 | (defvar query-replace-map |
| 1228 | (let ((map (make-sparse-keymap))) | ||
| 1229 | (define-key map " " 'act) | ||
| 1230 | (define-key map "\d" 'skip) | ||
| 1231 | (define-key map [delete] 'skip) | ||
| 1232 | (define-key map [backspace] 'skip) | ||
| 1233 | (define-key map "y" 'act) | ||
| 1234 | (define-key map "n" 'skip) | ||
| 1235 | (define-key map "Y" 'act) | ||
| 1236 | (define-key map "N" 'skip) | ||
| 1237 | (define-key map "e" 'edit-replacement) | ||
| 1238 | (define-key map "E" 'edit-replacement) | ||
| 1239 | (define-key map "," 'act-and-show) | ||
| 1240 | (define-key map "q" 'exit) | ||
| 1241 | (define-key map "\r" 'exit) | ||
| 1242 | (define-key map [return] 'exit) | ||
| 1243 | (define-key map "." 'act-and-exit) | ||
| 1244 | (define-key map "\C-r" 'edit) | ||
| 1245 | (define-key map "\C-w" 'delete-and-edit) | ||
| 1246 | (define-key map "\C-l" 'recenter) | ||
| 1247 | (define-key map "!" 'automatic) | ||
| 1248 | (define-key map "^" 'backup) | ||
| 1249 | (define-key map "\C-h" 'help) | ||
| 1250 | (define-key map [f1] 'help) | ||
| 1251 | (define-key map [help] 'help) | ||
| 1252 | (define-key map "?" 'help) | ||
| 1253 | (define-key map "\C-g" 'quit) | ||
| 1254 | (define-key map "\C-]" 'quit) | ||
| 1255 | (define-key map "\e" 'exit-prefix) | ||
| 1256 | (define-key map [escape] 'exit-prefix) | ||
| 1257 | map) | ||
| 1232 | "Keymap that defines the responses to questions in `query-replace'. | 1258 | "Keymap that defines the responses to questions in `query-replace'. |
| 1233 | The \"bindings\" in this map are not commands; they are answers. | 1259 | The \"bindings\" in this map are not commands; they are answers. |
| 1234 | The valid answers include `act', `skip', `act-and-show', | 1260 | The valid answers include `act', `skip', `act-and-show', |
| 1235 | `exit', `act-and-exit', `edit', `delete-and-edit', `recenter', | 1261 | `exit', `act-and-exit', `edit', `delete-and-edit', `recenter', |
| 1236 | `automatic', `backup', `exit-prefix', and `help'.") | 1262 | `automatic', `backup', `exit-prefix', and `help'.") |
| 1237 | 1263 | ||
| 1238 | (define-key query-replace-map " " 'act) | ||
| 1239 | (define-key query-replace-map "\d" 'skip) | ||
| 1240 | (define-key query-replace-map [delete] 'skip) | ||
| 1241 | (define-key query-replace-map [backspace] 'skip) | ||
| 1242 | (define-key query-replace-map "y" 'act) | ||
| 1243 | (define-key query-replace-map "n" 'skip) | ||
| 1244 | (define-key query-replace-map "Y" 'act) | ||
| 1245 | (define-key query-replace-map "N" 'skip) | ||
| 1246 | (define-key query-replace-map "e" 'edit-replacement) | ||
| 1247 | (define-key query-replace-map "E" 'edit-replacement) | ||
| 1248 | (define-key query-replace-map "," 'act-and-show) | ||
| 1249 | (define-key query-replace-map "q" 'exit) | ||
| 1250 | (define-key query-replace-map "\r" 'exit) | ||
| 1251 | (define-key query-replace-map [return] 'exit) | ||
| 1252 | (define-key query-replace-map "." 'act-and-exit) | ||
| 1253 | (define-key query-replace-map "\C-r" 'edit) | ||
| 1254 | (define-key query-replace-map "\C-w" 'delete-and-edit) | ||
| 1255 | (define-key query-replace-map "\C-l" 'recenter) | ||
| 1256 | (define-key query-replace-map "!" 'automatic) | ||
| 1257 | (define-key query-replace-map "^" 'backup) | ||
| 1258 | (define-key query-replace-map "\C-h" 'help) | ||
| 1259 | (define-key query-replace-map [f1] 'help) | ||
| 1260 | (define-key query-replace-map [help] 'help) | ||
| 1261 | (define-key query-replace-map "?" 'help) | ||
| 1262 | (define-key query-replace-map "\C-g" 'quit) | ||
| 1263 | (define-key query-replace-map "\C-]" 'quit) | ||
| 1264 | (define-key query-replace-map "\e" 'exit-prefix) | ||
| 1265 | (define-key query-replace-map [escape] 'exit-prefix) | ||
| 1266 | |||
| 1267 | (defun replace-match-string-symbols (n) | 1264 | (defun replace-match-string-symbols (n) |
| 1268 | "Process a list (and any sub-lists), expanding certain symbols. | 1265 | "Process a list (and any sub-lists), expanding certain symbols. |
| 1269 | Symbol Expands To | 1266 | Symbol Expands To |