Commit 032c3399 authored by Juri Linkov's avatar Juri Linkov
Browse files

(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.
parent a51203ee
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> 2009-11-09 Michael Albinus <michael.albinus@gmx.de>
* net/dbus.el (dbus-unregister-object): Release service, if no * net/dbus.el (dbus-unregister-object): Release service, if no
......
...@@ -1265,7 +1265,8 @@ Value is not expanded---you must call `expand-file-name' yourself. ...@@ -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 Default name to DEFAULT-FILENAME if user exits the minibuffer with
the same non-empty string that was inserted by this function. the same non-empty string that was inserted by this function.
(If DEFAULT-FILENAME is omitted, the visited file name is used, (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 If the user exits with an empty minibuffer, this function returns
an empty string. (This can only happen if the user erased the an empty string. (This can only happen if the user erased the
pre-inserted contents or if `insert-default-directory' is nil.) pre-inserted contents or if `insert-default-directory' is nil.)
...@@ -1308,7 +1309,10 @@ and `read-file-name-function'." ...@@ -1308,7 +1309,10 @@ and `read-file-name-function'."
(setq dir (abbreviate-file-name dir)) (setq dir (abbreviate-file-name dir))
;; Likewise for default-filename. ;; Likewise for default-filename.
(if 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 (let ((insdef (cond
((and insert-default-directory (stringp dir)) ((and insert-default-directory (stringp dir))
(if initial (if initial
...@@ -1357,9 +1361,12 @@ and `read-file-name-function'." ...@@ -1357,9 +1361,12 @@ and `read-file-name-function'."
(not (zerop (length file)))) (not (zerop (length file))))
(setq default-filename file) (setq default-filename file)
(setq dir (file-name-directory dir))) (setq dir (file-name-directory dir)))
(if default-filename (when default-filename
(setq default-filename (setq default-filename
(expand-file-name default-filename dir))) (expand-file-name (if (consp default-filename)
(car default-filename)
default-filename)
dir)))
(setq add-to-history t) (setq add-to-history t)
(x-file-dialog prompt dir default-filename (x-file-dialog prompt dir default-filename
dialog-mustmatch dialog-mustmatch
...@@ -1371,6 +1378,8 @@ and `read-file-name-function'." ...@@ -1371,6 +1378,8 @@ and `read-file-name-function'."
;; it has to mean that the user typed RET with the minibuffer empty. ;; it has to mean that the user typed RET with the minibuffer empty.
;; In that case, we really want to return "" ;; In that case, we really want to return ""
;; so that commands such as set-visited-file-name can distinguish. ;; 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) (when (eq val default-filename)
;; In this case, completing-read has not added an element ;; In this case, completing-read has not added an element
;; to the history. Maybe we should. ;; to the history. Maybe we should.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment