]> code.delx.au - gnu-emacs/blobdiff - lisp/pcomplete.el
(tab-always-indent): Fix custom-type.
[gnu-emacs] / lisp / pcomplete.el
index a620880e0f7f61781f7163ca5b8f4241c410d8c3..80f09492fee4c0c9b8211e015cc3f0a8cdaad933 100644 (file)
@@ -1,7 +1,7 @@
 ;;; pcomplete.el --- programmable completion
 
 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
-;;   2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 ;; Keywords: processes abbrev
@@ -480,28 +480,31 @@ Same as `pcomplete' but using the standard completion UI."
                      (pcomplete-begin)))
            (buftext (buffer-substring beg (point)))
            (table
-            (if (not (equal pcomplete-stub buftext))
-                ;; This isn't always strictly right (e.g. if
-                ;; FOO="toto/$FOO", then completion of /$FOO/bar may
-                ;; result in something incorrect), but given the lack of
-                ;; any other info, it's about as good as it gets, and in
-                ;; practice it should work just fine (fingers crossed).
-                (let ((prefixes (pcomplete--common-quoted-suffix
-                                 pcomplete-stub buftext)))
-                  (apply-partially
-                   'pcomplete--table-subvert
-                   completions
-                   (cdr prefixes) (car prefixes)))
+            (cond
+             ((null completions) nil)
+             ((not (equal pcomplete-stub buftext))
+              ;; This isn't always strictly right (e.g. if
+              ;; FOO="toto/$FOO", then completion of /$FOO/bar may
+              ;; result in something incorrect), but given the lack of
+              ;; any other info, it's about as good as it gets, and in
+              ;; practice it should work just fine (fingers crossed).
+              (let ((prefixes (pcomplete--common-quoted-suffix
+                               pcomplete-stub buftext)))
+                (apply-partially
+                 'pcomplete--table-subvert
+                 completions
+                 (cdr prefixes) (car prefixes))))
+             (t
               (lexical-let ((completions completions))
                 (lambda (string pred action)
                   (let ((res (complete-with-action
                               action completions string pred)))
                     (if (stringp res)
                         (pcomplete-quote-argument res)
-                      res))))))
+                      res)))))))
            (pred
             ;; pare it down, if applicable
-            (when (and pcomplete-use-paring pcomplete-seen)
+            (when (and table pcomplete-use-paring pcomplete-seen)
               (setq pcomplete-seen
                     (mapcar (lambda (f)
                               (funcall pcomplete-norm-func