From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.bugs Subject: bug#28258: 26.0.50; [PATCH] Let file-name-base succeed when buffer-file-name is nil Date: Tue, 29 Aug 2017 11:54:55 -0400 Message-ID: References: <87k21o8m8x.fsf@rose> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1504022181 31762 195.159.176.226 (29 Aug 2017 15:56:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 29 Aug 2017 15:56:21 +0000 (UTC) User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) Cc: 28258@debbugs.gnu.org To: Mohammed Sadiq Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 29 17:56:12 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmirw-0007BE-Hf for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 Aug 2017 17:56:00 +0200 Original-Received: from localhost ([::1]:45637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmis3-0000ql-Cp for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 Aug 2017 11:56:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmiry-0000px-Me for bug-gnu-emacs@gnu.org; Tue, 29 Aug 2017 11:56:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmirx-0004K4-Vc for bug-gnu-emacs@gnu.org; Tue, 29 Aug 2017 11:56:02 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52200) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dmirx-0004Jr-S9 for bug-gnu-emacs@gnu.org; Tue, 29 Aug 2017 11:56:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dmirx-00018B-IQ for bug-gnu-emacs@gnu.org; Tue, 29 Aug 2017 11:56:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Aug 2017 15:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28258 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 28258-submit@debbugs.gnu.org id=B28258.15040221174298 (code B ref 28258); Tue, 29 Aug 2017 15:56:01 +0000 Original-Received: (at 28258) by debbugs.gnu.org; 29 Aug 2017 15:55:17 +0000 Original-Received: from localhost ([127.0.0.1]:60881 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmirF-00017G-2z for submit@debbugs.gnu.org; Tue, 29 Aug 2017 11:55:17 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:36301) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmirC-00016y-D2 for 28258@debbugs.gnu.org; Tue, 29 Aug 2017 11:55:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmir6-0003X3-6K for 28258@debbugs.gnu.org; Tue, 29 Aug 2017 11:55:09 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:42880) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmiqv-0003Ne-6A; Tue, 29 Aug 2017 11:54:57 -0400 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1dmiqt-0004Nw-D5; Tue, 29 Aug 2017 11:54:55 -0400 X-Spook: Drug war ARPA Legion of Doom 22nd SAS Zachawi ASPIC Mena X-Ran: Y`@|Em`H~U6=Ri.()yO=^K3O;[C0l_$O|9=mB^)90H[w-3VO]{y/Q4UQW[.78I")94cHCL X-Hue: brightblue X-Attribution: GM In-Reply-To: <87k21o8m8x.fsf@rose> (Mohammed Sadiq's message of "Mon, 28 Aug 2017 07:52:22 +0530") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:136325 Archived-At: 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?