GNU bug report logs - #8534
24.0.50; Documentation bug in ns-read-file-name

Previous Next

Packages: ns, emacs;

Reported by: Harald Hanche-Olsen <hanche <at> math.ntnu.no>

Date: Fri, 22 Apr 2011 10:51:02 UTC

Severity: minor

Found in version 24.0.50

Done: Chong Yidong <cyd <at> stupidchicken.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8534 in the body.
You can then email your comments to 8534 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8534; Package emacs. (Fri, 22 Apr 2011 10:51:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Harald Hanche-Olsen <hanche <at> math.ntnu.no>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 22 Apr 2011 10:51:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Harald Hanche-Olsen <hanche <at> math.ntnu.no>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.50; Documentation bug in ns-read-file-name
Date: Fri, 22 Apr 2011 12:50:36 +0200 (CEST)
The doc string for ns-read-file-name (defined in src/nsfns.m) says

Optional arg ISLOAD, if non-nil, means read a file name for saving.

However the exact opposite is true, as the name of the variable also
indicates.

On a side note, when the function is called (with ISLOAD = nil) and
you select an existing file, the usual warning pane about overwriting
an existing file pops up briefly before the dialog vanishes and the
function returns the chosen filename. It is not clear to me if this is
the intended behaviour, but I find it confusing. It would have been
better, I think, to let the save dialog do its usual thing, and then
for the caller of ns-read-file-name to assume that the user has
authorized the overwriting of a pre-existing file with the same name.

In GNU Emacs 24.0.50.1 (x86_64-apple-darwin10.7.0, NS apple-appkit-1038.35)
 of 2011-04-21 on mack
Windowing system distributor `Apple', version 10.3.1038
configured using `configure  '--with-ns''

- Harald




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8534; Package emacs,ns. (Sun, 24 Apr 2011 17:52:01 GMT) Full text and rfc822 format available.

Message #8 received at 8534 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Harald Hanche-Olsen <hanche <at> math.ntnu.no>
Cc: 8534 <at> debbugs.gnu.org
Subject: Re: bug#8534: 24.0.50; Documentation bug in ns-read-file-name
Date: Sun, 24 Apr 2011 13:51:21 -0400
Harald Hanche-Olsen <hanche <at> math.ntnu.no> writes:

> The doc string for ns-read-file-name (defined in src/nsfns.m) says
>
> Optional arg ISLOAD, if non-nil, means read a file name for saving.
>
> However the exact opposite is true, as the name of the variable also
> indicates.

I can patch up the docstring if you explain to me what the opposite of
"read a file name for saving" is, and what is the difference between the
two kinds of file dialogs (I don't use OSX).




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8534; Package emacs,ns. (Sun, 24 Apr 2011 18:29:02 GMT) Full text and rfc822 format available.

Message #11 received at 8534 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Chong Yidong <cyd <at> stupidchicken.com>
Cc: hanche <at> math.ntnu.no, 8534 <at> debbugs.gnu.org
Subject: Re: bug#8534: 24.0.50; Documentation bug in ns-read-file-name
Date: Sun, 24 Apr 2011 21:28:42 +0300
> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00
> 	autolearn=unavailable version=3.3.1
> Resent-From: Chong Yidong <cyd <at> stupidchicken.com>
> Original-Sender: debbugs-submit-bounces <at> debbugs.gnu.org
> Resent-To: owner <at> debbugs.gnu.org
> Resent-CC: bug-gnu-emacs <at> gnu.org
> Resent-Sender: help-debbugs <at> gnu.org
> From: Chong Yidong <cyd <at> stupidchicken.com>
> Date: Sun, 24 Apr 2011 13:51:21 -0400
> Cc: 8534 <at> debbugs.gnu.org
> 
> Harald Hanche-Olsen <hanche <at> math.ntnu.no> writes:
> 
> > The doc string for ns-read-file-name (defined in src/nsfns.m) says
> >
> > Optional arg ISLOAD, if non-nil, means read a file name for saving.
> >
> > However the exact opposite is true, as the name of the variable also
> > indicates.
> 
> I can patch up the docstring if you explain to me what the opposite of
> "read a file name for saving" is, and what is the difference between the
> two kinds of file dialogs (I don't use OSX).

I guess it means that "non-nil" is backwards, as this part of
ns-read-file-name shows:

  panel = NILP (isLoad) ?
    (id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel];

This seems to say that if isLoad is non-nil, we pop up a File Open
dialog, while when it's nil, we pop up a File Save dialog.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8534; Package emacs,ns. (Sun, 24 Apr 2011 20:36:02 GMT) Full text and rfc822 format available.

Message #14 received at 8534 <at> debbugs.gnu.org (full text, mbox):

From: Harald Hanche-Olsen <hanche <at> math.ntnu.no>
To: eliz <at> gnu.org
Cc: cyd <at> stupidchicken.com, 8534 <at> debbugs.gnu.org
Subject: Re: bug#8534: 24.0.50; Documentation bug in ns-read-file-name
Date: Sun, 24 Apr 2011 22:34:49 +0200 (CEST)
[Eli Zaretskii <eliz <at> gnu.org> (2011-04-24 18:28:42 UTC)]

> > I can patch up the docstring if you explain to me what the opposite of
> > "read a file name for saving" is, and what is the difference between the
> > two kinds of file dialogs (I don't use OSX).
> 
> I guess it means that "non-nil" is backwards, as this part of
> ns-read-file-name shows:
> 
>   panel = NILP (isLoad) ?
>     (id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel];
> 
> This seems to say that if isLoad is non-nil, we pop up a File Open
> dialog, while when it's nil, we pop up a File Save dialog.

That is exactly correct. And the former dialog only lets you select an
existing file, while the latter lets you navigate to a folder and type
a filename.

- Harald




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8534; Package emacs,ns. (Sun, 24 Apr 2011 22:53:02 GMT) Full text and rfc822 format available.

Message #17 received at 8534 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Harald Hanche-Olsen <hanche <at> math.ntnu.no>
Cc: eliz <at> gnu.org, 8534 <at> debbugs.gnu.org
Subject: Re: bug#8534: 24.0.50; Documentation bug in ns-read-file-name
Date: Sun, 24 Apr 2011 18:52:39 -0400
Harald Hanche-Olsen <hanche <at> math.ntnu.no> writes:

>>   panel = NILP (isLoad) ?
>>     (id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel];
>>
>> This seems to say that if isLoad is non-nil, we pop up a File Open
>> dialog, while when it's nil, we pop up a File Save dialog.
>
> That is exactly correct. And the former dialog only lets you select an
> existing file, while the latter lets you navigate to a folder and type
> a filename.

OK.  Does the following patch make sense?  It renames `isLoad' to
`mustmatch', to be like x-file-dialog.

(It sure would have been nice if ns-read-file-name had been named
x-file-dialog, and given the same arguments.  If anyone with access to
Mac OS wants to clean it up properly.)

=== modified file 'src/nsfns.m'
*** src/nsfns.m	2011-04-07 03:34:05 +0000
--- src/nsfns.m	2011-04-24 22:46:40 +0000
***************
*** 1416,1424 ****
  DEFUN ("ns-read-file-name", Fns_read_file_name, Sns_read_file_name, 1, 4, 0,
         doc: /* Use a graphical panel to read a file name, using prompt PROMPT.
  Optional arg DIR, if non-nil, supplies a default directory.
! Optional arg ISLOAD, if non-nil, means read a file name for saving.
  Optional arg INIT, if non-nil, provides a default file name to use.  */)
!      (Lisp_Object prompt, Lisp_Object dir, Lisp_Object isLoad, Lisp_Object init)
  {
    static id fileDelegate = nil;
    int ret;
--- 1416,1425 ----
  DEFUN ("ns-read-file-name", Fns_read_file_name, Sns_read_file_name, 1, 4, 0,
         doc: /* Use a graphical panel to read a file name, using prompt PROMPT.
  Optional arg DIR, if non-nil, supplies a default directory.
! Optional arg MUSTMATCH, if non-nil, means the returned file or
! directory must exist.
  Optional arg INIT, if non-nil, provides a default file name to use.  */)
!      (Lisp_Object prompt, Lisp_Object dir, Lisp_Object mustmatch, Lisp_Object init)
  {
    static id fileDelegate = nil;
    int ret;
***************
*** 1443,1449 ****
    if ([dirS characterAtIndex: 0] == '~')
      dirS = [dirS stringByExpandingTildeInPath];
  
!   panel = NILP (isLoad) ?
      (id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel];
  
    [panel setTitle: promptS];
--- 1444,1450 ----
    if ([dirS characterAtIndex: 0] == '~')
      dirS = [dirS stringByExpandingTildeInPath];
  
!   panel = NILP (mustmatch) ?
      (id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel];
  
    [panel setTitle: promptS];
***************
*** 1457,1463 ****
  
    panelOK = 0;
    BLOCK_INPUT;
!   if (NILP (isLoad))
      {
        ret = [panel runModalForDirectory: dirS file: initS];
      }
--- 1458,1464 ----
  
    panelOK = 0;
    BLOCK_INPUT;
!   if (NILP (mustmatch))
      {
        ret = [panel runModalForDirectory: dirS file: initS];
      }





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8534; Package emacs,ns. (Mon, 25 Apr 2011 09:01:02 GMT) Full text and rfc822 format available.

Message #20 received at 8534 <at> debbugs.gnu.org (full text, mbox):

From: Harald Hanche-Olsen <hanche <at> math.ntnu.no>
To: cyd <at> stupidchicken.com
Cc: eliz <at> gnu.org, 8534 <at> debbugs.gnu.org
Subject: Re: bug#8534: 24.0.50; Documentation bug in ns-read-file-name
Date: Mon, 25 Apr 2011 11:00:16 +0200 (CEST)
[Chong Yidong <cyd <at> stupidchicken.com> (2011-04-24 22:52:39 UTC)]

> OK.  Does the following patch make sense?  It renames `isLoad' to
> `mustmatch', to be like x-file-dialog.

Yes, I think that is good.

> (It sure would have been nice if ns-read-file-name had been named
> x-file-dialog, and given the same arguments.  If anyone with access to
> Mac OS wants to clean it up properly.)

I have access, but lack the Objective-C-fu (for the time being, anyhow).

- Harald




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8534; Package emacs,ns. (Mon, 25 Apr 2011 13:02:02 GMT) Full text and rfc822 format available.

Message #23 received at 8534 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Chong Yidong <cyd <at> stupidchicken.com>
Cc: Harald Hanche-Olsen <hanche <at> math.ntnu.no>, 8534 <at> debbugs.gnu.org
Subject: Re: bug#8534: 24.0.50; Documentation bug in ns-read-file-name
Date: Mon, 25 Apr 2011 10:00:54 -0300
> (It sure would have been nice if ns-read-file-name had been named
> x-file-dialog, and given the same arguments.  If anyone with access to

No, it should be ns-file-dialog.
I know we have a lot of "x-" used as "generic GUI functions", but that's
a bad habit which we should aim to fix.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8534; Package emacs,ns. (Tue, 26 Apr 2011 18:32:02 GMT) Full text and rfc822 format available.

Message #26 received at 8534 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Harald Hanche-Olsen <hanche <at> math.ntnu.no>
Cc: eliz <at> gnu.org, 8534 <at> debbugs.gnu.org
Subject: Re: bug#8534: 24.0.50; Documentation bug in ns-read-file-name
Date: Tue, 26 Apr 2011 14:31:31 -0400
Harald Hanche-Olsen <hanche <at> math.ntnu.no> writes:

> [Chong Yidong <cyd <at> stupidchicken.com> (2011-04-24 22:52:39 UTC)]
>
>> OK.  Does the following patch make sense?  It renames `isLoad' to
>> `mustmatch', to be like x-file-dialog.
>
> Yes, I think that is good.

OK, committed to the emacs-23 branch.




bug closed, send any further explanations to 8534 <at> debbugs.gnu.org and Harald Hanche-Olsen <hanche <at> math.ntnu.no> Request was from Chong Yidong <cyd <at> stupidchicken.com> to control <at> debbugs.gnu.org. (Tue, 26 Apr 2011 18:32:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 25 May 2011 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 88 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.