[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: isearch multiple buffers
From: |
Juri Linkov |
Subject: |
Re: isearch multiple buffers |
Date: |
Sat, 20 Oct 2007 03:08:08 +0300 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux) |
> > Perhaps, we should add a new user option with 3 possible values:
> > 1. don't stop in the initial buffer
> > 2. stop once in the initial buffer
> 3. stop in every buffer which contains the search string
> (and always stop in the first buffer)
>
> So there are three useful options (and let's try using the 3-rd as the
> default).
>
> If you want to implement all three, please do.
I implemented a new user option isearch-buffers-pause with these
three values, with the default to pause in every buffer that contains
the search string.
Also I implemented a new minor mode isearch-buffers-minor-mode
that sets a group of variables necessary for this feature.
Turning off this minor mode deletes all created buffer-local bindings.
So any major mode that uses this feature can simply set the variable
isearch-buffers-next-buffer-function and call isearch-buffers-minor-mode.
The code implementing this feature has so many lines now that I think it
needs a separate file. One possible name would be isearchb.el, but this
name is already occupied by another package. So I think a good name will
be isearch-et.el (isearch everything :-) as I plan to add more isearch
extensions to this new file.
Below are two NEWS entries, a patch for the first package add-log.el
that uses this feature, a small patch for isearch.el, and a new file
isearch-et.el:
** The package isearch-et.el has been added. It implements a new mode
`isearch-buffers-minor-mode' that allows isearch to search through
multiple buffers. In this mode a new variable
`isearch-buffers-next-buffer-function' defines the function to call to get
the next buffer to search in the series of multiple buffers.
** isearch can now search through multiple ChangeLog files.
When running isearch in a ChangeLog file, if the search fails,
then another C-s tries searching the previous ChangeLog,
if there is one (e.g. go from ChangeLog to ChangeLog.12).
Index: lisp/add-log.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/add-log.el,v
retrieving revision 1.197
diff -c -r1.197 add-log.el
*** lisp/add-log.el 10 Oct 2007 18:52:44 -0000 1.197
--- lisp/add-log.el 20 Oct 2007 00:00:55 -0000
***************
*** 760,766 ****
'change-log-resolve-conflict)
(set (make-local-variable 'adaptive-fill-regexp) "\\s *")
(set (make-local-variable 'font-lock-defaults)
! '(change-log-font-lock-keywords t nil nil backward-paragraph)))
;; It might be nice to have a general feature to replace this. The idea I
;; have is a variable giving a regexp matching text which should not be
--- 760,788 ----
'change-log-resolve-conflict)
(set (make-local-variable 'adaptive-fill-regexp) "\\s *")
(set (make-local-variable 'font-lock-defaults)
! '(change-log-font-lock-keywords t nil nil backward-paragraph))
! (set (make-local-variable 'isearch-buffers-next-buffer-function)
! 'change-log-next-buffer)
! (isearch-buffers-minor-mode))
!
! (defun change-log-next-buffer (&optional buffer wrap)
! "Return the next buffer in the series of ChangeLog file buffers.
! This function is used for multiple buffers isearch.
! A sequence of buffers is formed by ChangeLog files with decreasing
! numeric file name suffixes in the directory of the initial ChangeLog
! file were isearch was started."
! (let* ((name (change-log-name))
! (files (cons name (sort (file-expand-wildcards
! (concat name "[-.][0-9]*"))
! (lambda (a b)
! (version< (substring b (length name))
! (substring a (length name)))))))
! (files (if isearch-forward files (reverse files))))
! (find-file-noselect
! (if wrap
! (car files)
! (cadr (member (file-name-nondirectory (buffer-file-name buffer))
! files))))))
;; It might be nice to have a general feature to replace this. The idea I
;; have is a variable giving a regexp matching text which should not be
Index: lisp/isearch.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.303
diff -c -r1.303 isearch.el
*** lisp/isearch.el 29 Aug 2007 05:28:05 -0000 1.303
--- lisp/isearch.el 20 Oct 2007 00:02:31 -0000
***************
*** 2035,2042 ****
(if isearch-forward (< pos2 pos1) (> pos2 pos1))))
(setq pos1 pos2)
(set-match-data match-data)))))
! (if pos1
! (goto-char pos1))
pos1))
(defun isearch-search ()
--- 2045,2059 ----
(if isearch-forward (< pos2 pos1) (> pos2 pos1))))
(setq pos1 pos2)
(set-match-data match-data)))))
! (when pos1
! ;; When using multiple buffers isearch, switch to the new buffer here,
! ;; because `save-excursion' above doesn't allow doing it inside funcall.
! (if (and (boundp 'isearch-buffers-next-buffer-function)
! isearch-buffers-next-buffer-function
! (boundp 'isearch-buffers-current-buffer)
! (buffer-live-p isearch-buffers-current-buffer))
! (switch-to-buffer isearch-buffers-current-buffer))
! (goto-char pos1))
pos1))
(defun isearch-search ()
isearch-et.el
Description: application/emacs-lisp
--
Juri Linkov
http://www.jurta.org/emacs/
- Re: isearch multiple buffers, (continued)
- Re: isearch multiple buffers, Juri Linkov, 2007/10/08
- Re: isearch multiple buffers, Johan Bockgård, 2007/10/11
- Re: isearch multiple buffers, Juri Linkov, 2007/10/11
- Re: isearch multiple buffers, Stefan Monnier, 2007/10/11
- Re: isearch multiple buffers, Juri Linkov, 2007/10/11
- Re: isearch multiple buffers, Richard Stallman, 2007/10/11
- Re: isearch multiple buffers, Juri Linkov, 2007/10/11
- Re: isearch multiple buffers, Johan Bockgård, 2007/10/12
- Re: isearch multiple buffers, Richard Stallman, 2007/10/12
- Re: isearch multiple buffers, Stefan Monnier, 2007/10/12
- Re: isearch multiple buffers,
Juri Linkov <=
- Re: isearch multiple buffers, Richard Stallman, 2007/10/21
- Re: isearch multiple buffers, Juri Linkov, 2007/10/21
- Re: isearch multiple buffers, Miles Bader, 2007/10/21
- Re: isearch multiple buffers, Lennart Borgman (gmail), 2007/10/21
- Re: isearch multiple buffers, Stefan Monnier, 2007/10/21
- Re: isearch multiple buffers, Miles Bader, 2007/10/21
- Re: isearch multiple buffers, Richard Stallman, 2007/10/23
- Re: isearch multiple buffers, David Kastrup, 2007/10/23
- Re: isearch multiple buffers, Richard Stallman, 2007/10/23
- Re: isearch multiple buffers, Eli Zaretskii, 2007/10/23