From: Philipp Stephani <p.stephani2@gmail.com>
To: Glenn Morris <rgm@gnu.org>, Mohammed Sadiq <sadiq@sadiqpk.org>
Cc: 28258@debbugs.gnu.org
Subject: bug#28258: 26.0.50; [PATCH] Let file-name-base succeed when buffer-file-name is nil
Date: Mon, 18 Sep 2017 17:12:36 +0000 [thread overview]
Message-ID: <CAArVCkSvz5G-j3DdjUBcqS4UmtugNap-VLbSppTuaVA=Nt9Tsg@mail.gmail.com> (raw)
In-Reply-To: <q9tw0qs3x4.fsf@fencepost.gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1746 bytes --]
Glenn Morris <rgm@gnu.org> schrieb am Di., 29. Aug. 2017 um 19:03 Uhr:
> Mohammed Sadiq wrote:
>
> >> IIUC: file-name-base currently errors when called with no applicable
> >> file name, and you want it to instead return nil? This seems rather
> >> unusual for an Emacs file-related function. I would have thought this
> >> unlikely to be applied, but maybe you could explain why you want it?
> >
> > The signature of `file-name-base' is (file-name-base &optional FILENAME).
> > That is, the FILENAME argument is optional. So I believe it shouldn't
> > be an error to not give the optional argument. And so calling the
> function
> > in a buffer with no file associated shouldn't be an error. I'm not sure
> > if my assertion is right.
>
> Thanks for explaining. I don't think I agree, but then the fact that the
> argument is optional and defaults to buffer-file-name also seems
> atypical to me (eg I don't think any other file-name- functions behaves
> like that). Let's wait and see if anyone else feels strongly one way or
> the other.
>
>
>
>
Changing from raising an error to returning nil is a breaking change:
callers currently can rely on the return value being never nil, and can
rely on errors being raised. Changing this would break these assumptions.
Even ignoring that, I think raising an error is the right thing to do:
unless given a filename, the function can't fulfil its promise, and raising
an error is the most appropriate reaction to this. (There are already way
too many Elisp functions that silently ignore errorneous situations.)
I do agree that the calling convention of `file-name-base' is odd. How
about making the argument mandatory (initially only by changing the
advertised calling convention and the docstring)?
[-- Attachment #2: Type: text/html, Size: 2175 bytes --]
next prev parent reply other threads:[~2017-09-18 17:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-28 2:22 bug#28258: 26.0.50; [PATCH] Let file-name-base succeed when buffer-file-name is nil Mohammed Sadiq
2017-08-29 15:54 ` Glenn Morris
2017-08-29 16:10 ` Mohammed Sadiq
2017-08-29 17:02 ` Glenn Morris
2017-09-18 17:12 ` Philipp Stephani [this message]
2017-09-19 0:41 ` Glenn Morris
2017-09-19 8:31 ` Philipp Stephani
2017-09-19 8:46 ` Philipp Stephani
2017-09-24 8:07 ` Philipp Stephani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAArVCkSvz5G-j3DdjUBcqS4UmtugNap-VLbSppTuaVA=Nt9Tsg@mail.gmail.com' \
--to=p.stephani2@gmail.com \
--cc=28258@debbugs.gnu.org \
--cc=rgm@gnu.org \
--cc=sadiq@sadiqpk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).