Skip to content

Instantly share code, notes, and snippets.

@phelrine
Created January 27, 2011 15:16
Show Gist options
  • Save phelrine/798624 to your computer and use it in GitHub Desktop.
Save phelrine/798624 to your computer and use it in GitHub Desktop.
yas/popup-prompt
(require 'popup)
(defun yas/popup-prompt (prompt choices &optional disp-fn)
(defun memq-index (elem list)
(defun memq-index-iter (list index)
(cond ((atom list) (and (eq elem list) index))
((eq elem (car list)) index)
(t (memq-index-iter (cdr list) (+ 1 index)))))
(memq-index-iter list 0))
(let* ((formatted-choices
(or (and disp-fn
(mapcar disp-fn choices))
choices))
(chosen (and formatted-choices
(popup-menu* formatted-choices))))
(nth (memq-index chosen formatted-choices) choices)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment