Subject: Re: bug#28258: 26.0.50; [PATCH] Let file-name-base succeed when buffer-file-name is nil

From: Glenn Morris <[email-masked]>
Date: Tue, 29 Aug 2017 11:54:55 -0400

Mohammed Sadiq wrote:

> * lisp/files.el (file-name-base): Don't fail when buffer-file-name
> is nil.
[...]
> --- a/lisp/files.el
> +++ b/lisp/files.el
> @@ -4467,8 +4467,9 @@ file-name-extension
>  (defun file-name-base (&optional filename)
>    "Return the base name of the FILENAME: no directory, no extension.
>  FILENAME defaults to `buffer-file-name'."
> -  (file-name-sans-extension
> -   (file-name-nondirectory (or filename (buffer-file-name)))))
> +  (let ((filename (or filename (buffer-file-name))))
> +    (and filename
> +        (file-name-sans-extension (file-name-nondirectory filename)))))

Hi, and thanks for the patch.
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?