Function: cookie-read

cookie-read is a byte-compiled function defined in cookie1.el.gz.

Signature

(cookie-read PROMPT PHRASE-FILE &optional STARTMSG ENDMSG REQUIRE-MATCH)

Documentation

Prompt with PROMPT and read with completion among cookies in PHRASE-FILE.

STARTMSG and ENDMSG are passed along to cookie-snarf. Argument REQUIRE-MATCH non-nil forces a matching cookie.

Aliases

read-cookie (obsolete since 24.4)

Source Code

;; Defined in /usr/src/emacs/lisp/play/cookie1.el.gz
(defun cookie-read (prompt phrase-file &optional startmsg endmsg require-match)
  "Prompt with PROMPT and read with completion among cookies in PHRASE-FILE.
STARTMSG and ENDMSG are passed along to `cookie-snarf'.
Argument REQUIRE-MATCH non-nil forces a matching cookie."
  (setq phrase-file (cookie-check-file phrase-file))
  ;; Make sure the cookies are in the cache.
  (or (intern-soft phrase-file cookie-cache)
      (cookie-snarf phrase-file startmsg endmsg))
  (completing-read prompt
		   (let ((sym (intern phrase-file cookie-cache)))
		     ;; We cache the alist form of the cookie in a property.
		     (or (get sym 'completion-alist)
			 (let* ((alist nil)
				(vec (cookie-snarf phrase-file
						   startmsg endmsg))
				(i (length vec)))
			   (while (>= (setq i (1- i)) 0)
			     (setq alist (cons (list (aref vec i)) alist)))
			   (put sym 'completion-alist alist))))
		   nil require-match nil nil))