Move lisp/emacs-lisp/authors.el to admin/
[bpt/emacs.git] / lisp / misearch.el
index 0aeed61..64ea40b 100644 (file)
@@ -1,6 +1,6 @@
 ;;; misearch.el --- isearch extensions for multi-buffer search
 
-;; Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012  Free Software Foundation, Inc.
+;; Copyright (C) 2007-2014 Free Software Foundation, Inc.
 
 ;; Author: Juri Linkov <juri@jurta.org>
 ;; Keywords: matching
@@ -73,7 +73,7 @@ end of the search space).
 The first argument of this function is the current buffer where the
 search is currently searching.  It defines the base buffer relative to
 which this function should find the next buffer.  When the isearch
-direction is backward (when `isearch-forward' is nil), this function
+direction is backward (when option `isearch-forward' is nil), this function
 should return the previous buffer to search.
 
 If the second argument of this function WRAP is non-nil, then it
@@ -130,19 +130,13 @@ Intended to be added to `isearch-mode-hook'."
   (lambda (string bound noerror)
     (let ((search-fun
           ;; Use standard functions to search within one buffer
-          (cond
-           (isearch-word
-            (if isearch-forward 'word-search-forward 'word-search-backward))
-           (isearch-regexp
-            (if isearch-forward 're-search-forward 're-search-backward))
-           (t
-            (if isearch-forward 'search-forward 'search-backward))))
+          (isearch-search-fun-default))
          found buffer)
       (or
        ;; 1. First try searching in the initial buffer
        (let ((res (funcall search-fun string bound noerror)))
         ;; Reset wrapping for all-buffers pause after successful search
-        (if (and res (eq multi-isearch-pause t))
+        (if (and res (not bound) (eq multi-isearch-pause t))
             (setq multi-isearch-current-buffer nil))
         res)
        ;; 2. If the above search fails, start visiting next/prev buffers
@@ -173,8 +167,8 @@ Intended to be added to `isearch-mode-hook'."
                   found)
               ;; Return nil when multi-isearch-next-buffer-current-function fails
               ;; (`with-current-buffer' raises an error for nil returned from it).
-              (error nil))
-          (signal 'search-failed (list string "Repeat for next buffer"))))))))
+              (error (signal 'search-failed (list string "end of multi"))))
+          (signal 'search-failed (list string "repeat for next buffer"))))))))
 
 (defun multi-isearch-wrap ()
   "Wrap the multiple buffers search when search is failed.
@@ -201,7 +195,7 @@ search status stack."
   `(lambda (cmd)
      (multi-isearch-pop-state cmd ,(current-buffer))))
 
-(defun multi-isearch-pop-state (cmd buffer)
+(defun multi-isearch-pop-state (_cmd buffer)
   "Restore the multiple buffers search state.
 Switch to the buffer restored from the search status stack."
   (unless (equal buffer (current-buffer))
@@ -224,6 +218,8 @@ set in `multi-isearch-buffers' or `multi-isearch-buffers-regexp'."
        (car buffers)
       (cadr (member buffer buffers)))))
 
+(defvar ido-ignore-item-temp-list)  ; from ido.el
+
 (defun multi-isearch-read-buffers ()
   "Return a list of buffers specified interactively, one by one."
   ;; Most code from `multi-occur'.
@@ -243,7 +239,8 @@ set in `multi-isearch-buffers' or `multi-isearch-buffers-regexp'."
     (nreverse bufs)))
 
 (defun multi-isearch-read-matching-buffers ()
-  "Return a list of buffers whose names match specified regexp."
+  "Return a list of buffers whose names match specified regexp.
+Uses `read-regexp' to read the regexp."
   ;; Most code from `multi-occur-in-matching-buffers'
   ;; and `kill-matching-buffers'.
   (let ((bufregexp
@@ -266,11 +263,11 @@ whose names match the specified regexp."
             (multi-isearch-read-matching-buffers)
           (multi-isearch-read-buffers))))
   (let ((multi-isearch-next-buffer-function
-        'multi-isearch-next-buffer-from-list)
-       (multi-isearch-buffer-list (mapcar #'get-buffer buffers)))
+        'multi-isearch-next-buffer-from-list))
+    (setq multi-isearch-buffer-list (mapcar #'get-buffer buffers))
     (switch-to-buffer (car multi-isearch-buffer-list))
     (goto-char (if isearch-forward (point-min) (point-max)))
-    (isearch-forward)))
+    (isearch-forward nil t)))
 
 ;;;###autoload
 (defun multi-isearch-buffers-regexp (buffers)
@@ -284,11 +281,11 @@ whose names match the specified regexp."
             (multi-isearch-read-matching-buffers)
           (multi-isearch-read-buffers))))
   (let ((multi-isearch-next-buffer-function
-        'multi-isearch-next-buffer-from-list)
-       (multi-isearch-buffer-list (mapcar #'get-buffer buffers)))
+        'multi-isearch-next-buffer-from-list))
+    (setq multi-isearch-buffer-list (mapcar #'get-buffer buffers))
     (switch-to-buffer (car multi-isearch-buffer-list))
     (goto-char (if isearch-forward (point-min) (point-max)))
-    (isearch-forward-regexp)))
+    (isearch-forward-regexp nil t)))
 
 \f
 ;;; Global multi-file search invocations
@@ -326,8 +323,10 @@ Every next/previous file in the defined sequence is visited by
       (add-to-list 'files file))
     (nreverse files)))
 
+;; A regexp is not the same thing as a file glob - does this matter?
 (defun multi-isearch-read-matching-files ()
-  "Return a list of files whose names match specified wildcard."
+  "Return a list of files whose names match specified wildcard.
+Uses `read-regexp' to read the wildcard."
   ;; Most wildcard code from `find-file-noselect'.
   (let ((filename (read-regexp "Search in files whose names match wildcard")))
     (when (and filename
@@ -350,11 +349,11 @@ whose file names match the specified wildcard."
             (multi-isearch-read-matching-files)
           (multi-isearch-read-files))))
   (let ((multi-isearch-next-buffer-function
-        'multi-isearch-next-file-buffer-from-list)
-       (multi-isearch-file-list (mapcar #'expand-file-name files)))
+        'multi-isearch-next-file-buffer-from-list))
+    (setq multi-isearch-file-list (mapcar #'expand-file-name files))
     (find-file (car multi-isearch-file-list))
     (goto-char (if isearch-forward (point-min) (point-max)))
-    (isearch-forward)))
+    (isearch-forward nil t)))
 
 ;;;###autoload
 (defun multi-isearch-files-regexp (files)
@@ -369,14 +368,13 @@ whose file names match the specified wildcard."
             (multi-isearch-read-matching-files)
           (multi-isearch-read-files))))
   (let ((multi-isearch-next-buffer-function
-        'multi-isearch-next-file-buffer-from-list)
-       (multi-isearch-file-list (mapcar #'expand-file-name files)))
+        'multi-isearch-next-file-buffer-from-list))
+    (setq multi-isearch-file-list (mapcar #'expand-file-name files))
     (find-file (car multi-isearch-file-list))
     (goto-char (if isearch-forward (point-min) (point-max)))
-    (isearch-forward-regexp)))
+    (isearch-forward-regexp nil t)))
 
 \f
 (provide 'multi-isearch)
-
-;; arch-tag: a6d38ffa-4d14-4e39-8ac6-46af9d6a6773
+(provide 'misearch)
 ;;; misearch.el ends here