emacs-devel
[Top][All Lists]
Advanced

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

find-dired.el


From: Luc Teirlinck
Subject: find-dired.el
Date: Mon, 31 May 2004 21:43:10 -0500 (CDT)

Below is the latest version of my patch to find-dired.el.  It needs
the patch to dired-aux.el, that I will send somewhat later, to
function properly.

One remaining problem with *Locate* and *Find* buffers is that if one
does `l' _on the very first line_, the directory will update in a
way that makes sense for Dired, but not for *Locate* or *Find*
buffers.  The effect can easily be undone using dired-undo, usually
bound to C-_ and C-x u.  Everything continues to work after that.
Doing `l' on the main directory is not a very usual thing to do.
After my patch to dired-aux, `l' and `C-u l' seem to work perfectly
on subdirectories.  The "l in the first line problem" already occurred
prior to my patch for *Locate* buffers.  It did not occur for *Find*
buffers, but the only reason for that is that neither `i' nor `l'
worked at all for *Find* buffers due to a bug I fixed.
 
The only solution around the "l on the first line problem" seems to be
to define separate `locate-do-redisplay' and `find-dired-do-redisplay'
functions, whose only difference with `dired-do-redisplay' would be
that they throw an error on the first line.  I do not believe that is
worth the trouble, since an inadvertent `l' on the first line, can
easily be undone with dired-undo.

===File ~/find-dired-diff===================================
diff -c /home/teirllm/stored/find-dired.old.el 
/home/teirllm/emacscvsdir/emacs/lisp/find-dired.el
*** /home/teirllm/stored/find-dired.old.el      Sat May 29 15:55:43 2004
--- /home/teirllm/emacscvsdir/emacs/lisp/find-dired.el  Fri May 28 11:38:32 2004
***************
*** 54,59 ****
--- 54,67 ----
               (string :tag "Ls Switches"))
    :group 'find-dired)
  
+ (defcustom find-ls-subdir-switches "-al"
+   "`ls' switches for inserting subdirectories in *Find* buffers.
+ This should contain the \"-l\" switch.
+ Use the \"-F\" switch if and only if you also use it for `find-ls-option'."
+   :type 'string
+   :group 'find-dired
+   :version "21.4")
+ 
  ;;;###autoload
  (defcustom find-grep-options
    (if (or (eq system-type 'berkeley-unix)
***************
*** 89,96 ****
    (let ((dired-buffers dired-buffers))
      ;; Expand DIR ("" means default-directory), and make sure it has a
      ;; trailing slash.
!     (setq dir (abbreviate-file-name
!              (file-name-as-directory (expand-file-name dir))))
      ;; Check that it's really a directory.
      (or (file-directory-p dir)
        (error "find-dired needs a directory: %s" dir))
--- 97,103 ----
    (let ((dired-buffers dired-buffers))
      ;; Expand DIR ("" means default-directory), and make sure it has a
      ;; trailing slash.
!     (setq dir (file-name-as-directory (expand-file-name dir)))
      ;; Check that it's really a directory.
      (or (file-directory-p dir)
        (error "find-dired needs a directory: %s" dir))
***************
*** 115,121 ****
      (setq buffer-read-only nil)
      (erase-buffer)
      (setq default-directory dir
!         find-args args                ; save for next interactive call
          args (concat find-dired-find-program " . "
                       (if (string= args "")
                           ""
--- 122,128 ----
      (setq buffer-read-only nil)
      (erase-buffer)
      (setq default-directory dir
!         find-args args              ; save for next interactive call
          args (concat find-dired-find-program " . "
                       (if (string= args "")
                           ""
***************
*** 128,133 ****
--- 135,141 ----
      (let ((map (make-sparse-keymap)))
        (set-keymap-parent map (current-local-map))
        (define-key map "\C-c\C-k" 'kill-find)
+       (define-key map "i" 'find-dired-maybe-insert-subdir)
        (use-local-map map))
      (make-local-variable 'dired-sort-inhibit)
      (setq dired-sort-inhibit t)
***************
*** 267,272 ****
--- 275,302 ----
              (delete-process proc)
              (force-mode-line-update)))
          (message "find-dired %s finished." (current-buffer))))))
+ 
+ (defun find-dired-maybe-insert-subdir (dirname &optional
+                                              switches no-error-if-not-dir-p)
+   "Like `dired-maybe-insert-subdir', but works with `find-dired'.
+ The difference is that this command uses `find-ls-subdir-switches'
+ as default switches passed to ls. As with `dired-maybe-insert-subdir',
+ you can specify other switches by providing a numeric prefix argument."
+   ;; Code adapted from dired-maybe-insert-subdir
+   (interactive
+    (list (dired-get-filename)
+        (if current-prefix-arg
+            (read-string "Switches for listing: "
+                         find-ls-subdir-switches))))
+   (let ((opoint (point)))
+     (setq dirname (file-name-as-directory dirname))
+     (or (and (not switches)
+            (dired-goto-subdir dirname))
+       (dired-insert-subdir dirname
+                            (or switches find-ls-subdir-switches)
+                            no-error-if-not-dir-p))
+     (push-mark opoint)))
+ 
  
  (provide 'find-dired)
  

Diff finished.  Mon May 31 20:44:52 2004
============================================================




reply via email to

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