unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* ido-read-file-name default-filename
@ 2005-08-18  0:14 Karl Chen
  2005-08-18  8:52 ` Kim F. Storm
  0 siblings, 1 reply; 6+ messages in thread
From: Karl Chen @ 2005-08-18  0:14 UTC (permalink / raw)
  Cc: Emacs Developement List


A number of functions that call `read-file-name' utilize the
`default-filename' parameter, or its default.  E.g., M-x
diff-backup RET should diff the current file instead of attempting
to diff the current directory.  I.e., regular `read-file-name'
returns `(or default-filename buffer-file-name)'.  Currently
`ido-read-file-name' always returns default-directory if the user
presses only RET.

I would like ido-read-file-name to heed default-filename.  I'm
willing to implement it.


Note that I think ido-find-file behavior shouldn't change,
i.e. ido-find-file RET should still dired the current directory.
(I also used Kevin Rodgers' find-file advice to also change
find-file's behavior thus.)

-- 
Karl 2005-08-17 16:55

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

* Re: ido-read-file-name default-filename
  2005-08-18  0:14 ido-read-file-name default-filename Karl Chen
@ 2005-08-18  8:52 ` Kim F. Storm
  2006-05-17  8:31   ` Karl Chen
  0 siblings, 1 reply; 6+ messages in thread
From: Kim F. Storm @ 2005-08-18  8:52 UTC (permalink / raw)
  Cc: Emacs Developement List

Karl Chen <quarl@cs.berkeley.edu> writes:

> A number of functions that call `read-file-name' utilize the
> `default-filename' parameter, or its default.  E.g., M-x
> diff-backup RET should diff the current file instead of attempting
> to diff the current directory.  I.e., regular `read-file-name'
> returns `(or default-filename buffer-file-name)'.  Currently
> `ido-read-file-name' always returns default-directory if the user
> presses only RET.

I guess this is an oversight on my part.

>
> I would like ido-read-file-name to heed default-filename.  I'm
> willing to implement it.

Please do.

>
>
> Note that I think ido-find-file behavior shouldn't change,
> i.e. ido-find-file RET should still dired the current directory.

Yes.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: ido-read-file-name default-filename
  2005-08-18  8:52 ` Kim F. Storm
@ 2006-05-17  8:31   ` Karl Chen
  2006-05-17 21:04     ` Kim F. Storm
       [not found]     ` <m34pzobaz4.fsf@kfs-l.imdomain.dk>
  0 siblings, 2 replies; 6+ messages in thread
From: Karl Chen @ 2006-05-17  8:31 UTC (permalink / raw)
  Cc: Emacs Developement List

>>>>> On 2005-08-18 01:52 PDT, Kim F Storm writes:

    Karl> I would like ido-read-file-name to heed
    Karl> default-filename.  I'm willing to implement it.

    Kim> Please do.

I finally got around doing this.


--- ido.el	06 Apr 2006 03:35:22 -0700	1.93
+++ ido.el	17 May 2006 01:28:50 -0700	
@@ -4468,6 +4468,7 @@
 	     (vc-handled-backends (and (boundp 'vc-handled-backends) vc-handled-backends))
 	     (minibuffer-completing-file-name t)
 	     (ido-current-directory (ido-expand-directory dir))
+             (ido-initial-directory ido-current-directory)
 	     (ido-directory-nonreadable (not (file-readable-p ido-current-directory)))
 	     (ido-directory-too-big (and (not ido-directory-nonreadable)
 					 (ido-directory-too-big-p ido-current-directory)))
@@ -4482,6 +4483,8 @@
 	  (setq filename 'fallback))
 	 ((eq ido-exit 'dired)
 	  (setq filename ido-current-directory))
+         ((and default-filename (string= filename ".") (string= ido-current-directory ido-initial-directory))
+          (setq filename default-filename))
 	 (filename
 	  (setq filename
 		(concat ido-current-directory filename))))))


-- 
Karl 2006-05-17 01:26

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

* Re: ido-read-file-name default-filename
  2006-05-17  8:31   ` Karl Chen
@ 2006-05-17 21:04     ` Kim F. Storm
       [not found]     ` <m34pzobaz4.fsf@kfs-l.imdomain.dk>
  1 sibling, 0 replies; 6+ messages in thread
From: Kim F. Storm @ 2006-05-17 21:04 UTC (permalink / raw)
  Cc: Emacs Developement List

Karl Chen <quarl@cs.berkeley.edu> writes:

>>>>>> On 2005-08-18 01:52 PDT, Kim F Storm writes:
>
>     Karl> I would like ido-read-file-name to heed
>     Karl> default-filename.  I'm willing to implement it.
>
>     Kim> Please do.
>
> I finally got around doing this.

Thanks, but this only works if ido-show-dot-for-dired is t.

I think a proper fix would be to simply move the default-filename
to the front of the choices list, so RET will select it.  I will
try to make that change.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: ido-read-file-name default-filename
       [not found]     ` <m34pzobaz4.fsf@kfs-l.imdomain.dk>
@ 2006-05-18  0:20       ` Karl Chen
  2006-05-18  7:44         ` Kim F. Storm
  0 siblings, 1 reply; 6+ messages in thread
From: Karl Chen @ 2006-05-18  0:20 UTC (permalink / raw)
  Cc: Emacs Developement List

>>>>> On 2006-05-17 14:25 PDT, Kim F Storm writes:

    Kim> I have installed a change which I think will fix this in
    Kim> general.  Please try the latest version.

Hi Kim, it works, but only when ido-show-dot-for-dired is nil.
The use case 
    (ido-everywhere 1)
    M-x diff RET
    RET for current buffer-file-name

Perhaps the solution is if default-filename is not nil, then
initially put it before "." even if ido-show-dot-for-dired.  Or
maybe diff-mode should let-bind ido-show-dot-for-dired nil.  

I guess one problem is read-file-name is overloaded for 2
different use cases: 1. read a file name (not a directory), and
2. read a file name or a directory name.  Separating
read-file-name into two functions or adding a flag indicating
intent would help.

-- 
Karl 2006-05-17 17:15

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

* Re: ido-read-file-name default-filename
  2006-05-18  0:20       ` Karl Chen
@ 2006-05-18  7:44         ` Kim F. Storm
  0 siblings, 0 replies; 6+ messages in thread
From: Kim F. Storm @ 2006-05-18  7:44 UTC (permalink / raw)
  Cc: Emacs Developement List

Karl Chen <quarl@cs.berkeley.edu> writes:

>>>>>> On 2006-05-17 14:25 PDT, Kim F Storm writes:
>
>     Kim> I have installed a change which I think will fix this in
>     Kim> general.  Please try the latest version.
>
> Hi Kim, it works, but only when ido-show-dot-for-dired is nil.

Rats.

> The use case 
>     (ido-everywhere 1)
>     M-x diff RET
>     RET for current buffer-file-name
>
> Perhaps the solution is if default-filename is not nil, then
> initially put it before "." even if ido-show-dot-for-dired.  Or
> maybe diff-mode should let-bind ido-show-dot-for-dired nil.  

Or ido-read-file-name should simply bind ido-show-dot-for-dired to nil
when default-filename is specified and it is not explicitly reading a
directory name.

Can you try this patch:

*** ido.el	17 May 2006 23:23:34 +0200	1.94
--- ido.el	18 May 2006 09:43:24 +0200	
***************
*** 4475,4480 ****
--- 4475,4482 ----
  	     (ido-directory-too-big (and (not ido-directory-nonreadable)
  					 (ido-directory-too-big-p ido-current-directory)))
  	     (ido-work-directory-index -1)
+ 	     (ido-show-dot-for-dired (and ido-show-dot-for-dired
+ 					  (not default-filename)))
  	     (ido-work-file-index -1)
  	     (ido-find-literal nil))
  	(setq ido-exit nil)

> I guess one problem is read-file-name is overloaded for 2
> different use cases: 1. read a file name (not a directory), and
> 2. read a file name or a directory name.  Separating
> read-file-name into two functions or adding a flag indicating
> intent would help.

That's too late I guess...

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

end of thread, other threads:[~2006-05-18  7:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-18  0:14 ido-read-file-name default-filename Karl Chen
2005-08-18  8:52 ` Kim F. Storm
2006-05-17  8:31   ` Karl Chen
2006-05-17 21:04     ` Kim F. Storm
     [not found]     ` <m34pzobaz4.fsf@kfs-l.imdomain.dk>
2006-05-18  0:20       ` Karl Chen
2006-05-18  7:44         ` Kim F. Storm

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