Check toggle condition in status function

This commit is contained in:
Eivind Fonn 2016-10-27 12:58:00 +02:00
parent e4e6638d4d
commit 03a8f6733f

View file

@ -71,7 +71,11 @@ used."
;; a bound symbol ;; a bound symbol
(status-eval `(and (or (and (symbolp ',status) (boundp ',status)) (status-eval `(and (or (and (symbolp ',status) (boundp ',status))
(listp ',status)) (listp ',status))
,status))) ,status))
(condition-eval `(or (null ',condition)
(and (or (and (symbolp ',condition) (boundp ',condition))
(listp ',condition))
,condition))))
`(progn `(progn
(push (append '(,name) '(:function ,wrapper-func (push (append '(,name) '(:function ,wrapper-func
:predicate ,wrapper-func-status) ',props) :predicate ,wrapper-func-status) ',props)
@ -80,10 +84,7 @@ used."
(defun ,wrapper-func ,(if prefix-arg-var (list prefix-arg-var) ()) (defun ,wrapper-func ,(if prefix-arg-var (list prefix-arg-var) ())
,(format "Toggle %s on and off." (symbol-name name)) ,(format "Toggle %s on and off." (symbol-name name))
,(if prefix-arg-var '(interactive "P") '(interactive)) ,(if prefix-arg-var '(interactive "P") '(interactive))
(if (or (null ',condition) (if ,condition-eval
(and (or (and (symbolp ',condition) (boundp ',condition))
(listp ',condition))
,condition))
(if (,wrapper-func-status) (if (,wrapper-func-status)
(progn ,@off-body (progn ,@off-body
(when (called-interactively-p 'any) (when (called-interactively-p 'any)
@ -95,7 +96,7 @@ used."
;; predicate function ;; predicate function
(defun ,wrapper-func-status () (defun ,wrapper-func-status ()
,(format "Check if %s is on." (symbol-name name)) ,(format "Check if %s is on." (symbol-name name))
,status-eval) (and ,condition-eval ,status-eval))
;; Only define on- or off-functions when status is available ;; Only define on- or off-functions when status is available
,@(when status ,@(when status
;; on-function ;; on-function