Created
January 27, 2011 15:16
-
-
Save phelrine/798624 to your computer and use it in GitHub Desktop.
yas/popup-prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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