aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2009-10-21 20:03:57 +0000
committerStefan Monnier2009-10-21 20:03:57 +0000
commit528c56e2d1f1ca98b5195ab9a45c44a46a3ff32a (patch)
tree3cdb8887f415421fc14dc908b49f47326b463d38
parent3132a7ea15ddf8c479a9596fb1736f5c62d5e8d9 (diff)
downloademacs-528c56e2d1f1ca98b5195ab9a45c44a46a3ff32a.tar.gz
emacs-528c56e2d1f1ca98b5195ab9a45c44a46a3ff32a.zip
* minibuffer.el (completion-table-with-terminator): Properly implement
boundaries, in case `terminator' appears in the suffix. (completion--embedded-envvar-table): Don't return boundaries if there's no valid completion. Simplify. (completion-file-name-table): New completion table extracted from completion--file-name-table. (completion--file-name-table): Use it. (read-file-name-predicate): Declare obsolete. (read-file-name): Use the pred arg i.s.o read-file-name-predicate. * vc-bzr.el (vc-bzr-revision-completion-table): Use the new completion-file-name-table, and use the `pred' argument. * files.el (locate-file-completion-table): Use the `pred' arg rather than read-file-name-predicate. (abbreviate-file-name): Use \` rather than ^ for BOS.
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/ChangeLog17
-rw-r--r--lisp/files.el17
-rw-r--r--lisp/minibuffer.el204
-rw-r--r--lisp/vc-bzr.el10
5 files changed, 167 insertions, 86 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 4d8778b10b0..ff31476fb57 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -256,6 +256,11 @@ Command*'.
256 256
257* Lisp changes in Emacs 23.2 257* Lisp changes in Emacs 23.2
258 258
259** read-file-name-predicate is obsolete. It was used to pass the predicate
260to read-file-name-internal because read-file-name-internal abused its `pred'
261argument to pass the current directory, but this hack is not needed
262any more.
263
259** completion-base-size is obsoleted by completion-base-position. 264** completion-base-size is obsoleted by completion-base-position.
260This change causes a few backward incompatibilities, mostly with 265This change causes a few backward incompatibilities, mostly with
261choose-completion-string-functions where the `mini-p' argument has 266choose-completion-string-functions where the `mini-p' argument has
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4834d05c570..ce126ee434f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,20 @@
12009-10-21 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * minibuffer.el (completion-table-with-terminator): Properly implement
4 boundaries, in case `terminator' appears in the suffix.
5 (completion--embedded-envvar-table): Don't return boundaries if
6 there's no valid completion. Simplify.
7 (completion-file-name-table): New completion table extracted from
8 completion--file-name-table.
9 (completion--file-name-table): Use it.
10 (read-file-name-predicate): Declare obsolete.
11 (read-file-name): Use the pred arg i.s.o read-file-name-predicate.
12 * vc-bzr.el (vc-bzr-revision-completion-table): Use the new
13 completion-file-name-table, and use the `pred' argument.
14 * files.el (locate-file-completion-table): Use the `pred' arg rather
15 than read-file-name-predicate.
16 (abbreviate-file-name): Use \` rather than ^ for BOS.
17
12009-10-21 Dan Nicolaescu <dann@ics.uci.edu> 182009-10-21 Dan Nicolaescu <dann@ics.uci.edu>
2 19
3 * vc.el (vc-deduce-fileset): Undo previous change, do not tell 20 * vc.el (vc-deduce-fileset): Undo previous change, do not tell
diff --git a/lisp/files.el b/lisp/files.el
index 9bb4d757dfe..ce9791fdaae 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -728,8 +728,10 @@ one or more of those symbols."
728 "Do completion for file names passed to `locate-file'." 728 "Do completion for file names passed to `locate-file'."
729 (cond 729 (cond
730 ((file-name-absolute-p string) 730 ((file-name-absolute-p string)
731 (let ((read-file-name-predicate pred)) 731 ;; FIXME: maybe we should use completion-file-name-table instead,
732 (read-file-name-internal string nil action))) 732 ;; tho at least for `load', the arg is passed through
733 ;; substitute-in-file-name for historical reasons.
734 (read-file-name-internal string pred action))
733 ((eq (car-safe action) 'boundaries) 735 ((eq (car-safe action) 'boundaries)
734 (let ((suffix (cdr action))) 736 (let ((suffix (cdr action)))
735 (list* 'boundaries 737 (list* 'boundaries
@@ -1603,7 +1605,7 @@ home directory is a root directory) and removes automounter prefixes
1603 (or abbreviated-home-dir 1605 (or abbreviated-home-dir
1604 (setq abbreviated-home-dir 1606 (setq abbreviated-home-dir
1605 (let ((abbreviated-home-dir "$foo")) 1607 (let ((abbreviated-home-dir "$foo"))
1606 (concat "^" (abbreviate-file-name (expand-file-name "~")) 1608 (concat "\\`" (abbreviate-file-name (expand-file-name "~"))
1607 "\\(/\\|\\'\\)")))) 1609 "\\(/\\|\\'\\)"))))
1608 1610
1609 ;; If FILENAME starts with the abbreviated homedir, 1611 ;; If FILENAME starts with the abbreviated homedir,
@@ -1614,9 +1616,7 @@ home directory is a root directory) and removes automounter prefixes
1614 (= (aref filename 0) ?/))) 1616 (= (aref filename 0) ?/)))
1615 ;; MS-DOS root directories can come with a drive letter; 1617 ;; MS-DOS root directories can come with a drive letter;
1616 ;; Novell Netware allows drive letters beyond `Z:'. 1618 ;; Novell Netware allows drive letters beyond `Z:'.
1617 (not (and (or (eq system-type 'ms-dos) 1619 (not (and (memq system-type '(ms-dos windows-nt cygwin))
1618 (eq system-type 'cygwin)
1619 (eq system-type 'windows-nt))
1620 (save-match-data 1620 (save-match-data
1621 (string-match "^[a-zA-`]:/$" filename))))) 1621 (string-match "^[a-zA-`]:/$" filename)))))
1622 (setq filename 1622 (setq filename
@@ -1643,8 +1643,7 @@ If there is no such live buffer, return nil."
1643 (when (and buf (funcall predicate buf)) buf)) 1643 (when (and buf (funcall predicate buf)) buf))
1644 (let ((list (buffer-list)) found) 1644 (let ((list (buffer-list)) found)
1645 (while (and (not found) list) 1645 (while (and (not found) list)
1646 (save-excursion 1646 (with-current-buffer (car list)
1647 (set-buffer (car list))
1648 (if (and buffer-file-name 1647 (if (and buffer-file-name
1649 (string= buffer-file-truename truename) 1648 (string= buffer-file-truename truename)
1650 (funcall predicate (current-buffer))) 1649 (funcall predicate (current-buffer)))
@@ -4834,7 +4833,7 @@ non-nil, it is called instead of rereading visited file contents."
4834 file-name))) 4833 file-name)))
4835 (run-hooks 'before-revert-hook) 4834 (run-hooks 'before-revert-hook)
4836 ;; If file was backed up but has changed since, 4835 ;; If file was backed up but has changed since,
4837 ;; we shd make another backup. 4836 ;; we should make another backup.
4838 (and (not auto-save-p) 4837 (and (not auto-save-p)
4839 (not (verify-visited-file-modtime (current-buffer))) 4838 (not (verify-visited-file-modtime (current-buffer)))
4840 (setq buffer-backed-up nil)) 4839 (setq buffer-backed-up nil))
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index c8bb26002af..2024a5bd7d1 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -37,26 +37,39 @@
37;; it should only lists the ones that `try-completion' would consider. 37;; it should only lists the ones that `try-completion' would consider.
38;; E.g. it should honor completion-ignored-extensions. 38;; E.g. it should honor completion-ignored-extensions.
39;; - choose-completion can't automatically figure out the boundaries 39;; - choose-completion can't automatically figure out the boundaries
40;; corresponding to the displayed completions. `base-size' gives the left 40;; corresponding to the displayed completions because we only
41;; boundary, but not the righthand one. So we need to add 41;; provide the start info but not the end info in
42;; completion-extra-size. 42;; completion-base-position.
43;; - choose-completion doesn't know how to quote the text it inserts.
44;; E.g. it fails to double the dollars in file-name completion, or
45;; to backslash-escape spaces and other chars in comint completion.
46;; - C-x C-f ~/*/sr ? should not list "~/./src".
47;; - minibuffer-force-complete completes ~/src/emacs/t<!>/lisp/minibuffer.el
48;; to ~/src/emacs/trunk/ and throws away lisp/minibuffer.el.
43 49
44;;; Todo: 50;;; Todo:
45 51
46;; - make partial-complete-mode obsolete: 52;; - make partial-complete-mode obsolete:
47;; - (?) <foo.h> style completion for file names. 53;; - (?) <foo.h> style completion for file names.
48 54;; This can't be done identically just by tweaking completion,
49;; - case-sensitivity is currently confuses two issues: 55;; because partial-completion-mode's behavior is to expand <string.h>
56;; to /usr/include/string.h only when exiting the minibuffer, at which
57;; point the completion code is actually not involved normally.
58;; Partial-completion-mode does it via a find-file-not-found-function.
59;; - special code for C-x C-f <> to visit the file ref'd at point
60;; via (require 'foo) or #include "foo". ffap seems like a better
61;; place for this feature (supplemented with major-mode-provided
62;; functions to find the file ref'd at point).
63
64;; - case-sensitivity currently confuses two issues:
50;; - whether or not a particular completion table should be case-sensitive 65;; - whether or not a particular completion table should be case-sensitive
51;; (i.e. whether strings that different only by case are semantically 66;; (i.e. whether strings that differ only by case are semantically
52;; equivalent) 67;; equivalent)
53;; - whether the user wants completion to pay attention to case. 68;; - whether the user wants completion to pay attention to case.
54;; e.g. we may want to make it possible for the user to say "first try 69;; e.g. we may want to make it possible for the user to say "first try
55;; completion case-sensitively, and if that fails, try to ignore case". 70;; completion case-sensitively, and if that fails, try to ignore case".
56 71
57;; - make lisp-complete-symbol and sym-comp use it.
58;; - add support for ** to pcm. 72;; - add support for ** to pcm.
59;; - Make read-file-name-predicate obsolete.
60;; - Add vc-file-name-completion-table to read-file-name-internal. 73;; - Add vc-file-name-completion-table to read-file-name-internal.
61;; - A feature like completing-help.el. 74;; - A feature like completing-help.el.
62;; - make lisp/complete.el obsolete. 75;; - make lisp/complete.el obsolete.
@@ -182,12 +195,29 @@ You should give VAR a non-nil `risky-local-variable' property."
182 (t comp))))) 195 (t comp)))))
183 196
184(defun completion-table-with-terminator (terminator table string pred action) 197(defun completion-table-with-terminator (terminator table string pred action)
198 "Construct a completion table like TABLE but with an extra TERMINATOR.
199This is meant to be called in a curried way by first passing TERMINATOR
200and TABLE only (via `apply-partially').
201TABLE is a completion table, and TERMINATOR is a string appended to TABLE's
202completion if it is complete. TERMINATOR is also used to determine the
203completion suffix's boundary."
185 (cond 204 (cond
205 ((eq (car-safe action) 'boundaries)
206 (let* ((suffix (cdr action))
207 (bounds (completion-boundaries string table pred suffix))
208 (max (string-match (regexp-quote terminator) suffix)))
209 (list* 'boundaries (car bounds)
210 (min (cdr bounds) (or max (length suffix))))))
186 ((eq action nil) 211 ((eq action nil)
187 (let ((comp (try-completion string table pred))) 212 (let ((comp (try-completion string table pred)))
188 (if (eq comp t) 213 (if (eq comp t)
189 (concat string terminator) 214 (concat string terminator)
190 (if (and (stringp comp) 215 (if (and (stringp comp)
216 ;; FIXME: Try to avoid this second call, especially since
217 ;; it may be very inefficient (because `comp' made us
218 ;; jump to a new boundary, so we complete in that
219 ;; boundary with an empty start string).
220 ;; completion-boundaries might help.
191 (eq (try-completion comp table pred) t)) 221 (eq (try-completion comp table pred) t))
192 (concat comp terminator) 222 (concat comp terminator)
193 comp)))) 223 comp))))
@@ -232,6 +262,8 @@ Note: TABLE needs to be a proper completion table which obeys predicates."
232 262
233(defun completion-table-in-turn (&rest tables) 263(defun completion-table-in-turn (&rest tables)
234 "Create a completion table that tries each table in TABLES in turn." 264 "Create a completion table that tries each table in TABLES in turn."
265 ;; FIXME: the boundaries may come from TABLE1 even when the completion list
266 ;; is returned by TABLE2 (because TABLE1 returned an empty list).
235 (lexical-let ((tables tables)) 267 (lexical-let ((tables tables))
236 (lambda (string pred action) 268 (lambda (string pred action)
237 (completion--some (lambda (table) 269 (completion--some (lambda (table)
@@ -533,6 +565,8 @@ scroll the window of possible completions."
533Repeated uses step through the possible completions." 565Repeated uses step through the possible completions."
534 (interactive) 566 (interactive)
535 ;; FIXME: Need to deal with the extra-size issue here as well. 567 ;; FIXME: Need to deal with the extra-size issue here as well.
568 ;; FIXME: ~/src/emacs/t<M-TAB>/lisp/minibuffer.el completes to
569 ;; ~/src/emacs/trunk/ and throws away lisp/minibuffer.el.
536 (let* ((start (field-beginning)) 570 (let* ((start (field-beginning))
537 (end (field-end)) 571 (end (field-end))
538 (all (completion-all-sorted-completions))) 572 (all (completion-all-sorted-completions)))
@@ -1026,19 +1060,26 @@ variables.")
1026 "$\\([[:alnum:]_]*\\|{\\([^}]*\\)\\)\\'")) 1060 "$\\([[:alnum:]_]*\\|{\\([^}]*\\)\\)\\'"))
1027 1061
1028(defun completion--embedded-envvar-table (string pred action) 1062(defun completion--embedded-envvar-table (string pred action)
1029 (if (eq (car-safe action) 'boundaries) 1063 (when (string-match completion--embedded-envvar-re string)
1030 ;; Compute the boundaries of the subfield to which this 1064 (let* ((beg (or (match-beginning 2) (match-beginning 1)))
1031 ;; completion applies. 1065 (table (completion--make-envvar-table))
1032 (let ((suffix (cdr action))) 1066 (prefix (substring string 0 beg)))
1033 (if (string-match completion--embedded-envvar-re string) 1067 (if (eq (car-safe action) 'boundaries)
1034 (list* 'boundaries 1068 ;; Only return boundaries if there's something to complete,
1035 (or (match-beginning 2) (match-beginning 1)) 1069 ;; since otherwise when we're used in
1036 (when (string-match "[^[:alnum:]_]" suffix) 1070 ;; completion-table-in-turn, we could return boundaries and
1037 (match-beginning 0))))) 1071 ;; let some subsequent table return a list of completions.
1038 (when (string-match completion--embedded-envvar-re string) 1072 ;; FIXME: Maybe it should rather be fixed in
1039 (let* ((beg (or (match-beginning 2) (match-beginning 1))) 1073 ;; completion-table-in-turn instead, but it's difficult to
1040 (table (completion--make-envvar-table)) 1074 ;; do it efficiently there.
1041 (prefix (substring string 0 beg))) 1075 (when (try-completion prefix table pred)
1076 ;; Compute the boundaries of the subfield to which this
1077 ;; completion applies.
1078 (let ((suffix (cdr action)))
1079 (list* 'boundaries
1080 (or (match-beginning 2) (match-beginning 1))
1081 (when (string-match "[^[:alnum:]_]" suffix)
1082 (match-beginning 0)))))
1042 (if (eq (aref string (1- beg)) ?{) 1083 (if (eq (aref string (1- beg)) ?{)
1043 (setq table (apply-partially 'completion-table-with-terminator 1084 (setq table (apply-partially 'completion-table-with-terminator
1044 "}" table))) 1085 "}" table)))
@@ -1048,75 +1089,102 @@ variables.")
1048 (completion-table-with-context 1089 (completion-table-with-context
1049 prefix table (substring string beg) pred action)))))) 1090 prefix table (substring string beg) pred action))))))
1050 1091
1051(defun completion--file-name-table (string pred action) 1092(defun completion-file-name-table (string pred action)
1052 "Internal subroutine for `read-file-name'. Do not call this." 1093 "Completion table for file names."
1094 (ignore-errors
1053 (cond 1095 (cond
1054 ((and (zerop (length string)) (eq 'lambda action))
1055 nil) ; FIXME: why?
1056 ((eq (car-safe action) 'boundaries) 1096 ((eq (car-safe action) 'boundaries)
1057 ;; FIXME: Actually, this is not always right in the presence of
1058 ;; envvars, but there's not much we can do, I think.
1059 (let ((start (length (file-name-directory string))) 1097 (let ((start (length (file-name-directory string)))
1060 (end (string-match-p "/" (cdr action)))) 1098 (end (string-match-p "/" (cdr action))))
1061 (list* 'boundaries start end))) 1099 (list* 'boundaries start end)))
1062 1100
1101 ((eq action 'lambda)
1102 (if (zerop (length string))
1103 nil ;Not sure why it's here, but it probably doesn't harm.
1104 (funcall (or pred 'file-exists-p) string)))
1105
1063 (t 1106 (t
1064 (let* ((dir (if (stringp pred) 1107 (let* ((name (file-name-nondirectory string))
1065 ;; It used to be that `pred' was abused to pass `dir' 1108 (specdir (file-name-directory string))
1066 ;; as an argument. 1109 (realdir (or specdir default-directory)))
1067 (prog1 (expand-file-name pred) (setq pred nil))
1068 default-directory))
1069 (str (condition-case nil
1070 (substitute-in-file-name string)
1071 (error string)))
1072 (name (file-name-nondirectory str))
1073 (specdir (file-name-directory str))
1074 (realdir (if specdir (expand-file-name specdir dir)
1075 (file-name-as-directory dir))))
1076 1110
1077 (cond 1111 (cond
1078 ((null action) 1112 ((null action)
1079 (let ((comp (file-name-completion name realdir 1113 (let ((comp (file-name-completion name realdir pred)))
1080 read-file-name-predicate))) 1114 (if (stringp comp)
1081 (cond 1115 (concat specdir comp)
1082 ((stringp comp) 1116 comp)))
1083 ;; Requote the $s before returning the completion.
1084 (minibuffer--double-dollars (concat specdir comp)))
1085 (comp
1086 ;; Requote the $s before checking for changes.
1087 (setq str (minibuffer--double-dollars str))
1088 (if (string-equal string str)
1089 comp
1090 ;; If there's no real completion, but substitute-in-file-name
1091 ;; changed the string, then return the new string.
1092 str)))))
1093 1117
1094 ((eq action t) 1118 ((eq action t)
1095 (let ((all (file-name-all-completions name realdir))) 1119 (let ((all (file-name-all-completions name realdir)))
1096 1120
1097 ;; Check the predicate, if necessary. 1121 ;; Check the predicate, if necessary.
1098 (unless (memq read-file-name-predicate '(nil file-exists-p)) 1122 (unless (memq pred '(nil file-exists-p))
1099 (let ((comp ()) 1123 (let ((comp ())
1100 (pred 1124 (pred
1101 (if (eq read-file-name-predicate 'file-directory-p) 1125 (if (eq pred 'file-directory-p)
1102 ;; Brute-force speed up for directory checking: 1126 ;; Brute-force speed up for directory checking:
1103 ;; Discard strings which don't end in a slash. 1127 ;; Discard strings which don't end in a slash.
1104 (lambda (s) 1128 (lambda (s)
1105 (let ((len (length s))) 1129 (let ((len (length s)))
1106 (and (> len 0) (eq (aref s (1- len)) ?/)))) 1130 (and (> len 0) (eq (aref s (1- len)) ?/))))
1107 ;; Must do it the hard (and slow) way. 1131 ;; Must do it the hard (and slow) way.
1108 read-file-name-predicate))) 1132 pred)))
1109 (let ((default-directory realdir)) 1133 (let ((default-directory (expand-file-name realdir)))
1110 (dolist (tem all) 1134 (dolist (tem all)
1111 (if (funcall pred tem) (push tem comp)))) 1135 (if (funcall pred tem) (push tem comp))))
1112 (setq all (nreverse comp)))) 1136 (setq all (nreverse comp))))
1113 1137
1114 all)) 1138 all))))))))
1139
1140(defvar read-file-name-predicate nil
1141 "Current predicate used by `read-file-name-internal'.")
1142(make-obsolete-variable 'read-file-name-predicate
1143 "use the regular PRED argument" "23.2")
1144
1145(defun completion--file-name-table (string pred action)
1146 "Internal subroutine for `read-file-name'. Do not call this.
1147This is a completion table for file names, like `completion-file-name-table'
1148except that it passes the file name through `substitute-in-file-name'."
1149 (cond
1150 ((eq (car-safe action) 'boundaries)
1151 ;; For the boundaries, we can't really delegate to
1152 ;; completion-file-name-table and then fix them up, because it
1153 ;; would require us to track the relationship between `str' and
1154 ;; `string', which is difficult. And in any case, if
1155 ;; substitute-in-file-name turns "fo-$TO-ba" into "fo-o/b-ba", there's
1156 ;; no way for us to return proper boundaries info, because the
1157 ;; boundary is not (yet) in `string'.
1158 (let ((start (length (file-name-directory string)))
1159 (end (string-match-p "/" (cdr action))))
1160 (list* 'boundaries start end)))
1115 1161
1116 (t 1162 (t
1117 ;; Only other case actually used is ACTION = lambda. 1163 (let* ((default-directory
1118 (let ((default-directory dir)) 1164 (if (stringp pred)
1119 (funcall (or read-file-name-predicate 'file-exists-p) str)))))))) 1165 ;; It used to be that `pred' was abused to pass `dir'
1166 ;; as an argument.
1167 (prog1 (file-name-as-directory (expand-file-name pred))
1168 (setq pred nil))
1169 default-directory))
1170 (str (condition-case nil
1171 (substitute-in-file-name string)
1172 (error string)))
1173 (comp (completion-file-name-table
1174 str (or pred read-file-name-predicate) action)))
1175
1176 (cond
1177 ((stringp comp)
1178 ;; Requote the $s before returning the completion.
1179 (minibuffer--double-dollars comp))
1180 ((and (null action) comp
1181 ;; Requote the $s before checking for changes.
1182 (setq str (minibuffer--double-dollars str))
1183 (not (string-equal string str)))
1184 ;; If there's no real completion, but substitute-in-file-name
1185 ;; changed the string, then return the new string.
1186 str)
1187 (t comp))))))
1120 1188
1121(defalias 'read-file-name-internal 1189(defalias 'read-file-name-internal
1122 (completion-table-in-turn 'completion--embedded-envvar-table 1190 (completion-table-in-turn 'completion--embedded-envvar-table
@@ -1126,9 +1194,6 @@ variables.")
1126(defvar read-file-name-function nil 1194(defvar read-file-name-function nil
1127 "If this is non-nil, `read-file-name' does its work by calling this function.") 1195 "If this is non-nil, `read-file-name' does its work by calling this function.")
1128 1196
1129(defvar read-file-name-predicate nil
1130 "Current predicate used by `read-file-name-internal'.")
1131
1132(defcustom read-file-name-completion-ignore-case 1197(defcustom read-file-name-completion-ignore-case
1133 (if (memq system-type '(ms-dos windows-nt darwin cygwin)) 1198 (if (memq system-type '(ms-dos windows-nt darwin cygwin))
1134 t nil) 1199 t nil)
@@ -1227,7 +1292,7 @@ and `read-file-name-function'."
1227 prompt dir default-filename mustmatch initial predicate) 1292 prompt dir default-filename mustmatch initial predicate)
1228 (let ((completion-ignore-case read-file-name-completion-ignore-case) 1293 (let ((completion-ignore-case read-file-name-completion-ignore-case)
1229 (minibuffer-completing-file-name t) 1294 (minibuffer-completing-file-name t)
1230 (read-file-name-predicate (or predicate 'file-exists-p)) 1295 (pred (or predicate 'file-exists-p))
1231 (add-to-history nil)) 1296 (add-to-history nil))
1232 1297
1233 (let* ((val 1298 (let* ((val
@@ -1242,8 +1307,8 @@ and `read-file-name-function'."
1242 (minibuffer-with-setup-hook 1307 (minibuffer-with-setup-hook
1243 (lambda () (setq default-directory dir)) 1308 (lambda () (setq default-directory dir))
1244 (completing-read prompt 'read-file-name-internal 1309 (completing-read prompt 'read-file-name-internal
1245 nil mustmatch insdef 'file-name-history 1310 pred mustmatch insdef
1246 default-filename))) 1311 'file-name-history default-filename)))
1247 ;; If DEFAULT-FILENAME not supplied and DIR contains 1312 ;; If DEFAULT-FILENAME not supplied and DIR contains
1248 ;; a file name, split it. 1313 ;; a file name, split it.
1249 (let ((file (file-name-nondirectory dir)) 1314 (let ((file (file-name-nondirectory dir))
@@ -1253,9 +1318,8 @@ and `read-file-name-function'."
1253 ;; it is impossible to create new files using 1318 ;; it is impossible to create new files using
1254 ;; dialogs with the default settings. 1319 ;; dialogs with the default settings.
1255 (dialog-mustmatch 1320 (dialog-mustmatch
1256 (and (not (eq mustmatch 'confirm)) 1321 (not (memq mustmatch
1257 (not (eq mustmatch 'confirm-after-completion)) 1322 '(nil confirm confirm-after-completion)))))
1258 mustmatch)))
1259 (when (and (not default-filename) 1323 (when (and (not default-filename)
1260 (not (zerop (length file)))) 1324 (not (zerop (length file))))
1261 (setq default-filename file) 1325 (setq default-filename file)
diff --git a/lisp/vc-bzr.el b/lisp/vc-bzr.el
index da9c97f2c17..b5118538cff 100644
--- a/lisp/vc-bzr.el
+++ b/lisp/vc-bzr.el
@@ -736,14 +736,10 @@ stream. Standard error output is discarded."
736 ((string-match "\\`\\(ancestor\\|branch\\|\\(revno:\\)?[-0-9]+:\\):" 736 ((string-match "\\`\\(ancestor\\|branch\\|\\(revno:\\)?[-0-9]+:\\):"
737 string) 737 string)
738 (completion-table-with-context (substring string 0 (match-end 0)) 738 (completion-table-with-context (substring string 0 (match-end 0))
739 ;; FIXME: only allow directories. 739 'completion-file-name-table
740 ;; FIXME: don't allow envvars.
741 'read-file-name-internal
742 (substring string (match-end 0)) 740 (substring string (match-end 0))
743 ;; Dropping `pred'. Maybe we should 741 ;; Dropping `pred' for no good reason.
744 ;; just stash it in 742 'file-directory-p
745 ;; `read-file-name-predicate'?
746 nil
747 action)) 743 action))
748 ((string-match "\\`\\(before\\):" string) 744 ((string-match "\\`\\(before\\):" string)
749 (completion-table-with-context (substring string 0 (match-end 0)) 745 (completion-table-with-context (substring string 0 (match-end 0))