diff options
| author | Glenn Morris | 2013-08-23 13:34:09 -0400 |
|---|---|---|
| committer | Glenn Morris | 2013-08-23 13:34:09 -0400 |
| commit | bb35f42f61663c47d3443a87665462f75dfd3b2c (patch) | |
| tree | e559b77d3c43a2688c48e193f653dedad95c4e32 | |
| parent | cb8d2612434ccdd7524a0da9c4728720c9badab3 (diff) | |
| download | emacs-bb35f42f61663c47d3443a87665462f75dfd3b2c.tar.gz emacs-bb35f42f61663c47d3443a87665462f75dfd3b2c.zip | |
* lisp/files.el (create-file-buffer): Rework previous change.
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/files.el | 15 |
2 files changed, 9 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f633f5f5de7..6d3b09c3449 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -2,8 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | * files.el (interpreter-mode-alist): Use tcl-mode for expect scripts. | 3 | * files.el (interpreter-mode-alist): Use tcl-mode for expect scripts. |
| 4 | 4 | ||
| 5 | * files.el (create-file-buffer): Handle the vital case of a file | 5 | * files.el (create-file-buffer): If the result would begin with |
| 6 | whose basename is all spaces. (Bug#15162) | 6 | spaces, prepend a "|" instead of removing them. (Bug#15162) |
| 7 | 7 | ||
| 8 | 2013-08-23 Stefan Monnier <monnier@iro.umontreal.ca> | 8 | 2013-08-23 Stefan Monnier <monnier@iro.umontreal.ca> |
| 9 | 9 | ||
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." | |||
| 1603 | "Create a suitably named buffer for visiting FILENAME, and return it. | 1603 | "Create a suitably named buffer for visiting FILENAME, and return it. |
| 1604 | FILENAME (sans directory) is used unchanged if that name is free; | 1604 | FILENAME (sans directory) is used unchanged if that name is free; |
| 1605 | otherwise a string <2> or <3> or ... is appended to get an unused name. | 1605 | otherwise a string <2> or <3> or ... is appended to get an unused name. |
| 1606 | Spaces at the start of FILENAME (sans directory) are removed." | 1606 | |
| 1607 | ;; ^ Because buffers whose name begins with a space are treated as | 1607 | Emacs treats buffers whose names begin with a space as internal buffers. |
| 1608 | ;; internal Emacs buffers. | 1608 | To avoid confusion when visiting a file whose name begins with a space, |
| 1609 | this function prepends a \"|\" to the final result if necessary." | ||
| 1609 | (let ((lastname (file-name-nondirectory filename))) | 1610 | (let ((lastname (file-name-nondirectory filename))) |
| 1610 | (if (string= lastname "") | 1611 | (if (string= lastname "") |
| 1611 | (setq lastname filename)) | 1612 | (setq lastname filename)) |
| 1612 | (save-match-data | 1613 | (generate-new-buffer (if (string-match-p "\\` " lastname) |
| 1613 | (if (string-match "\\` +\\(.*\\)" lastname) | 1614 | (concat "|" lastname) |
| 1614 | (if (zerop (length (setq lastname (match-string 1 lastname)))) | 1615 | lastname)))) |
| 1615 | (setq lastname "SPC")))) ; bug#15162 | ||
| 1616 | (generate-new-buffer lastname))) | ||
| 1617 | 1616 | ||
| 1618 | (defun generate-new-buffer (name) | 1617 | (defun generate-new-buffer (name) |
| 1619 | "Create and return a buffer with a name based on NAME. | 1618 | "Create and return a buffer with a name based on NAME. |