From 61611d54b50a9523f696bd95c233b35556030324 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Fri, 23 Aug 2013 13:08:19 -0400 Subject: [PATCH] * files.el (create-file-buffer): Handle a file whose basename is all spaces. Fixes: debbugs:15162 --- lisp/ChangeLog | 5 +++++ lisp/files.el | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index df9fce72dd9..9fd3e687405 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-08-23 Glenn Morris + + * files.el (create-file-buffer): Handle the vital case of a file + whose basename is all spaces. (Bug#15162) + 2013-08-23 Stefan Monnier * textmodes/fill.el (fill-match-adaptive-prefix): Don't throw away diff --git a/lisp/files.el b/lisp/files.el index efd89605b1b..71dc968f160 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1604,12 +1604,16 @@ killed." FILENAME (sans directory) is used unchanged if that name is free; otherwise a string <2> or <3> or ... is appended to get an unused name. Spaces at the start of FILENAME (sans directory) are removed." + ;; ^ Because buffers whose name begins with a space are treated as + ;; internal Emacs buffers. (let ((lastname (file-name-nondirectory filename))) (if (string= lastname "") (setq lastname filename)) (save-match-data - (string-match "^ *\\(.*\\)" lastname) - (generate-new-buffer (match-string 1 lastname))))) + (if (string-match "\\` +\\(.*\\)" lastname) + (if (zerop (length (setq lastname (match-string 1 lastname)))) + (setq lastname "SPC")))) ; bug#15162 + (generate-new-buffer lastname))) (defun generate-new-buffer (name) "Create and return a buffer with a name based on NAME. -- 2.11.4.GIT