(locate-current-search): New variable.
authorEli Zaretskii <eliz@gnu.org>
Sat, 9 Sep 2006 10:34:23 +0000 (10:34 +0000)
committerEli Zaretskii <eliz@gnu.org>
Sat, 9 Sep 2006 10:34:23 +0000 (10:34 +0000)
(locate): Set buffer local value.  Use current buffer if it is in Locate mode.
(locate-mode): Disable undo here.
(locate-do-setup): Use locate-current-filter from buffer to be killed.
(locate-update): Use locate-current-search and locate-current-filter.

lisp/ChangeLog
lisp/locate.el

index 6c5c97d..7f7c3c7 100644 (file)
@@ -1,3 +1,14 @@
+2006-09-09  Matt Hodges  <MPHodges@member.fsf.org>
+
+       * locate.el (locate-current-search): New variable.
+       (locate): Set buffer local value.  Use current buffer if it is
+       in Locate mode.
+       (locate-mode): Disable undo here.
+       (locate-do-setup): Use locate-current-filter from buffer to be
+       killed. 
+       (locate-update): Use locate-current-search and
+       locate-current-filter.
+
 2006-09-08  David Kastrup  <dak@gnu.org>
 
        * desktop.el (desktop-read): when loading a desktop, disable
index 5df695d..9cf37e8 100644 (file)
 
 ;; Variables
 
+(defvar locate-current-search nil)
 (defvar locate-current-filter nil)
 
 (defgroup locate nil
@@ -289,29 +290,36 @@ the docstring of that function for its meaning."
         (run-locate-command
          (or (and current-prefix-arg (not locate-prompt-for-command))
              (and (not current-prefix-arg) locate-prompt-for-command)))
+         locate-buffer
         )
 
     ;; Find the Locate buffer
-    (save-window-excursion
-      (set-buffer (get-buffer-create locate-buffer-name))
+    (setq locate-buffer (if (eq major-mode 'locate-mode)
+                            (current-buffer)
+                          (get-buffer-create locate-buffer-name)))
+
+    (save-excursion
+      (set-buffer locate-buffer)
       (locate-mode)
+
       (let ((inhibit-read-only t)
-           (buffer-undo-list t))
-       (erase-buffer)
+            (buffer-undo-list t))
+        (erase-buffer)
+
+        (set (make-local-variable 'locate-current-search) search-string)
+        (set (make-local-variable 'locate-current-filter) filter)
 
-       (setq locate-current-filter filter)
+        (if run-locate-command
+            (shell-command search-string)
+          (apply 'call-process locate-cmd nil t nil locate-cmd-args))
 
-       (if run-locate-command
-           (shell-command search-string locate-buffer-name)
-         (apply 'call-process locate-cmd nil t nil locate-cmd-args))
+        (and filter
+             (locate-filter-output filter))
 
-       (and filter
-            (locate-filter-output filter))
+        (locate-do-setup search-string)))
 
-       (locate-do-setup search-string)
-       ))
-    (and (not (string-equal (buffer-name) locate-buffer-name))
-       (switch-to-buffer-other-window locate-buffer-name))
+    (unless (eq (current-buffer) locate-buffer)
+      (switch-to-buffer-other-window locate-buffer))
 
     (run-hooks 'dired-mode-hook)
     (dired-next-line 3)                        ;move to first matching file.
@@ -461,6 +469,7 @@ do not work in subdirectories.
         default-directory   "/"
        buffer-read-only    t
        selective-display   t)
+  (buffer-disable-undo)
   (dired-alist-add-1 default-directory (point-min-marker))
   (set (make-local-variable 'dired-directory) "/")
   (set (make-local-variable 'dired-subdir-switches) locate-ls-subdir-switches)
@@ -492,11 +501,12 @@ do not work in subdirectories.
     ;; Nothing returned from locate command?
     (and (eobp)
         (progn
-          (kill-buffer locate-buffer-name)
-          (if locate-current-filter
-              (error "Locate: no match for %s in database using filter %s"
-                     search-string locate-current-filter)
-            (error "Locate: no match for %s in database" search-string))))
+           (let ((filter locate-current-filter)) ; local
+             (kill-buffer (current-buffer))
+             (if filter
+                 (error "Locate: no match for %s in database using filter %s"
+                        search-string filter)
+               (error "Locate: no match for %s in database" search-string)))))
 
     (locate-insert-header search-string)
 
@@ -580,15 +590,14 @@ do not work in subdirectories.
   "Revert the *Locate* buffer.
 If `locate-update-when-revert' is non-nil, offer to update the
 locate database using the shell command in `locate-update-command'."
-  (let ((str (car locate-history-list)))
-    (and locate-update-when-revert
-        (yes-or-no-p "Update locate database (may take a few seconds)? ")
-        ;; `expand-file-name' is used in order to autoload Tramp if
-        ;; necessary.  It cannot be loaded when `default-directory'
-        ;; is remote.
-        (let ((default-directory (expand-file-name locate-update-path)))
-          (shell-command locate-update-command)))
-    (locate str)))
+  (and locate-update-when-revert
+       (yes-or-no-p "Update locate database (may take a few seconds)? ")
+       ;; `expand-file-name' is used in order to autoload Tramp if
+       ;; necessary.  It cannot be loaded when `default-directory'
+       ;; is remote.
+       (let ((default-directory (expand-file-name locate-update-path)))
+         (shell-command locate-update-command)))
+  (locate locate-current-search locate-current-filter))
 
 ;;; Modified three functions from `dired.el':
 ;;;   dired-find-directory,