all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Luc Teirlinck <teirllm@dms.auburn.edu>
Subject: `i' in find-dired
Date: Wed, 26 May 2004 21:30:43 -0500 (CDT)	[thread overview]
Message-ID: <200405270230.i4R2Uhc23125@raven.dms.auburn.edu> (raw)

`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))
+ 
+ 
  \f
  (provide 'find-dired)
  
============================================================

                 reply	other threads:[~2004-05-27  2:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200405270230.i4R2Uhc23125@raven.dms.auburn.edu \
    --to=teirllm@dms.auburn.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.