summaryrefslogtreecommitdiff
path: root/lisp/files.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2013-08-23 13:34:09 -0400
committerGlenn Morris <rgm@gnu.org>2013-08-23 13:34:09 -0400
commitbb35f42f61663c47d3443a87665462f75dfd3b2c (patch)
treee559b77d3c43a2688c48e193f653dedad95c4e32 /lisp/files.el
parentcb8d2612434ccdd7524a0da9c4728720c9badab3 (diff)
downloademacs-bb35f42f61663c47d3443a87665462f75dfd3b2c.tar.gz
* lisp/files.el (create-file-buffer): Rework previous change.
Diffstat (limited to 'lisp/files.el')
-rw-r--r--lisp/files.el15
1 files changed, 7 insertions, 8 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 9adbca10369..04ea47fa6ef 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1603,17 +1603,16 @@ killed."
"Create a suitably named buffer for visiting FILENAME, and return it.
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.
+
+Emacs treats buffers whose names begin with a space as internal buffers.
+To avoid confusion when visiting a file whose name begins with a space,
+this function prepends a \"|\" to the final result if necessary."
(let ((lastname (file-name-nondirectory filename)))
(if (string= lastname "")
(setq lastname filename))
- (save-match-data
- (if (string-match "\\` +\\(.*\\)" lastname)
- (if (zerop (length (setq lastname (match-string 1 lastname))))
- (setq lastname "SPC")))) ; bug#15162
- (generate-new-buffer lastname)))
+ (generate-new-buffer (if (string-match-p "\\` " lastname)
+ (concat "|" lastname)
+ lastname))))
(defun generate-new-buffer (name)
"Create and return a buffer with a name based on NAME.