summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2005-11-28 21:46:51 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2005-11-28 21:46:51 +0000
commitcedbd3f084c41036b82ade1f7c45eaf1d8e5dfd3 (patch)
treedd6c6f47325f9a0260a85a15ed10a598b5623245 /lisp
parent756bfad5752f35da3dd0b15b1ae2ad0d81726437 (diff)
downloademacs-cedbd3f084c41036b82ade1f7c45eaf1d8e5dfd3.tar.gz
(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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/replace.el99
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 @@
+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.
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."
(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 @@ Alternatively, click \\[occur-mode-mouse-goto] on an item to go to it.
"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 @@ Alternatively, click \\[occur-mode-mouse-goto] on an item to go to it.
(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 @@ See also `multi-occur'."
(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 @@ C-l to clear the screen, redisplay, and offer same replacement again,
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