emacs-devel
[Top][All Lists]
Advanced

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

Re: M-g in dired


From: Juri Linkov
Subject: Re: M-g in dired
Date: Tue, 23 May 2006 08:16:14 +0300
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

>     Oops, this default was inserted by ffap.  When ffap-read-file-or-url
>     reads a directory/file name it uses the current buffer's file name as
>     default.  dired could do the same.
>
> The visited file name should not be the default for C-x d.  But it
> would be nice if the visited file name were easily accessible
> when you want it.  That's why I suggest putting it in the "future
> history" list.

For reading a directory/file name, ffap uses the function
`completing-read' with the value of the `initial-input' arg set
to the directory name, and the `default' arg set to the current buffer's
file name.  This has the effect that typing RET returns the directory name,
not the file name from the default value.  And only after typing `M-n RET'
it returns the default file name.

Is it possible to achieve the same effect by `read-file-name'
(which is used by dired)?

Essentially, what is used by ffap is:

    (completing-read "Dired file: "
     nil "~/" nil '("~/" . 2) 'file-name-history "~/.emacs")

    Typing `C-x C-e RET' returns "~/"
    Typing `C-x C-e M-n RET' returns "~/.emacs"

But trying to do the same for `read-file-name':

    (read-file-name "Dired file: " "~/" "~/.emacs" nil nil nil)

    Typing `C-x C-e RET' returns "~/.emacs", not "~/"
    Typing `C-x C-e M-n RET' returns "~/.emacs"

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





reply via email to

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