Function: ffap-menu-ask

ffap-menu-ask is a byte-compiled function defined in ffap.el.gz.

Signature

(ffap-menu-ask TITLE ALIST CONT)

Documentation

Prompt from a menu of choices, and then apply some action.

Arguments are TITLE, ALIST, and CONT (a continuation function). This uses either a menu or the minibuffer depending on invocation. The TITLE string is used as either the prompt or menu title. Each ALIST entry looks like (STRING . DATA) and defines one choice. Function CONT is applied to the entry chosen by the user.

Source Code

;; Defined in /usr/src/emacs/lisp/ffap.el.gz
(defun ffap-menu-ask (title alist cont)
  "Prompt from a menu of choices, and then apply some action.
Arguments are TITLE, ALIST, and CONT (a continuation function).
This uses either a menu or the minibuffer depending on invocation.
The TITLE string is used as either the prompt or menu title.
Each ALIST entry looks like (STRING . DATA) and defines one choice.
Function CONT is applied to the entry chosen by the user."
  ;; Note: this function is used with a different continuation
  ;; by the ffap-url add-on package.
  ;; Could try rewriting to use easymenu.el.
  (let (choice)
    (cond
     ;; Emacs mouse:
     ((and (fboundp 'x-popup-menu)
           (listp last-nonmenu-event)
           last-nonmenu-event)
      (setq choice
	    (x-popup-menu
	     t
	     (list "" (cons title
			    (mapcar (lambda (i) (cons (car i) i))
				    alist))))))
     ;; minibuffer with completion buffer:
     (t
      (let ((minibuffer-setup-hook 'minibuffer-completion-help))
	;; Bug: prompting may assume unique strings, no "".
	(setq choice
	      (completing-read
	       (format-prompt title (car (car alist)))
	       alist nil t
	       ;; (cons (car (car alist)) 0)
	       nil)))
      (sit-for 0)			; redraw original screen
      ;; Convert string to its entry, or else the default:
      (setq choice (or (assoc choice alist) (car alist)))))
    (if choice
	(funcall cont choice)
      (message "No choice made!")	; possible with menus
      nil)))