]> code.delx.au - gnu-emacs/blobdiff - lisp/replace.el
Fix spelling of "precede".
[gnu-emacs] / lisp / replace.el
index 95bb680b7a48940029d7d406c0b4edc34ade5506..0b90c94c7fa7e45084286ff2dd3bcf5d0436c047 100644 (file)
@@ -1,7 +1,8 @@
 ;;; replace.el --- replace commands for Emacs
 
 ;; Copyright (C) 1985, 1986, 1987, 1992, 1994, 1996, 1997, 2000, 2001,
-;;   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+;;   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 
@@ -555,7 +556,7 @@ regexp, the last isearch string, and the last replacement regexp."
             (format "%s: " prompt))
           nil nil nil 'regexp-history defaults t)))
     (if (equal input "")
-       default-value
+       (or default-value input)
       (prog1 input
        (add-to-history 'regexp-history input)))))
 
@@ -767,43 +768,43 @@ a previously found match."
     (define-key map "\C-c\C-f" 'next-error-follow-minor-mode)
     (define-key map [menu-bar] (make-sparse-keymap))
     (define-key map [menu-bar occur]
-      (cons "Occur" map))
+      `(cons ,(purecopy "Occur") map))
     (define-key map [next-error-follow-minor-mode]
       (menu-bar-make-mm-toggle next-error-follow-minor-mode
                               "Auto Occurrence Display"
                               "Display another occurrence when moving the cursor"))
-    (define-key map [separator-1] '("--"))
+    (define-key map [separator-1] menu-bar-separator)
     (define-key map [kill-this-buffer]
-      '(menu-item "Kill occur buffer" kill-this-buffer
-                 :help "Kill the current *Occur* buffer"))
+      `(menu-item ,(purecopy "Kill occur buffer") kill-this-buffer
+                 :help ,(purecopy "Kill the current *Occur* buffer")))
     (define-key map [quit-window]
-      '(menu-item "Quit occur window" quit-window
-                 :help "Quit the current *Occur* buffer.  Bury it, and maybe delete the selected frame"))
+      `(menu-item ,(purecopy "Quit occur window") quit-window
+                 :help ,(purecopy "Quit the current *Occur* buffer.  Bury it, and maybe delete the selected frame")))
     (define-key map [revert-buffer]
-      '(menu-item "Revert occur buffer" revert-buffer
-                 :help "Replace the text in the *Occur* buffer with the results of rerunning occur"))
+      `(menu-item ,(purecopy "Revert occur buffer") revert-buffer
+                 :help ,(purecopy "Replace the text in the *Occur* buffer with the results of rerunning occur")))
     (define-key map [clone-buffer]
-      '(menu-item "Clone occur buffer" clone-buffer
-                 :help "Create and return a twin copy of the current *Occur* buffer"))
+      `(menu-item ,(purecopy "Clone occur buffer") clone-buffer
+                 :help ,(purecopy "Create and return a twin copy of the current *Occur* buffer")))
     (define-key map [occur-rename-buffer]
-      '(menu-item "Rename occur buffer" occur-rename-buffer
-                 :help "Rename the current *Occur* buffer to *Occur: original-buffer-name*."))
-    (define-key map [separator-2] '("--"))
+      `(menu-item ,(purecopy "Rename occur buffer") occur-rename-buffer
+                 :help ,(purecopy "Rename the current *Occur* buffer to *Occur: original-buffer-name*.")))
+    (define-key map [separator-2] menu-bar-separator)
     (define-key map [occur-mode-goto-occurrence-other-window]
-      '(menu-item "Go To Occurrence Other Window" occur-mode-goto-occurrence-other-window
-                 :help "Go to the occurrence the current line describes, in another window"))
+      `(menu-item ,(purecopy "Go To Occurrence Other Window") occur-mode-goto-occurrence-other-window
+                 :help ,(purecopy "Go to the occurrence the current line describes, in another window")))
     (define-key map [occur-mode-goto-occurrence]
-      '(menu-item "Go To Occurrence" occur-mode-goto-occurrence
-                 :help "Go to the occurrence the current line describes"))
+      `(menu-item ,(purecopy "Go To Occurrence") occur-mode-goto-occurrence
+                 :help ,(purecopy "Go to the occurrence the current line describes")))
     (define-key map [occur-mode-display-occurrence]
-      '(menu-item "Display Occurrence" occur-mode-display-occurrence
-                 :help "Display in another window the occurrence the current line describes"))
+      `(menu-item ,(purecopy "Display Occurrence") occur-mode-display-occurrence
+                 :help ,(purecopy "Display in another window the occurrence the current line describes")))
     (define-key map [occur-next]
-      '(menu-item "Move to next match" occur-next
-                 :help "Move to the Nth (default 1) next match in an Occur mode buffer"))
+      `(menu-item ,(purecopy "Move to next match") occur-next
+                 :help ,(purecopy "Move to the Nth (default 1) next match in an Occur mode buffer")))
     (define-key map [occur-prev]
-      '(menu-item "Move to previous match" occur-prev
-                 :help "Move to the Nth (default 1) previous match in an Occur mode buffer"))
+      `(menu-item ,(purecopy "Move to previous match") occur-prev
+                 :help ,(purecopy "Move to the Nth (default 1) previous match in an Occur mode buffer")))
     map)
   "Keymap for `occur-mode'.")
 
@@ -1401,7 +1402,7 @@ N     (match-string N)           (where N is a string of digits)
 #&    (string-to-number (match-string 0))
 #     replace-count
 
-Note that these symbols must be preceeded by a backslash in order to
+Note that these symbols must be preceded by a backslash in order to
 type them using Lisp syntax."
   (while (consp n)
     (cond
@@ -1548,6 +1549,7 @@ make, or the user didn't cancel the call."
          (replace-count 0)
          (nonempty-match nil)
         (multi-buffer nil)
+        (recenter-last-op nil) ; Start cycling order with initial position.
 
          ;; If non-nil, it is marker saying where in the buffer to stop.
          (limit nil)
@@ -1571,7 +1573,7 @@ make, or the user didn't cancel the call."
 
     ;; If last typed key in previous call of multi-buffer perform-replace
     ;; was `automatic-all', don't ask more questions in next files
-    (when (eq (lookup-key map (vector last-input-char)) 'automatic-all)
+    (when (eq (lookup-key map (vector last-input-event)) 'automatic-all)
       (setq query-flag nil multi-buffer t))
 
     ;; REPLACEMENTS is either a string, a list of strings, or a cons cell
@@ -1784,7 +1786,12 @@ make, or the user didn't cancel the call."
                        ((eq def 'skip)
                         (setq done t))
                        ((eq def 'recenter)
-                        (recenter nil))
+                        ;; `this-command' has the value `query-replace',
+                        ;; so we need to bind it to `recenter-top-bottom'
+                        ;; to allow it to detect a sequence of `C-l'.
+                        (let ((this-command 'recenter-top-bottom)
+                              (last-command 'recenter-top-bottom))
+                          (recenter-top-bottom)))
                        ((eq def 'edit)
                         (let ((opos (point-marker)))
                           (setq real-match-data (replace-match-data
@@ -1838,9 +1845,12 @@ make, or the user didn't cancel the call."
                                       unread-command-events))
                         (setq done t)))
                  (when query-replace-lazy-highlight
-                   ;; Force lazy rehighlighting only after replacements
+                   ;; Force lazy rehighlighting only after replacements.
                    (if (not (memq def '(skip backup)))
-                       (setq isearch-lazy-highlight-last-string nil))))
+                       (setq isearch-lazy-highlight-last-string nil)))
+                 (unless (eq def 'recenter)
+                   ;; Reset recenter cycling order to initial position.
+                   (setq recenter-last-op nil)))
                ;; Record previous position for ^ when we move on.
                ;; Change markers to numbers in the match data
                ;; since lots of markers slow down editing.
@@ -1883,7 +1893,9 @@ make, or the user didn't cancel the call."
       (let ((isearch-string string)
            (isearch-regexp regexp)
            (search-whitespace-regexp nil)
-           (isearch-case-fold-search case-fold))
+           (isearch-case-fold-search case-fold)
+           (isearch-forward t)
+           (isearch-error nil))
        (isearch-lazy-highlight-new-loop range-beg range-end))))
 
 (defun replace-dehighlight ()