Function: PC-try-completion

PC-try-completion is a byte-compiled function defined in complete.el.gz.

Signature

(PC-try-completion STRING ALIST &optional PREDICATE)

Documentation

Like try-completion but return STRING instead of t.

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/complete.el.gz
;; The following function is an attempt to work around two problems:

;; (1) When complete.el was written, (try-completion "" '(("") (""))) used to
;; return the value "".  With a change from 2002-07-07 it returns t which caused
;; `PC-lisp-complete-symbol' to fail with a "Wrong type argument: sequencep, t"
;; error.  `PC-try-completion' returns STRING in this case.

;; (2) (try-completion "" '((""))) returned t before the above-mentioned change.
;; Since `PC-chop-word' operates on the return value of `try-completion' this
;; case might have provoked a similar error as in (1).  `PC-try-completion'
;; returns "" instead.  I don't know whether this is a real problem though.

;; Since `PC-try-completion' is not a guaranteed to fix these bugs reliably, you
;; should try to look at the following discussions when you encounter problems:
;; - emacs-pretest-bug ("Partial Completion" starting 2007-02-23),
;; - emacs-devel ("[address-of-OP: Partial completion]" starting 2007-02-24),
;; - emacs-devel ("[address-of-OP: EVAL and mouse selection in *Completions*]"
;;   starting 2007-03-05).
(defun PC-try-completion (string alist &optional predicate)
  "Like `try-completion' but return STRING instead of t."
  (let ((result (try-completion string alist predicate)))
    (if (eq result t) string result)))