From 032c33996ae4358d9a7d99cb852146bb08e06352 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 10 Nov 2009 00:54:45 +0000 Subject: [PATCH] (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. --- lisp/ChangeLog | 6 ++++++ lisp/minibuffer.el | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index fa68d679c8b..158e493fde0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2009-11-10 Juri Linkov + + * 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 * net/dbus.el (dbus-unregister-object): Release service, if no diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 59732fd4b8a..823b56e7125 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1265,7 +1265,8 @@ Value is not expanded---you must call `expand-file-name' yourself. 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 @@ and `read-file-name-function'." (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 @@ and `read-file-name-function'." (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 @@ and `read-file-name-function'." ;; 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. -- 2.39.5