]> code.delx.au - gnu-emacs/commitdiff
(PC-do-completion): Be more robust in the presence of
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 23 Apr 2008 18:39:22 +0000 (18:39 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 23 Apr 2008 18:39:22 +0000 (18:39 +0000)
unexpected values in minibuffer-completion-predicate.

lisp/ChangeLog
lisp/complete.el

index 9f4da1f394a20bebc23d59815e06f69bc9b13be5..11355da864c3e9f5cbd9054aad70ae047464ef13 100644 (file)
@@ -1,5 +1,8 @@
 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.
 
index 3c4385273d16e28e3ac9457891be0a4b73c8068b..c16e4af61c08a18a03b5a83da85ebad7e3747b7b 100644 (file)
@@ -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))
       (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
@@ -506,8 +507,9 @@ GOTO-END is non-nil, however, it instead replaces up to END."
       (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))
@@ -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
                   (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)))
@@ -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)
                        ;; 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