more prefix-alternative cleanup

This commit is contained in:
Ivan Malison 2015-11-22 01:50:07 -08:00
parent 6688135c17
commit 348d2d1fa6

View File

@ -208,16 +208,18 @@
(interactive "p") (interactive "p")
(message "%s" arg)) (message "%s" arg))
(imalison:prefix-alternatives multi-line multi-line multi-line)
(defmacro imalison:prefix-alternatives (name &rest alternatives) (defmacro imalison:prefix-alternatives (name &rest alternatives)
`(defun ,name (arg) `(defun ,name (arg)
(interactive "p") (interactive "p")
(setq function (setq function
(cond (cond
,@(progn ,@(progn
(setq last-power 1) (let ((last-power 1))
(cl-loop for alternative in alternatives (cl-loop for alternative in alternatives
collect `((eq prefix-value ,last-power) (quote ,alternative)) collect `((eq prefix-value ,last-power) (quote ,alternative))
do (setq last-power (* last-power 4)))))) do (setq last-power (* last-power 4)))))))
(setq function (or function (car alternatives))) ; Set a default value for function (setq function (or function (car alternatives))) ; Set a default value for function
(setq current-prefix-arg nil) (setq current-prefix-arg nil)
(call-interactively function))) (call-interactively function)))