Always include termhooks.h.
[bpt/emacs.git] / lisp / replace.el
index 49f3920..ad0c172 100644 (file)
@@ -227,7 +227,8 @@ in the buffer that the occurrences were found in.
   (setq mode-name "Occur")
   (make-local-variable 'occur-buffer)
   (make-local-variable 'occur-nlines)
-  (make-local-variable 'occur-pos-list))
+  (make-local-variable 'occur-pos-list)
+  (run-hooks 'occur-mode-hook))
 
 (defun occur-mode-goto-occurrence ()
   "Go to the line this occurrence was found in, in the buffer it was found in."
@@ -250,6 +251,8 @@ in the buffer that the occurrences were found in.
                                   (+ 2 (* 2 occur-nlines)))
                                  (t 1)))))
         (pos (nth occur-number occur-pos-list)))
+    (or pos
+       (error "No occurrence on this line"))
     (pop-to-buffer occur-buffer)
     (goto-char (marker-position pos))))
 \f
@@ -276,7 +279,9 @@ It serves as a menu to find any of the occurrences in this buffer.
   (interactive (list (let* ((default (car regexp-history))
                            (input 
                             (read-from-minibuffer
-                             (format "List lines matching regexp (default `%s'): " default)
+                             (if default
+                                 (format "List lines matching regexp (default `%s'): " default)
+                               "List lines matching regexp: ")
                              nil nil nil
                              'regexp-history)))
                       (if (> (length input) 0) input
@@ -369,7 +374,7 @@ It serves as a menu to find any of the occurrences in this buffer.
 ;; to make that display both SPC and Y.
 (defconst query-replace-help
   "Type Space or `y' to replace one match, Delete or `n' to skip to next,
-ESC or `q' to exit, Period to replace one match and exit,
+RET or `q' to exit, Period to replace one match and exit,
 Comma to replace but not move point immediately,
 C-r to enter recursive edit (\\[exit-recursive-edit] to get out again),
 C-w to delete match and recursive edit,
@@ -392,8 +397,6 @@ The valid answers include `act', `skip', `act-and-show',
 (define-key query-replace-map "y" 'act)
 (define-key query-replace-map "n" 'skip)
 (define-key query-replace-map "," 'act-and-show)
-(define-key query-replace-map "\e" 'exit)
-(define-key query-replace-map [escape] 'exit)
 (define-key query-replace-map "q" 'exit)
 (define-key query-replace-map "\r" 'exit)
 (define-key query-replace-map [return] 'exit)
@@ -488,7 +491,8 @@ which will run faster and do exactly what you probably want."
          ;; Loop reading commands until one of them sets done,
          ;; which means it has finished handling this occurrence.
          (while (not done)
-           (message "Query replacing %s with %s: "
+           (message (substitute-command-keys
+                     "Query replacing %s with %s: (\\<query-replace-map>\\[help] for help) ")
                     from-string next-replacement)
            (setq key (read-event))
            (setq key (vector key))