unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Find file in Dired - let M-n yank name at point?
@ 2006-08-18 23:50 Drew Adams
  2006-08-20 20:17 ` Drew Adams
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2006-08-18 23:50 UTC (permalink / raw)


Just a thought, probably not well thought out -

What about binding `C-x C-f', `C-x 4 f', `C-x C-v', and so on, in Dired, to
Dired-specific commands that let you use `M-n' to yank (append)
`dired-get-file-for-visit' onto the directory name that is the
`default-filename' arg for `read-file-name'?

That is, not change the default value for these commands, which is the
directory name, but let you add the file name under the cursor to that
directory name via `M-n'.

`a', `f', `RET', `o', `e', and `mouse-2' visit the file under the cursor
quickly, but they don't let you edit the name first.

I haven't tried this yet; it just occurred to me. Don't know if it would be
a good idea, but I can't see why not. Currently, `M-n' just says there is
nothing available. Why not make this name available, and give `M-n'
something useful to do in this situation?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Find file in Dired - let M-n yank name at point?
  2006-08-18 23:50 Find file in Dired - let M-n yank name at point? Drew Adams
@ 2006-08-20 20:17 ` Drew Adams
  2006-08-22  3:09   ` Richard Stallman
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2006-08-20 20:17 UTC (permalink / raw)


    What about binding `C-x C-f', `C-x 4 f', `C-x C-v', and so on,
    in Dired, to Dired-specific commands that let you use `M-n' to
    yank (append) `dired-get-file-for-visit' onto the directory
    name that is the `default-filename' arg for `read-file-name'?

    That is, not change the default value for these commands,
    which is the directory name, but let you add the file name
    under the cursor to that directory name via `M-n'.

    `a', `f', `RET', `o', `e', and `mouse-2' visit the file under
    the cursor quickly, but they don't let you edit the name first.

    I haven't tried this yet; it just occurred to me. Don't know if
    it would be a good idea, but I can't see why not. Currently,
    `M-n' just says there is nothing available. Why not make this
    name available, and give `M-n' something useful to do in this
    situation?

This suggestion got no uptake either way, for or against.

FWIW, I've played with it now, and I like it. It takes nothing away from the
current behavior, I believe; it just lets you easily grab the file name that
the cursor is on.

The implementation can be trivial. This is one way to do it (in case you
want to play with it):

(defun find-file-read-args (prompt mustmatch)
  (list (let ((find-file-default
               (if (eq major-mode 'dired-mode)
                   (abbreviate-file-name (dired-get-file-for-visit))
                 (and buffer-file-name (abbreviate-file-name
                                         buffer-file-name)))))
          (minibuffer-with-setup-hook
              (lambda () (setq minibuffer-default find-file-default))
            (read-file-name prompt nil default-directory mustmatch)))
        t))

Again, the advantage over using, say, RET (`dired-find-file'), is that you
can edit the file name.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Find file in Dired - let M-n yank name at point?
  2006-08-20 20:17 ` Drew Adams
@ 2006-08-22  3:09   ` Richard Stallman
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Stallman @ 2006-08-22  3:09 UTC (permalink / raw)
  Cc: emacs-devel

	What about binding `C-x C-f', `C-x 4 f', `C-x C-v', and so on,
	in Dired, to Dired-specific commands that let you use `M-n' to
	yank (append) `dired-get-file-for-visit' onto the directory
	name that is the `default-filename' arg for `read-file-name'?

It is a good feature, but I would rather implement it in a cleaner
way, with a hook that tells file name reading how to set up the
value for M-n.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-08-22  3:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-18 23:50 Find file in Dired - let M-n yank name at point? Drew Adams
2006-08-20 20:17 ` Drew Adams
2006-08-22  3:09   ` Richard Stallman

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).