]> git.eshelyaron.com Git - emacs.git/commitdiff
(read-file-name): Support a list of default values
authorJuri Linkov <juri@jurta.org>
Tue, 10 Nov 2009 00:54:45 +0000 (00:54 +0000)
committerJuri Linkov <juri@jurta.org>
Tue, 10 Nov 2009 00:54:45 +0000 (00:54 +0000)
in `default-filename'.  Use the first file name where only one
element is required.  Doc fix.

lisp/ChangeLog
lisp/minibuffer.el

index fa68d679c8b75d47ee2538fe7a854251328a1bbc..158e493fde0229d0ee17d4ea6685fdad7af7dafb 100644 (file)
@@ -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
index 59732fd4b8af839abe5b9de308dbda3967ca0d75..823b56e7125942e1db7799b509af300dd05b9a92 100644 (file)
@@ -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.