emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r113984: * lisp/files.el (create-file-buffer): Rewor


From: Glenn Morris
Subject: [Emacs-diffs] trunk r113984: * lisp/files.el (create-file-buffer): Rework previous change.
Date: Fri, 23 Aug 2013 17:34:15 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113984
revision-id: address@hidden
parent: address@hidden
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Fri 2013-08-23 13:34:09 -0400
message:
  * lisp/files.el (create-file-buffer): Rework previous change.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/files.el                  files.el-20091113204419-o5vbwnq5f7feedwu-265
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-08-23 17:09:09 +0000
+++ b/lisp/ChangeLog    2013-08-23 17:34:09 +0000
@@ -2,8 +2,8 @@
 
        * files.el (interpreter-mode-alist): Use tcl-mode for expect scripts.
 
-       * files.el (create-file-buffer): Handle the vital case of a file
-       whose basename is all spaces.  (Bug#15162)
+       * files.el (create-file-buffer): If the result would begin with
+       spaces, prepend a "|" instead of removing them.  (Bug#15162)
 
 2013-08-23  Stefan Monnier  <address@hidden>
 

=== modified file 'lisp/files.el'
--- a/lisp/files.el     2013-08-23 17:09:09 +0000
+++ b/lisp/files.el     2013-08-23 17:34:09 +0000
@@ -1603,17 +1603,16 @@
   "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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]