From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mohammed Sadiq Newsgroups: gmane.emacs.bugs Subject: bug#28258: 26.0.50; [PATCH] Let file-name-base succeed when buffer-file-name is nil Date: Mon, 28 Aug 2017 07:52:22 +0530 Message-ID: <87k21o8m8x.fsf@rose> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1503887056 923 195.159.176.226 (28 Aug 2017 02:24:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 28 Aug 2017 02:24:16 +0000 (UTC) To: 28258@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 28 04:24:05 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 1dm9ie-000846-FU for geb-bug-gnu-emacs@m.gmane.org; Mon, 28 Aug 2017 04:24:05 +0200 Original-Received: from localhost ([::1]:36576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dm9il-0006le-8D for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Aug 2017 22:24:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dm9if-0006lY-GI for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2017 22:24:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dm9ic-0007HP-AZ for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2017 22:24:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:49807) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dm9ic-0007HF-79 for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2017 22:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dm9ic-0002Af-20 for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2017 22:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mohammed Sadiq Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Aug 2017 02:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 28258 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15038869928286 (code B ref -1); Mon, 28 Aug 2017 02:24:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 28 Aug 2017 02:23:12 +0000 Original-Received: from localhost ([127.0.0.1]:58488 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dm9hn-00029a-UY for submit@debbugs.gnu.org; Sun, 27 Aug 2017 22:23:12 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:54708) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dm9hm-00029O-Kd for submit@debbugs.gnu.org; Sun, 27 Aug 2017 22:23:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dm9hg-0006VG-F2 for submit@debbugs.gnu.org; Sun, 27 Aug 2017 22:23:05 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:41967) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dm9hg-0006Uv-Am for submit@debbugs.gnu.org; Sun, 27 Aug 2017 22:23:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dm9he-0006i8-Ra for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2017 22:23:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dm9hb-0006Nu-LI for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2017 22:23:02 -0400 Original-Received: from us2-ob3-3.mailhostbox.com ([208.91.199.218]:49177) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dm9hb-0006J9-Be for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2017 22:22:59 -0400 Original-Received: from rose (unknown [117.249.176.225]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: sadiq@sadiqpk.org) by us2.outbound.mailhostbox.com (Postfix) with ESMTPSA id 7A99CCA9C2 for ; Mon, 28 Aug 2017 02:22:42 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sadiqpk.org; s=20160628; t=1503886963; bh=vnOzE56j5FEOfUrAE4UXNyGPo/sQXW2cFd4IQXXqPKg=; h=From:To:Subject:Date; b=dLybiYWp9hsmqUkYTROWCKJ4Beq0s7rdfhQ4nBnpw6dGwanmgJLAEb5Y9I+h28RDh uvkVlC6uMdWitXx547fUz8esbfdCLjm0TOZjGuMkhLj1+iV+PT0IKTo1aSAeFy3LPu WQY0GDHLcjMVndo9t/q125pFejwC9jrCuEAb7Zmc= X-CMAE-Score: 0 X-CMAE-Analysis: v=2.2 cv=AbTBJzfG c=1 sm=1 tr=0 a=a4xM6SKlOPztAz5wXzXJJw==:117 a=a4xM6SKlOPztAz5wXzXJJw==:17 a=Nx9P28zXeZGLW8zPJyEA:9 a=FkaavPx6D78fk1eNWGUA:9 a=CkxXAERhc60I61HGDTkA:9 a=S0EmJ8sqXQ4rp835:21 a=U5kSAaI0ZLpVI0xp:21 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:136286 Archived-At: --=-=-= Content-Type: text/plain Let file-name-base succeed when buffer-file-name is nil. Hi. This is my first patch to GNU Emacs. Please let me know if it is sensible or not. Thanks --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Let-file-name-base-succeed-when-buffer-file-name-is-.patch Content-Description: Let file-name-base succeed when buffer-file-name is nil >From efb4f12c9083ad3930eaf5da8929d4e6b33609eb Mon Sep 17 00:00:00 2001 From: "Mohammed Sadik P. K" Date: Mon, 28 Aug 2017 07:34:25 +0530 Subject: [PATCH] Let file-name-base succeed when buffer-file-name is nil FILENAME is an optional argument for file-name-base. So it shouldn't fail when no filename is associated with current buffer. * lisp/files.el (file-name-base): Don't fail when buffer-file-name is nil. --- lisp/files.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index 872fc46e87..d75d402545 100644 --- 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))))) (defcustom make-backup-file-name-function #'make-backup-file-name--default-function -- 2.11.0 --=-=-= Content-Type: text/plain In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2017-08-27 built on rose Repository revision: 853ed4533bbddf16c50ad12ed1db70fa252715fb Windowing system distributor 'The X.Org Foundation', version 11.0.11902000 System Description: Debian GNU/Linux 9.1 (stretch) Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Making completion list... delete-backward-char: Text is read-only Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 LIBSYSTEMD Important settings: value of $LC_MONETARY: en_GB.UTF-8 value of $LC_NUMERIC: en_GB.UTF-8 value of $LC_TIME: en_GB.UTF-8 value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message subr-x puny seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib dired dired-loaddefs format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils elec-pair time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 95499 5650) (symbols 48 20292 1) (miscs 40 43 93) (strings 32 28804 1235) (string-bytes 1 763186) (vectors 16 14660) (vector-slots 8 492593 5734) (floats 8 49 67) (intervals 56 217 0) (buffers 992 12)) --=-=-=--