Function: idlwave-one-key-select

idlwave-one-key-select is a byte-compiled function defined in idlwave.el.gz.

Signature

(idlwave-one-key-select SYM PROMPT DELAY)

Documentation

Make the user select an element from the alist in the variable SYM.

The keys of the alist are expected to be strings. The function returns the car of the selected association. To do this, PROMPT is displayed and the user must hit a letter key to select an entry. If the user does not reply within DELAY seconds, a help window with the options is displayed automatically. The key which is associated with each option is generated automatically. First, the strings are checked for preselected keys, like in "[P]rint". If these don't exist, a letter in the string is automatically selected.

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/idlwave.el.gz
(defun idlwave-one-key-select (sym prompt delay)
  "Make the user select an element from the alist in the variable SYM.
The keys of the alist are expected to be strings.  The function returns the
car of the selected association.
To do this, PROMPT is displayed and the user must hit a letter key to
select an entry.  If the user does not reply within DELAY seconds, a help
window with the options is displayed automatically.
The key which is associated with each option is generated automatically.
First, the strings are checked for preselected keys, like in \"[P]rint\".
If these don't exist, a letter in the string is automatically selected."
  (let* ((alist (symbol-value sym))
         (temp-buffer-show-hook '(fit-window-to-buffer))
         keys-alist char)
    ;; First check the cache
    (if (and (eq (symbol-value sym) (get sym :one-key-alist-last)))
        (setq keys-alist (get sym :one-key-alist-cache))
      ;; Need to make new list
      (setq keys-alist (idlwave-make-one-key-alist alist))
      (put sym :one-key-alist-cache keys-alist)
      (put sym :one-key-alist-last alist))
    ;; Display prompt and wait for quick reply
    (message "%s[%s]" prompt
             (mapconcat (lambda(x) (char-to-string (car x)))
                        keys-alist))
    (if (sit-for delay)
        ;; No quick reply: Show help
        (save-window-excursion
          (with-output-to-temp-buffer "*Completions*"
	    (dolist (x keys-alist)
	      (princ (nth 1 x))
	      (princ "\n")))
          (setq char (read-char)))
      (setq char (read-char)))
    (message nil)
    ;; Return the selected result
    (nth 2 (assoc char keys-alist))))