unexpected values in minibuffer-completion-predicate.
2008-04-23 Stefan Monnier <monnier@iro.umontreal.ca>
2008-04-23 Stefan Monnier <monnier@iro.umontreal.ca>
+ * complete.el (PC-do-completion): Be more robust in the presence of
+ unexpected values in minibuffer-completion-predicate.
+
* minibuffer.el (read-file-name): Don't let-bind default-directory.
Only abbreviate default-filename if it's a file.
* minibuffer.el (read-file-name): Don't let-bind default-directory.
Only abbreviate default-filename if it's a file.
(and filename
(let ((dir (file-name-directory str))
(file (file-name-nondirectory str))
(and filename
(let ((dir (file-name-directory str))
(file (file-name-nondirectory str))
- ;; The base dir for file-completion is passed in `predicate'.
- (default-directory (expand-file-name pred)))
+ ;; The base dir for file-completion was passed in `predicate'.
+ (default-directory (if (stringp pred) (expand-file-name pred)
+ default-directory)))
(while (and (stringp dir) (not (file-directory-p dir)))
(setq dir (directory-file-name dir))
(setq file (concat (replace-regexp-in-string
(while (and (stringp dir) (not (file-directory-p dir)))
(setq dir (directory-file-name dir))
(setq file (concat (replace-regexp-in-string
(and filename
(string-match "\\*.*/" str)
(let ((pat str)
(and filename
(string-match "\\*.*/" str)
(let ((pat str)
- ;; The base dir for file-completion is passed in `predicate'.
- (default-directory (expand-file-name pred))
+ ;; The base dir for file-completion was passed in `predicate'.
+ (default-directory (if (stringp pred) (expand-file-name pred)
+ default-directory))
files)
(setq p (1+ (string-match "/[^/]*\\'" pat)))
(while (setq p (string-match PC-delim-regex pat p))
files)
(setq p (1+ (string-match "/[^/]*\\'" pat)))
(while (setq p (string-match PC-delim-regex pat p))
(while (and (setq p (cdr p))
(equal dir (file-name-directory (car p)))))
(if p
(while (and (setq p (cdr p))
(equal dir (file-name-directory (car p)))))
(if p
- (setq filename nil table nil pred nil
+ (setq filename nil table nil
+ pred (if (stringp pred) nil pred)
ambig t)
(delete-region beg end)
(setq str (concat dir (file-name-nondirectory str)))
ambig t)
(delete-region beg end)
(setq str (concat dir (file-name-nondirectory str)))
;; even if we couldn't, so remove the added
;; wildcards.
(setq str origstr)
;; even if we couldn't, so remove the added
;; wildcards.
(setq str origstr)
- (setq filename nil table nil pred nil)))))
+ (setq filename nil table nil
+ pred (if (stringp pred) nil pred))))))
;; Strip directory name if appropriate
(if filename
;; Strip directory name if appropriate
(if filename