emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

read-file-name (was: FFAP)


From: Juri Linkov
Subject: read-file-name (was: FFAP)
Date: Mon, 09 Nov 2009 12:14:29 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu)

All completion functions support a list of default values
except `read-file-name'.  The following patch fills this hole.

Index: lisp/minibuffer.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/minibuffer.el,v
retrieving revision 1.93
diff -c -r1.93 minibuffer.el
*** lisp/minibuffer.el  2 Nov 2009 02:06:40 -0000       1.93
--- lisp/minibuffer.el  9 Nov 2009 10:12:38 -0000
***************
*** 1265,1271 ****
  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.)
  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.)
--- 1265,1272 ----
  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.
!   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,1314 ****
    (setq dir (abbreviate-file-name dir))
    ;; Likewise for default-filename.
    (if default-filename
!       (setq default-filename (abbreviate-file-name default-filename)))
    (let ((insdef (cond
                   ((and insert-default-directory (stringp dir))
                    (if initial
--- 1309,1317 ----
    (setq dir (abbreviate-file-name dir))
    ;; Likewise for default-filename.
    (if default-filename
!       (if (consp default-filename)
!         (setq default-filename (mapcar 'abbreviate-file-name 
default-filename))
!       (setq default-filename (abbreviate-file-name default-filename))))
    (let ((insdef (cond
                   ((and insert-default-directory (stringp dir))
                    (if initial
***************
*** 1357,1365 ****
                               (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)))
                      (setq add-to-history t)
                      (x-file-dialog prompt dir default-filename
                                   dialog-mustmatch
--- 1360,1371 ----
                               (not (zerop (length file))))
                        (setq default-filename file)
                        (setq dir (file-name-directory 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,1376 ****
--- 1377,1384 ----
            ;; 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.

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]