From 2f65ac9e19dc2fd01d949f752bdc85b95c656725 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 23 Apr 2008 18:39:22 +0000 Subject: [PATCH] (PC-do-completion): Be more robust in the presence of unexpected values in minibuffer-completion-predicate. --- lisp/ChangeLog | 3 +++ lisp/complete.el | 16 ++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9f4da1f394a..11355da864c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2008-04-23 Stefan Monnier + * 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. diff --git a/lisp/complete.el b/lisp/complete.el index 3c4385273d1..c16e4af61c0 100644 --- a/lisp/complete.el +++ b/lisp/complete.el @@ -491,8 +491,9 @@ GOTO-END is non-nil, however, it instead replaces up to END." (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 @@ -506,8 +507,9 @@ GOTO-END is non-nil, however, it instead replaces up to END." (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)) @@ -522,7 +524,8 @@ GOTO-END is non-nil, however, it instead replaces up to END." (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))) @@ -535,7 +538,8 @@ GOTO-END is non-nil, however, it instead replaces up to END." ;; 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 -- 2.11.4.GIT