diff options
| author | Noam Postavsky | 2016-10-27 22:17:11 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2016-12-11 21:36:08 -0500 |
| commit | a92a027d58cb4df5bb6c7e3c546a72183a192f45 (patch) | |
| tree | 6de406718d319b0a8d514548852a48c7583bcd96 /test | |
| parent | 2783e0e3899cf92910e97dc8bfda3e47b3df1478 (diff) | |
| download | emacs-a92a027d58cb4df5bb6c7e3c546a72183a192f45.tar.gz emacs-a92a027d58cb4df5bb6c7e3c546a72183a192f45.zip | |
Quote filenames containing '~' in prompts
When in a directory named '~', the default value given by
`read-file-name' should be quoted by prepending '/:', in order to
prevent it from being interpreted as referring to the $HOME
directory (Bug#16984).
* lisp/minibuffer.el (minibuffer-maybe-quote-filename): New function.
(completion--sifn-requote, read-file-name-default): Use it instead of
`minibuffer--double-dollars'.
* test/lisp/files-tests.el (files-test-read-file-in-~): Test it.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/files-tests.el | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 80d5e5befbc..f4ccd5c2044 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el | |||
| @@ -220,5 +220,28 @@ form.") | |||
| 220 | (should-not yes-or-no-p-prompts) | 220 | (should-not yes-or-no-p-prompts) |
| 221 | (should (equal kill-emacs-args '(nil))))) | 221 | (should (equal kill-emacs-args '(nil))))) |
| 222 | 222 | ||
| 223 | (ert-deftest files-test-read-file-in-~ () | ||
| 224 | "Test file prompting in directory named '~'. | ||
| 225 | If we are in a directory named '~', the default value should not | ||
| 226 | be $HOME." | ||
| 227 | (cl-letf (((symbol-function 'completing-read) | ||
| 228 | (lambda (_prompt _coll &optional _pred _req init _hist def _) | ||
| 229 | (or def init))) | ||
| 230 | (dir (make-temp-file "read-file-name-test" t))) | ||
| 231 | (unwind-protect | ||
| 232 | (let ((subdir (expand-file-name "./~/"))) | ||
| 233 | (make-directory subdir t) | ||
| 234 | (with-temp-buffer | ||
| 235 | (setq default-directory subdir) | ||
| 236 | (should-not (equal | ||
| 237 | (expand-file-name (read-file-name "File: ")) | ||
| 238 | (expand-file-name "~/"))) | ||
| 239 | ;; Don't overquote either! | ||
| 240 | (setq default-directory (concat "/:" subdir)) | ||
| 241 | (should-not (equal | ||
| 242 | (expand-file-name (read-file-name "File: ")) | ||
| 243 | (concat "/:/:" subdir))))) | ||
| 244 | (delete-directory dir 'recursive)))) | ||
| 245 | |||
| 223 | (provide 'files-tests) | 246 | (provide 'files-tests) |
| 224 | ;;; files-tests.el ends here | 247 | ;;; files-tests.el ends here |