emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

locate and find-dired (was: insert-directory)


From: Juri Linkov
Subject: locate and find-dired (was: insert-directory)
Date: Mon, 07 Jun 2004 12:59:23 +0300
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Kai Grossjohann <address@hidden> writes:
> I wonder if it makes sense to have the locate output look more like
> the find-dired output?  Then the buffer could be in dired mode
> normally.  (One could call file-attributes on each filename returned
> by locate and construct "ls -l" like output from that.)

This would be very useful, because often there is a need to look at
file attributes of files returned by locate, and also it will allow
dired operations on files.

There are at least two solutions.  One doesn't require any
modification and can be simply invoked as:

C-u M-x locate RET locate filename | xargs ls -alG RET

This produces interesting results with recent Luc's changes: it
automatically inserts found subdirectories into *Locate* buffer.

Another solution is to extend find-dired.el to allow arbitrary
command lines.  For example, a new variable `find-dired-program'
could be set to "locate %s | xargs ls ", so results of `locate'
are put into dired mode.  [Note that the code below is NOT a finished
patch for installing into CVS, this is simply an example of possible
extension of find-dired.el]

--- lisp/find-dired.el  6 Jun 2004 02:30:21 -0000       1.48
+++ lisp/find-dired.el  7 Jun 2004 09:48:43 -0000
@@ -40,6 +40,11 @@
   :group 'dired
   :type 'file)
 
+(defcustom find-dired-program nil
+  "Command line used to find files."
+  :group 'dired
+  :type 'string)
+
 ;; find's -ls corresponds to these switches.
 ;; Note -b, at least GNU find quotes spaces etc. in filenames
 ;;;###autoload
@@ -125,11 +130,14 @@
     (erase-buffer)
     (setq default-directory dir
          find-args args              ; save for next interactive call
-         args (concat find-dired-find-program " . "
+         args (if find-dired-program
+                   (concat (format find-dired-program args)
+                           (cdr find-ls-option))
+                 (concat find-dired-find-program " . "
                       (if (string= args "")
                           ""
                         (concat "\\( " args " \\) "))
-                      (car find-ls-option)))
+                      (car find-ls-option))))
     ;; Start the find process.
     (shell-command (concat args "&") (current-buffer))
     ;; The next statement will bomb in classic dired (no optional arg allowed)

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





reply via email to

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