summaryrefslogtreecommitdiff
path: root/lisp/files.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2013-08-23 13:08:19 -0400
committerGlenn Morris <rgm@gnu.org>2013-08-23 13:08:19 -0400
commit61611d54b50a9523f696bd95c233b35556030324 (patch)
treeca0422ccc06afcfad302b94852f6cc93df86d41d /lisp/files.el
parente3a6636351364fe32463d3a8196e5fc564c66422 (diff)
downloademacs-61611d54b50a9523f696bd95c233b35556030324.tar.gz
emacs-61611d54b50a9523f696bd95c233b35556030324.tar.bz2
emacs-61611d54b50a9523f696bd95c233b35556030324.zip
* files.el (create-file-buffer): Handle a file whose basename is all spaces.
Fixes: debbugs:15162
Diffstat (limited to 'lisp/files.el')
-rw-r--r--lisp/files.el8
1 files changed, 6 insertions, 2 deletions
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.