emacs-devel
[Top][All Lists]
Advanced

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

`i' in find-dired


From: Luc Teirlinck
Subject: `i' in find-dired
Date: Wed, 26 May 2004 21:30:43 -0500 (CDT)

`i' in *Find* buffers (I am _not_ talking about *Locate* buffers this
time) does currently not work.  Two reasons: it passes the `d' switch
to `ls', which is inappropriate for `i'.  More bizarre is what happens
if one tries out `i' in one's home directory, or a subdirectory
thereof.  It immediately throws an error.  The reason is that
`find-dired' calls abbreviate-file-name on its directory.  Hence, the
directory is "~" instead of, say. "/home/teirllm.  But to several
parts of dired and, in particular to `dired-tree-lessp', "~" is "/:~".

Why does find-dired call abbreviate-file-name?  If it is to replace
/home/teirllm with "~", then it is inconsistent with dired, which is
not prepared for that.  It can not be to avoid using names that the
user is not familiar with, because it is the user who entered that
name.  The patch below gets rid of the `abbreviate-file-name' and
makes other changes that make `i' work satisfactorily.

I could install the patch if desired.
  
There is one more problem that the patch below does _not_ address.
`find-dired' puts the buffer in plain dired-mode, but changes
keybindings using:

    (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))

The "i" is added by my proposed patch, but the "\C-c\C-k" was there
before.  But `C-h m' will list dired-mode-map.  Hence "i" will be
shown as bound to dired-maybe-insert-subdir, instead of
find-dired-maybe-insert-subdir.  This problem is introduced by my
patch.  "\C-c\C-k" will not be shown at all.  This problem is already
present.  `C-h b' will list the correct bindings.

What is the best way to deal with this kind of problem?  Just ignore
it?  Or defining a separate `find-dired-mode' and `find-dired-mode-map'?
The former might allow for a more accurate description of *Find*
buffers and the latter for better customizability of bindings.
However, maybe it would be overkill in this case.

===File ~/find-dired-diff===================================
*** find-dired.el       08 Mar 2004 16:42:52 -0600      1.47
--- find-dired.el       26 May 2004 19:21:53 -0500      
***************
*** 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,296 ----
              (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."
+   (interactive
+    (list (dired-get-filename)
+        (if current-prefix-arg
+            (read-string "Switches for listing: "
+                         find-ls-subdir-switches)
+          find-ls-subdir-switches)))
+   (dired-maybe-insert-subdir dirname switches no-error-if-not-dir-p))
+ 
+ 
  
  (provide 'find-dired)
  
============================================================




reply via email to

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