Created
April 13, 2015 23:02
-
-
Save mrwacky42/9d2aa9f3d4080b9676cc to your computer and use it in GitHub Desktop.
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
(setq checkboxes '(("yesno" :options ("Yes" "No") :default "Yes") | |
("passfail" :options ("Pass" "Fail") :default "Pass"))) | |
(defun create-checkboxes () | |
(let ((choice-options (mapcar #'car checkboxes))) | |
(completing-read "Choices: " checkboxes nil t nil nil (first choice-options)))) | |
(defun get-some-checkboxes () | |
(let* ((choicekey (create-checkboxes)) | |
(choicedefault (plist-get (cdr (assoc choicekey checkboxes)) :default)) | |
(choiceoptions (plist-get (cdr (assoc choicekey checkboxes)) :options))) | |
(setq checked (completing-read "Which is checked?: " choiceoptions nil t nil nil choicedefault)) | |
(mapconcat (function (lambda (x) (format "[%s] %s" (if (string= x checked) "✔" "") x))) | |
choiceoptions " "))) | |
(get-some-checkboxes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment