all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philipp Stephani <p.stephani2@gmail.com>
To: Glenn Morris <rgm@gnu.org>
Cc: 28258@debbugs.gnu.org, Mohammed Sadiq <sadiq@sadiqpk.org>
Subject: bug#28258: 26.0.50; [PATCH] Let file-name-base succeed when buffer-file-name is nil
Date: Tue, 19 Sep 2017 08:46:30 +0000	[thread overview]
Message-ID: <CAArVCkR9p=YxN_OiiD_Dg7rNbLgUiKnQ0WbHnoXyv7Jr4gE8sQ@mail.gmail.com> (raw)
In-Reply-To: <CAArVCkS0MYLt+CRhauDz_iTDUmgs0gSgyvtWa06j-3Bo6XKfSQ@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 488 bytes --]

Philipp Stephani <p.stephani2@gmail.com> schrieb am Di., 19. Sep. 2017 um
10:31 Uhr:

> Glenn Morris <rgm@gnu.org> 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.
>

New version of the patch, with all callers and the manual fixed.

[-- Attachment #1.2: Type: text/html, Size: 1106 bytes --]

[-- Attachment #2: 0001-Make-FILENAME-argument-of-file-name-base-mandatory.txt --]
[-- Type: text/plain, Size: 5297 bytes --]

From 89f01da2afd8b41f9af3937a8a1903c57916d19e Mon Sep 17 00:00:00 2001
From: Philipp Stephani <phst@google.com>
Date: Tue, 19 Sep 2017 10:29:42 +0200
Subject: [PATCH] Make FILENAME argument of 'file-name-base' mandatory

* lisp/files.el (file-name-base): Make FILENAME argument mandatory.

* lisp/autoinsert.el (auto-insert-alist):
* lisp/progmodes/cperl-mode.el (cperl-electric-pod):
* lisp/progmodes/idlwave.el (idlwave-parse-definition):
* lisp/textmodes/reftex-ref.el (reftex-replace-prefix-escapes): Fix
all callers.
---
 doc/lispref/files.texi       |  4 +---
 etc/NEWS                     |  3 +++
 lisp/autoinsert.el           | 10 +++++-----
 lisp/files.el                |  4 ++--
 lisp/progmodes/cperl-mode.el |  2 +-
 lisp/progmodes/idlwave.el    |  2 +-
 lisp/textmodes/reftex-ref.el |  2 +-
 7 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index 6be998f0b2..e4a4bfe598 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -2106,7 +2106,7 @@ File Name Components
 not an extension.
 @end defun
 
-@defun file-name-base &optional filename
+@defun file-name-base filename
 This function is the composition of @code{file-name-sans-extension}
 and @code{file-name-nondirectory}.  For example,
 
@@ -2114,8 +2114,6 @@ File Name Components
 (file-name-base "/my/home/foo.c")
     @result{} "foo"
 @end example
-
-The @var{filename} argument defaults to @code{buffer-file-name}.
 @end defun
 
 @node Relative File Names
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,
 \f
 * 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'.
+
 \f
 * Lisp Changes in Emacs 27.1
 
diff --git a/lisp/autoinsert.el b/lisp/autoinsert.el
index 2820c8a9af..a43e068a4d 100644
--- a/lisp/autoinsert.el
+++ b/lisp/autoinsert.el
@@ -141,14 +141,14 @@ auto-insert-alist
      "
 .\\\" You may distribute this file under the terms of the GNU Free
 .\\\" Documentation License.
-.TH " (file-name-base)
+.TH " (file-name-base (buffer-file-name))
      " " (file-name-extension (buffer-file-name))
      " " (format-time-string "%Y-%m-%d ")
      "\n.SH NAME\n"
-     (file-name-base)
+     (file-name-base (buffer-file-name))
      " \\- " str
      "\n.SH SYNOPSIS
-.B " (file-name-base)
+.B " (file-name-base (buffer-file-name))
      "\n"
      _
      "
@@ -211,7 +211,7 @@ auto-insert-alist
 
 
 \(provide '"
-       (file-name-base)
+       (file-name-base (buffer-file-name))
        ")
 \;;; " (file-name-nondirectory (buffer-file-name)) " ends here\n")
     (("\\.texi\\(nfo\\)?\\'" . "Texinfo file skeleton")
@@ -219,7 +219,7 @@ auto-insert-alist
      "\\input texinfo   @c -*-texinfo-*-
 @c %**start of header
 @setfilename "
-     (file-name-base) ".info\n"
+     (file-name-base (buffer-file-name)) ".info\n"
       "@settitle " str "
 @c %**end of header
 @copying\n"
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)))))
 
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index abd77bd973..e956637572 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -2314,7 +2314,7 @@ cperl-electric-pod
 						 nil t)))) ; Only one
 		     (progn
 		       (forward-word-strictly 1)
-		       (setq name (file-name-base)
+		       (setq name (file-name-base (buffer-file-name))
 			     p (point))
 		       (insert " NAME\n\n" name
 			       " - \n\n=head1 SYNOPSIS\n\n\n\n"
diff --git a/lisp/progmodes/idlwave.el b/lisp/progmodes/idlwave.el
index 9231e11890..92a42b1cb9 100644
--- a/lisp/progmodes/idlwave.el
+++ b/lisp/progmodes/idlwave.el
@@ -5240,7 +5240,7 @@ idlwave-parse-definition
 	  class
 	  (cond ((not (boundp 'idlwave-scanning-lib))
 		 (list  'buffer (buffer-file-name)))
-;		((string= (downcase (file-name-base))
+;		((string= (downcase (file-name-base (buffer-file-name))
 ;			  (downcase name))
 ;		 (list 'lib))
 ;		(t (cons 'lib (file-name-nondirectory (buffer-file-name))))
diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el
index c2c5ca3de0..f9f23201b4 100644
--- a/lisp/textmodes/reftex-ref.el
+++ b/lisp/textmodes/reftex-ref.el
@@ -314,7 +314,7 @@ reftex-replace-prefix-escapes
               (save-match-data
                 (cond
                  ((equal letter "f")
-                  (file-name-base))
+                  (file-name-base (buffer-file-name)))
                  ((equal letter "F")
                   (let ((masterdir (file-name-directory (reftex-TeX-master-file)))
                         (file (file-name-sans-extension (buffer-file-name))))
-- 
2.14.1


  reply	other threads:[~2017-09-19  8:46 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
2017-09-19  0:41         ` Glenn Morris
2017-09-19  8:31           ` Philipp Stephani
2017-09-19  8:46             ` Philipp Stephani [this message]
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAArVCkR9p=YxN_OiiD_Dg7rNbLgUiKnQ0WbHnoXyv7Jr4gE8sQ@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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.