annotate lisp/isearch-multi.el @ 95387:be7d86474ead

(Faccept_process_output): If `millisec' is non-nil, `seconds' default to 0. (wait_reading_process_output): Also return non-nil if we read output from a non-running process.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 29 May 2008 16:54:53 +0000
parents ee5932bf781d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
85568
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
1 ;;; isearch-multi.el --- isearch extensions for multi-buffer search
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
2
87665
b9e8ab94c460 Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86062
diff changeset
3 ;; Copyright (C) 2007, 2008 Free Software Foundation, Inc.
85568
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
4
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
5 ;; Author: Juri Linkov <juri@jurta.org>
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
6 ;; Keywords: matching
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
7
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
9
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87665
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
85568
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87665
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87665
diff changeset
13 ;; (at your option) any later version.
85568
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
14
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
19
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87665
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
85568
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
22
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
23 ;;; Commentary:
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
24
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
25 ;; This file adds more dimensions to the search space. It implements
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
26 ;; various features that extend isearch. One of them is an ability to
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
27 ;; search through multiple buffers.
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
28
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
29 ;;; Code:
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
30
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
31 ;;; Search multiple buffers
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
32
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
33 (defgroup isearch-buffers nil
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
34 "Using isearch to search through multiple buffers."
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
35 :version "23.1"
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
36 :group 'isearch)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
37
85667
4516d805659c (isearch-buffers-multi): New option.
Richard M. Stallman <rms@gnu.org>
parents: 85604
diff changeset
38 (defcustom isearch-buffers-multi t
4516d805659c (isearch-buffers-multi): New option.
Richard M. Stallman <rms@gnu.org>
parents: 85604
diff changeset
39 "Non-nil enables searching multiple related buffers, in certain modes."
4516d805659c (isearch-buffers-multi): New option.
Richard M. Stallman <rms@gnu.org>
parents: 85604
diff changeset
40 :type 'boolean
4516d805659c (isearch-buffers-multi): New option.
Richard M. Stallman <rms@gnu.org>
parents: 85604
diff changeset
41 :version "23.1"
4516d805659c (isearch-buffers-multi): New option.
Richard M. Stallman <rms@gnu.org>
parents: 85604
diff changeset
42 :group 'isearch-buffers)
4516d805659c (isearch-buffers-multi): New option.
Richard M. Stallman <rms@gnu.org>
parents: 85604
diff changeset
43
85568
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
44 (defcustom isearch-buffers-pause t
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
45 "A choice defining where to pause the search.
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
46 If the value is nil, don't pause before going to the next buffer.
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
47 If the value is `initial', pause only after a failing search in the
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
48 initial buffer.
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
49 If t, pause in all buffers that contain the search string."
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
50 :type '(choice
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
51 (const :tag "Don't pause" nil)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
52 (const :tag "Only in initial buffer" initial)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
53 (const :tag "All buffers" t))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
54 :version "23.1"
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
55 :group 'isearch-buffers)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
56
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
57 ;;;###autoload
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
58 (defvar isearch-buffers-current-buffer nil
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
59 "The buffer where the search is currently searching.
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
60 The value is nil when the search still is in the initial buffer.")
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
61
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
62 ;;;###autoload
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
63 (defvar isearch-buffers-next-buffer-function nil
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
64 "Function to call to get the next buffer to search.
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
65
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
66 When this variable is set to a function that returns a buffer, then
86062
f4816ef45bcb (isearch-buffers-next-buffer-function): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 85667
diff changeset
67 after typing another \\[isearch-forward] or \\[isearch-backward] \
f4816ef45bcb (isearch-buffers-next-buffer-function): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 85667
diff changeset
68 at a failing search, the search goes
85568
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
69 to the next buffer in the series and continues searching for the
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
70 next occurrence.
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
71
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
72 The first argument of this function is the current buffer where the
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
73 search is currently searching. It defines the base buffer relative to
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
74 which this function should find the next buffer. When the isearch
86062
f4816ef45bcb (isearch-buffers-next-buffer-function): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 85667
diff changeset
75 direction is backward (when `isearch-forward' is nil), this function
f4816ef45bcb (isearch-buffers-next-buffer-function): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 85667
diff changeset
76 should return the previous buffer to search. If the second argument of
85568
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
77 this function WRAP is non-nil, then it should return the first buffer
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
78 in the series; and for the backward search, it should return the last
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
79 buffer in the series.")
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
80
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
81 ;;;###autoload
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
82 (define-minor-mode isearch-buffers-minor-mode
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
83 "Minor mode for using isearch to search through multiple buffers.
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
84 With arg, turn isearch-buffers minor mode on if arg is positive, off otherwise."
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
85 :group 'isearch-buffers ;; :lighter " X"
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
86 (if isearch-buffers-minor-mode
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
87 (progn
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
88 (add-hook 'isearch-mode-hook 'isearch-buffers-init nil t)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
89 (set (make-local-variable 'isearch-search-fun-function)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
90 'isearch-buffers-search-fun)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
91 (set (make-local-variable 'isearch-wrap-function)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
92 'isearch-buffers-wrap)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
93 (set (make-local-variable 'isearch-push-state-function)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
94 'isearch-buffers-push-state))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
95 (remove-hook 'isearch-mode-hook 'isearch-buffers-init t)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
96 (kill-local-variable 'isearch-search-fun-function)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
97 (kill-local-variable 'isearch-wrap-function)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
98 (kill-local-variable 'isearch-push-state-function)))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
99
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
100 (defun isearch-buffers-init ()
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
101 "Set up isearch to search multiple buffers.
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
102 Intended to be added to `isearch-mode-hook'."
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
103 (setq isearch-buffers-current-buffer nil))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
104
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
105 (defun isearch-buffers-search-fun ()
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
106 "Return the proper search function, for isearch in multiple buffers."
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
107 (lambda (string bound noerror)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
108 (let ((search-fun
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
109 ;; Use standard functions to search within one buffer
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
110 (cond
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
111 (isearch-word
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
112 (if isearch-forward 'word-search-forward 'word-search-backward))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
113 (isearch-regexp
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
114 (if isearch-forward 're-search-forward 're-search-backward))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
115 (t
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
116 (if isearch-forward 'search-forward 'search-backward))))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
117 found buffer)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
118 (or
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
119 ;; 1. First try searching in the initial buffer
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
120 (let ((res (funcall search-fun string bound noerror)))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
121 ;; Reset wrapping for all-buffers pause after successful search
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
122 (if (and res (eq isearch-buffers-pause t))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
123 (setq isearch-buffers-current-buffer nil))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
124 res)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
125 ;; 2. If the above search fails, start visiting next/prev buffers
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
126 ;; successively, and search the string in them. Do this only
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
127 ;; when bound is nil (i.e. not while lazy-highlighting search
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
128 ;; strings in the current buffer).
85667
4516d805659c (isearch-buffers-multi): New option.
Richard M. Stallman <rms@gnu.org>
parents: 85604
diff changeset
129 (when (and (not bound) isearch-buffers-multi)
85568
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
130 ;; If no-pause or there was one attempt to leave the current buffer
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
131 (if (or (null isearch-buffers-pause)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
132 (and isearch-buffers-pause isearch-buffers-current-buffer))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
133 (condition-case nil
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
134 (progn
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
135 (while (not found)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
136 ;; Find the next buffer to search
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
137 (setq buffer (funcall isearch-buffers-next-buffer-function
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
138 buffer))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
139 (with-current-buffer buffer
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
140 (goto-char (if isearch-forward (point-min) (point-max)))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
141 (setq isearch-barrier (point) isearch-opoint (point))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
142 ;; After visiting the next/prev buffer search the
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
143 ;; string in it again, until the function in
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
144 ;; isearch-buffers-next-buffer-function raises an error
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
145 ;; at the beginning/end of the buffer sequence.
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
146 (setq found (funcall search-fun string bound noerror))))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
147 ;; Set buffer for isearch-search-string to switch
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
148 (if buffer (setq isearch-buffers-current-buffer buffer))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
149 ;; Return point of the new search result
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
150 found)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
151 ;; Return nil when isearch-buffers-next-buffer-function fails
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
152 (error nil))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
153 (signal 'search-failed (list string "Repeat for next buffer"))))))))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
154
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
155 (defun isearch-buffers-wrap ()
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
156 "Wrap the multiple buffers search when search is failed.
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
157 Switch buffer to the first buffer for a forward search,
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
158 or to the last buffer for a backward search.
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
159 Set `isearch-buffers-current-buffer' to the current buffer to display
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
160 the isearch suffix message [initial buffer] only when isearch leaves
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
161 the initial buffer."
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
162 (if (or (null isearch-buffers-pause)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
163 (and isearch-buffers-pause isearch-buffers-current-buffer))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
164 (progn
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
165 (switch-to-buffer
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
166 (setq isearch-buffers-current-buffer
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
167 (funcall isearch-buffers-next-buffer-function
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
168 (current-buffer) t)))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
169 (goto-char (if isearch-forward (point-min) (point-max))))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
170 (setq isearch-buffers-current-buffer (current-buffer))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
171 (setq isearch-wrapped nil)))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
172
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
173 (defun isearch-buffers-push-state ()
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
174 "Save a function restoring the state of multiple buffers search.
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
175 Save the current buffer to the additional state parameter in the
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
176 search status stack."
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
177 `(lambda (cmd)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
178 (isearch-buffers-pop-state cmd ,(current-buffer))))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
179
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
180 (defun isearch-buffers-pop-state (cmd buffer)
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
181 "Restore the multiple buffers search state.
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
182 Switch to the buffer restored from the search status stack."
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
183 (unless (equal buffer (current-buffer))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
184 (switch-to-buffer (setq isearch-buffers-current-buffer buffer))))
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
185
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
186 (provide 'isearch-multi)
85604
14c6e96eeaad Add arch tagline
Miles Bader <miles@gnu.org>
parents: 85568
diff changeset
187
14c6e96eeaad Add arch tagline
Miles Bader <miles@gnu.org>
parents: 85568
diff changeset
188 ;; arch-tag: a6d38ffa-4d14-4e39-8ac6-46af9d6a6773
85568
76aa2c1e4934 New file.
Juri Linkov <juri@jurta.org>
parents:
diff changeset
189 ;;; isearch-multi.el ends here