Mercurial > emacs
changeset 67187:805356939662
(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.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 28 Nov 2005 21:46:51 +0000 |
parents | d4cac21cdeb8 |
children | 25c21897d6a9 |
files | lisp/ChangeLog lisp/replace.el |
diffstat | 2 files changed, 55 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Mon Nov 28 21:20:28 2005 +0000 +++ b/lisp/ChangeLog Mon Nov 28 21:46:51 2005 +0000 @@ -1,3 +1,10 @@ +2005-11-28 Stefan Monnier <monnier@iro.umontreal.ca> + + * replace.el (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. + 2005-11-28 Juri Linkov <juri@jurta.org> * simple.el (quoted-insert): Let-bind input-method-function to nil.
--- a/lisp/replace.el Mon Nov 28 21:20:28 2005 +0000 +++ b/lisp/replace.el Mon Nov 28 21:46:51 2005 +0000 @@ -693,6 +693,7 @@ (defvar occur-mode-map (let ((map (make-sparse-keymap))) + ;; We use this alternative name, so we can use \\[occur-mode-mouse-goto]. (define-key map [mouse-2] 'occur-mode-mouse-goto) (define-key map "\C-c\C-c" 'occur-mode-goto-occurrence) (define-key map "\C-m" 'occur-mode-goto-occurrence) @@ -746,20 +747,6 @@ "Handle `revert-buffer' for Occur mode buffers." (apply 'occur-1 (append occur-revert-arguments (list (buffer-name))))) -(defun occur-mode-mouse-goto (event) - "In Occur mode, go to the occurrence whose line you click on." - (interactive "e") - (let (pos) - (save-excursion - (set-buffer (window-buffer (posn-window (event-end event)))) - (save-excursion - (goto-char (posn-point (event-end event))) - (setq pos (occur-mode-find-occurrence)))) - (let (same-window-buffer-names - same-window-regexps) - (pop-to-buffer (marker-buffer pos))) - (goto-char pos))) - (defun occur-mode-find-occurrence () (let ((pos (get-text-property (point) 'occur-target))) (unless pos @@ -768,12 +755,22 @@ (error "Buffer for this occurrence was killed")) pos)) -(defun occur-mode-goto-occurrence () +(defalias 'occur-mode-mouse-goto 'occur-mode-goto-occurrence) +(defun occur-mode-goto-occurrence (&optional event) "Go to the occurrence the current line describes." - (interactive) - (let ((pos (occur-mode-find-occurrence)) - same-window-buffer-names - same-window-regexps) + (interactive (list last-nonmenu-event)) + (let ((pos + (if (null event) + ;; Actually `event-end' works correctly with a nil argument as + ;; well, so we could dispense with this test, but let's not + ;; rely on this undocumented behavior. + (occur-mode-find-occurrence) + (with-current-buffer (window-buffer (posn-window (event-end event))) + (save-excursion + (goto-char (posn-point (event-end event))) + (occur-mode-find-occurrence))))) + same-window-buffer-names + same-window-regexps) (pop-to-buffer (marker-buffer pos)) (goto-char pos))) @@ -1094,8 +1091,7 @@ (marker nil) (curstring "") (headerpt (with-current-buffer out-buf (point)))) - (save-excursion - (set-buffer buf) + (with-current-buffer buf (or coding ;; Set CODING only if the current buffer locally ;; binds buffer-file-coding-system. @@ -1228,42 +1224,43 @@ E to edit the replacement string" "Help message while in `query-replace'.") -(defvar query-replace-map (make-sparse-keymap) +(defvar query-replace-map + (let ((map (make-sparse-keymap))) + (define-key map " " 'act) + (define-key map "\d" 'skip) + (define-key map [delete] 'skip) + (define-key map [backspace] 'skip) + (define-key map "y" 'act) + (define-key map "n" 'skip) + (define-key map "Y" 'act) + (define-key map "N" 'skip) + (define-key map "e" 'edit-replacement) + (define-key map "E" 'edit-replacement) + (define-key map "," 'act-and-show) + (define-key map "q" 'exit) + (define-key map "\r" 'exit) + (define-key map [return] 'exit) + (define-key map "." 'act-and-exit) + (define-key map "\C-r" 'edit) + (define-key map "\C-w" 'delete-and-edit) + (define-key map "\C-l" 'recenter) + (define-key map "!" 'automatic) + (define-key map "^" 'backup) + (define-key map "\C-h" 'help) + (define-key map [f1] 'help) + (define-key map [help] 'help) + (define-key map "?" 'help) + (define-key map "\C-g" 'quit) + (define-key map "\C-]" 'quit) + (define-key map "\e" 'exit-prefix) + (define-key map [escape] 'exit-prefix) + map) "Keymap that defines the responses to questions in `query-replace'. The \"bindings\" in this map are not commands; they are answers. The valid answers include `act', `skip', `act-and-show', `exit', `act-and-exit', `edit', `delete-and-edit', `recenter', `automatic', `backup', `exit-prefix', and `help'.") -(define-key query-replace-map " " 'act) -(define-key query-replace-map "\d" 'skip) -(define-key query-replace-map [delete] 'skip) -(define-key query-replace-map [backspace] 'skip) -(define-key query-replace-map "y" 'act) -(define-key query-replace-map "n" 'skip) -(define-key query-replace-map "Y" 'act) -(define-key query-replace-map "N" 'skip) -(define-key query-replace-map "e" 'edit-replacement) -(define-key query-replace-map "E" 'edit-replacement) -(define-key query-replace-map "," 'act-and-show) -(define-key query-replace-map "q" 'exit) -(define-key query-replace-map "\r" 'exit) -(define-key query-replace-map [return] 'exit) -(define-key query-replace-map "." 'act-and-exit) -(define-key query-replace-map "\C-r" 'edit) -(define-key query-replace-map "\C-w" 'delete-and-edit) -(define-key query-replace-map "\C-l" 'recenter) -(define-key query-replace-map "!" 'automatic) -(define-key query-replace-map "^" 'backup) -(define-key query-replace-map "\C-h" 'help) -(define-key query-replace-map [f1] 'help) -(define-key query-replace-map [help] 'help) -(define-key query-replace-map "?" 'help) -(define-key query-replace-map "\C-g" 'quit) -(define-key query-replace-map "\C-]" 'quit) -(define-key query-replace-map "\e" 'exit-prefix) -(define-key query-replace-map [escape] 'exit-prefix) - (defun replace-match-string-symbols (n) "Process a list (and any sub-lists), expanding certain symbols. Symbol Expands To