emacs-devel
[Top][All Lists]
Advanced

[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: Sun, 20 Jul 2008 22:38:04 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu)

>     whose single input argument accepts a list of files/buffers to search.
>     They then switch to the first file/buffer from this list and start
>     Isearch in it.
>
> It sounds good.  But I would like to point out that you are developing
> yet another way of specifying a set of buffers and then acting on
> those buffers.  In this case, the only kind of action is to search
> them, at least so far.  Maybe others could be added.

Many Emacs packages already have different ways of specifying a set
of buffers.  For instance, buff-menu.el and ibuffer.el use the key `m'
to mark a set of buffers, and other keys (like `x', `v') to operate
on a set of marked buffers.  I just added a new operation to the
existing packages that specify a set of buffers.

> There are other features of this general sort.  One of them is
> filesets.  It was meant to provide a general solution for this kind of
> thing, but it does not seem to have caught on much.  Perhaps it is not
> smoothly enough integrated with the rest of Emacs.

filesets.el is a promising package with presently poor user interface.
It displays a list of selected buffers only in the menu (not available
when the menu is turned off) or in a Customize buffer that displays one
customizable variable as a set of files.  I think a better way to display
filesets would be UI like provided by buffer-list, i.e. a special buffer
that displays a set of files and allows easily doing operations on them.

> Since you're starting on a new one, I wonder if you could turn this
> into a convenient interface for doing various operations on the same
> set of buffers.  If we succeed in doing this, once and for all, it will
> be a major step forward.

On the www site of the filesets project I've found a file filesets2.el
that contains features missing in the Emacs version of filesets.el.
These features provide integration with dired and ibuffer: there are
special commands to add a buffer from the ibuffer's buffer list to
a fileset, and to add dired marked buffers to a fileset.  I wonder
why the author didn't include them to Emacs.

Anyway, in the patch below I added Isearch operation on the filesets to
filesets.el.  And also fixed the existing multi-file query-replace
operation to use new keys to skip the current file and to do automatic
replacements in all remaining files (a feature implemented recently
in a separate patch).  It requires only adding `multi-query-replace-map'
and using the standard function to read query-replace arguments
`query-replace-read-args'.

Index: lisp/filesets.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/filesets.el,v
retrieving revision 1.39
diff -c -w -b -r1.39 filesets.el
*** lisp/filesets.el    27 Jun 2008 07:34:46 -0000      1.39
--- lisp/filesets.el    20 Jul 2008 19:35:03 -0000
***************
*** 565,576 ****
    :group 'filesets)
  
  (defcustom filesets-commands
!   `(("Query Replace"
!      query-replace
       (filesets-cmd-query-replace-getargs))
      ("Query Replace (regexp)"
!      query-replace-regexp
!      (filesets-cmd-query-replace-getargs))
      ("Grep <<selection>>"
       "grep"
       ("-n " filesets-get-quoted-selection " " "<<file-name>>"))
--- 565,582 ----
    :group 'filesets)
  
  (defcustom filesets-commands
!   `(("Isearch"
!      multi-isearch-files
!      (filesets-cmd-isearch-getargs))
!     ("Isearch (regexp)"
!      multi-isearch-files-regexp
!      (filesets-cmd-isearch-getargs))
!     ("Query Replace"
!      perform-replace
       (filesets-cmd-query-replace-getargs))
      ("Query Replace (regexp)"
!      perform-replace
!      (filesets-cmd-query-replace-regexp-getargs))
      ("Grep <<selection>>"
       "grep"
       ("-n " filesets-get-quoted-selection " " "<<file-name>>"))
***************
*** 1623,1628 ****
--- 1629,1636 ----
        (when files
          (let ((fn   (filesets-cmd-get-fn cmd-name))
                (args (filesets-cmd-get-args cmd-name)))
+           (if (memq fn '(multi-isearch-files multi-isearch-files-regexp))
+               (apply fn args)
              (dolist (this files nil)
                (save-excursion
                  (save-restriction
***************
*** 1654,1660 ****
                                                   (filesets-run-cmd--repl-fn
                                                    this
                                                    'list)))))))
!                           (apply fn args))))))))))))))))
  
  (defun filesets-get-cmd-menu ()
    "Create filesets command menu."
--- 1662,1668 ----
                                                     (filesets-run-cmd--repl-fn
                                                      this
                                                      'list)))))))
!                             (apply fn args)))))))))))))))))
  
  (defun filesets-get-cmd-menu ()
    "Create filesets command menu."
***************
*** 1668,1683 ****
  ;;; sample commands
  (defun filesets-cmd-query-replace-getargs ()
    "Get arguments for `query-replace' and `query-replace-regexp'."
!   (let* ((from-string (read-string "Filesets query replace: "
!                                  ""
!                                  'query-replace-history))
!        (to-string  (read-string
!                     (format "Filesets query replace %s with: " from-string)
!                     ""
!                     'query-replace-history))
!        (delimited  (y-or-n-p
!                     "Filesets query replace: respect word boundaries? ")))
!     (list from-string to-string delimited)))
  
  (defun filesets-cmd-shell-command-getargs ()
    "Get arguments for `filesets-cmd-shell-command'."
--- 1676,1694 ----
  ;;; sample commands
  (defun filesets-cmd-query-replace-getargs ()
    "Get arguments for `query-replace' and `query-replace-regexp'."
!   (let ((common (query-replace-read-args "Filesets query replace" nil t)))
!     (list (nth 0 common) (nth 1 common) t nil (nth 2 common) nil
!         multi-query-replace-map)))
! 
! (defun filesets-cmd-query-replace-regexp-getargs ()
!   "Get arguments for `query-replace' and `query-replace-regexp'."
!   (let ((common (query-replace-read-args "Filesets query replace" t t)))
!     (list (nth 0 common) (nth 1 common) t t (nth 2 common) nil
!         multi-query-replace-map)))
! 
! (defun filesets-cmd-isearch-getargs ()
!   "Get arguments for `multi-isearch-files' and `multi-isearch-files-regexp'."
!   (list files))
  
  (defun filesets-cmd-shell-command-getargs ()
    "Get arguments for `filesets-cmd-shell-command'."

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]