unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* read-directory-name
@ 2005-05-07  1:20 Luc Teirlinck
  2005-05-07  1:48 ` read-directory-name Luc Teirlinck
  2005-05-08 22:45 ` read-directory-name Richard Stallman
  0 siblings, 2 replies; 8+ messages in thread
From: Luc Teirlinck @ 2005-05-07  1:20 UTC (permalink / raw)


The docstring and Elisp documentation of `read-directory-name' conflict.

Docstring:

  Default name to default-dirname if user exits with the same
  non-empty string that was inserted by this function.
  (If default-dirname is omitted, dir combined with initial is used,
  or just dir if initial is nil.)

Elisp manual:

   If both DEFAULT and INITIAL are `nil',
   this function uses the current buffer's default directory as
   substitute default, ignoring DIRECTORY.

>From the following ielm run it appears that the Elisp documentation is
still correct, even though the code and docstring have changed (on
April 23) since I checked all of this quite a while ago:

ELISP> default-directory
"~/"
ELISP> (read-directory-name "Directory: " "/etc/")
"~/"
ELISP> 

To get the second line, I just presses RET with /etc/ in the
minibuffer.

Sincerely,

Luc.

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

* Re: read-directory-name
  2005-05-07  1:20 read-directory-name Luc Teirlinck
@ 2005-05-07  1:48 ` Luc Teirlinck
  2005-05-07  1:52   ` read-directory-name Luc Teirlinck
  2005-05-07  2:34   ` read-directory-name Luc Teirlinck
  2005-05-08 22:45 ` read-directory-name Richard Stallman
  1 sibling, 2 replies; 8+ messages in thread
From: Luc Teirlinck @ 2005-05-07  1:48 UTC (permalink / raw)
  Cc: emacs-devel

>From my prior message:

   >From the following ielm run it appears that the Elisp documentation is
   still correct, even though the code and docstring have changed (on
   April 23) since I checked all of this quite a while ago:

   ELISP> default-directory
   "~/"
   ELISP> (read-directory-name "Directory: " "/etc/")
   "~/"
   ELISP> 

   To get the second line, I just presses RET with /etc/ in the
   minibuffer.

Of course, here is the read-directory-name code:

  (unless dir
    (setq dir default-directory))
  (unless default-dirname
    (setq default-dirname
      (if initial (concat dir initial) default-directory)))
  (read-file-name prompt dir (or default-dirname 
				 (if initial (expand-file-name initial dir)
				   dir))
		  mustmatch initial 'file-directory-p))

If both initial and default-dirname are nil, the second unless-form
default-dirname to default-directory.  The or-form then passes
default-directory to read-file-name.  From the docstring, it would
appear that this is not intentional.

Sincerely,

Luc.

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

* Re: read-directory-name
  2005-05-07  1:48 ` read-directory-name Luc Teirlinck
@ 2005-05-07  1:52   ` Luc Teirlinck
  2005-05-07  2:34   ` read-directory-name Luc Teirlinck
  1 sibling, 0 replies; 8+ messages in thread
From: Luc Teirlinck @ 2005-05-07  1:52 UTC (permalink / raw)
  Cc: emacs-devel

>From my previous message:

   If both initial and default-dirname are nil, the second unless-form
   default-dirname to default-directory.

Of course, meant was:

the second unless-form sets default-dirname

(I accidentally enabled Overwite mode again, without noticing it.)

Sincerely,

Luc.

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

* Re: read-directory-name
  2005-05-07  1:48 ` read-directory-name Luc Teirlinck
  2005-05-07  1:52   ` read-directory-name Luc Teirlinck
@ 2005-05-07  2:34   ` Luc Teirlinck
  2005-05-07  2:47     ` read-directory-name Luc Teirlinck
  1 sibling, 1 reply; 8+ messages in thread
From: Luc Teirlinck @ 2005-05-07  2:34 UTC (permalink / raw)
  Cc: emacs-devel

Is the behavior implemented by the following patch what was really
intended by the April 23 change?  One could, in addition to the patch
below, also change the `(concat dir initial)' into
`(expand-file-name initial dir)' which is probably more portable.

Note however that the _old_ (in fact _still present_, even though
maybe accidentally so) behavior, as documented in the Elisp manual
looks like it was implemented very intentionally.

===File ~/files.el-diff=====================================
*** files.el	06 May 2005 11:08:41 -0500	1.764
--- files.el	06 May 2005 20:47:00 -0500	
***************
*** 543,553 ****
      (setq dir default-directory))
    (unless default-dirname
      (setq default-dirname
! 	  (if initial (concat dir initial) default-directory)))
!   (read-file-name prompt dir (or default-dirname 
! 				 (if initial (expand-file-name initial dir)
! 				   dir))
! 		  mustmatch initial
  		  'file-directory-p))
  
  \f
--- 543,550 ----
      (setq dir default-directory))
    (unless default-dirname
      (setq default-dirname
! 	  (if initial (concat dir initial) dir)))
!   (read-file-name prompt dir default-dirname mustmatch initial
  		  'file-directory-p))
  
  \f
============================================================

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

* Re: read-directory-name
  2005-05-07  2:34   ` read-directory-name Luc Teirlinck
@ 2005-05-07  2:47     ` Luc Teirlinck
  2005-05-07  2:56       ` read-directory-name Luc Teirlinck
  0 siblings, 1 reply; 8+ messages in thread
From: Luc Teirlinck @ 2005-05-07  2:47 UTC (permalink / raw)
  Cc: emacs-devel

>From my previous patch:

   ! 	  (if initial (concat dir initial) dir)))

Sorry, that was wrong.  It should have been:

   ! 	  (if initial (concat dir initial) dir default-directory)))

But I saw that Juri already earlier proposed that exact same
(corrected as above) patch.  Since it was not used, there must be
something I still misunderstand.  I am going to quit making guesses.

Sincerely,

Luc.

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

* Re: read-directory-name
  2005-05-07  2:47     ` read-directory-name Luc Teirlinck
@ 2005-05-07  2:56       ` Luc Teirlinck
  2005-05-09 21:32         ` read-directory-name Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Luc Teirlinck @ 2005-05-07  2:56 UTC (permalink / raw)
  Cc: emacs-devel

>From my previous reply:

   Sorry, that was wrong.  It should have been:

      ! 	  (if initial (concat dir initial) dir default-directory)))

Obviously, that was even _more_ wrong.
It should have been the following, as in Juri's original patch:

-         (if initial (concat dir initial) default-directory)))
+         (or (if initial (concat dir initial))
+             dir
+             default-directory)))


Sincerely,

Luc.

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

* Re: read-directory-name
  2005-05-07  1:20 read-directory-name Luc Teirlinck
  2005-05-07  1:48 ` read-directory-name Luc Teirlinck
@ 2005-05-08 22:45 ` Richard Stallman
  1 sibling, 0 replies; 8+ messages in thread
From: Richard Stallman @ 2005-05-08 22:45 UTC (permalink / raw)
  Cc: emacs-devel

I forgot to delete the unless-form from read-directory-name.
I will do so.  Thanks.

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

* Re: read-directory-name
  2005-05-07  2:56       ` read-directory-name Luc Teirlinck
@ 2005-05-09 21:32         ` Juri Linkov
  0 siblings, 0 replies; 8+ messages in thread
From: Juri Linkov @ 2005-05-09 21:32 UTC (permalink / raw)
  Cc: emacs-devel

>    Sorry, that was wrong.  It should have been:
>
>       ! 	  (if initial (concat dir initial) dir default-directory)))
>
> Obviously, that was even _more_ wrong.
> It should have been the following, as in Juri's original patch:
>
> -         (if initial (concat dir initial) default-directory)))
> +         (or (if initial (concat dir initial))
> +             dir
> +             default-directory)))

I haven't installed this patch, because I've found that
`read-directory-name' inherits its behavior from `read-file-name',
so changing `read-directory-name' would make it inconsistent with
`read-file-name'.

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

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

end of thread, other threads:[~2005-05-09 21:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-07  1:20 read-directory-name Luc Teirlinck
2005-05-07  1:48 ` read-directory-name Luc Teirlinck
2005-05-07  1:52   ` read-directory-name Luc Teirlinck
2005-05-07  2:34   ` read-directory-name Luc Teirlinck
2005-05-07  2:47     ` read-directory-name Luc Teirlinck
2005-05-07  2:56       ` read-directory-name Luc Teirlinck
2005-05-09 21:32         ` read-directory-name Juri Linkov
2005-05-08 22:45 ` read-directory-name 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).