Mercurial > emacs
changeset 105930:45b3f4e55e6e
(read-file-name): Support a list of default values
in `default-filename'. Use the first file name where only one
element is required. Doc fix.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Tue, 10 Nov 2009 00:54:45 +0000 |
parents | 1b5554f1d1c8 |
children | a5db20cb0a5a |
files | lisp/ChangeLog lisp/minibuffer.el |
diffstat | 2 files changed, 20 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Tue Nov 10 00:07:41 2009 +0000 +++ b/lisp/ChangeLog Tue Nov 10 00:54:45 2009 +0000 @@ -1,3 +1,9 @@ +2009-11-10 Juri Linkov <juri@jurta.org> + + * minibuffer.el (read-file-name): Support a list of default values + in `default-filename'. Use the first file name where only one + element is required. Doc fix. + 2009-11-09 Michael Albinus <michael.albinus@gmx.de> * net/dbus.el (dbus-unregister-object): Release service, if no
--- a/lisp/minibuffer.el Tue Nov 10 00:07:41 2009 +0000 +++ b/lisp/minibuffer.el Tue Nov 10 00:54:45 2009 +0000 @@ -1265,7 +1265,8 @@ Default name to DEFAULT-FILENAME if user exits the minibuffer with the same non-empty string that was inserted by this function. (If DEFAULT-FILENAME is omitted, the visited file name is used, - except that if INITIAL is specified, that combined with DIR is used.) + except that if INITIAL is specified, that combined with DIR is used. + If DEFAULT-FILENAME is a list of file names, the first file name is used.) If the user exits with an empty minibuffer, this function returns an empty string. (This can only happen if the user erased the pre-inserted contents or if `insert-default-directory' is nil.) @@ -1308,7 +1309,10 @@ (setq dir (abbreviate-file-name dir)) ;; Likewise for default-filename. (if default-filename - (setq default-filename (abbreviate-file-name default-filename))) + (setq default-filename + (if (consp default-filename) + (mapcar 'abbreviate-file-name default-filename) + (abbreviate-file-name default-filename)))) (let ((insdef (cond ((and insert-default-directory (stringp dir)) (if initial @@ -1357,9 +1361,12 @@ (not (zerop (length file)))) (setq default-filename file) (setq dir (file-name-directory dir))) - (if default-filename - (setq default-filename - (expand-file-name default-filename dir))) + (when default-filename + (setq default-filename + (expand-file-name (if (consp default-filename) + (car default-filename) + default-filename) + dir))) (setq add-to-history t) (x-file-dialog prompt dir default-filename dialog-mustmatch @@ -1371,6 +1378,8 @@ ;; it has to mean that the user typed RET with the minibuffer empty. ;; In that case, we really want to return "" ;; so that commands such as set-visited-file-name can distinguish. + (when (consp default-filename) + (setq default-filename (car default-filename))) (when (eq val default-filename) ;; In this case, completing-read has not added an element ;; to the history. Maybe we should.