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

From: Philipp Stephani <[email-masked]>
Date: Tue, 19 Sep 2017 08:31:29 +0000

Glenn Morris <[email-masked]> schrieb am Di., 19. Sep. 2017 um 02:41 Uhr:

>
> > 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)?
>
> Sounds good to me.
>

OK, here's a patch.
From 8ab66b54afdc02aca90a4c51a426205ac024ff05 Mon Sep 17 00:00:00 2001
From: Philipp Stephani <[email-masked]>
Date: Tue, 19 Sep 2017 10:29:42 +0200
Subject: [PATCH] * lisp/files.el (file-name-base): Make FILENAME argument
 mandatory.

---
 etc/NEWS      | 3 +++
 lisp/files.el | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 371cdf686c..de93ae84fa 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -43,6 +43,9 @@ When you add a new item, use the appropriate mark if you are sure it applies,
 
 * Incompatible Lisp Changes in Emacs 27.1
 
+** The FILENAME argument to 'file-name-base' is now mandatory and no
+longer defaults to 'buffer-file-name'.
+
 
 * Lisp Changes in Emacs 27.1
 
diff --git a/lisp/files.el b/lisp/files.el
index c55c8097c1..fe7cb1a8a9 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4479,8 +4479,8 @@ 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'."
+  "Return the base name of the FILENAME: no directory, no extension."
+  (declare (advertised-calling-convention (filename) "27.1"))
   (file-name-sans-extension
    (file-name-nondirectory (or filename (buffer-file-name)))))
 
-- 
2.14.1