refactor: extract transient class

This commit is contained in:
Pavel Korytov 2022-08-13 15:53:05 +05:00
parent adfb483168
commit 2f95a2a1c5

21
pomm.el
View file

@ -627,21 +627,22 @@ minor mode."
(read-number "Number of work periods before a long break:" (read-number "Number of work periods before a long break:"
pomm-number-of-periods))) pomm-number-of-periods)))
(defclass pomm--set-context-on-iteration-end-infix (transient-switch) (defclass pomm--transient-lisp-variable-switch (transient-switch)
((transient :initform t)) ((transient :initform t)
"A transient class to toggle `pomm-reset-context-on-iteration-end'.") (variable :initarg :variable)))
(cl-defmethod transient-init-value ((obj pomm--set-context-on-iteration-end-infix)) (cl-defmethod transient-init-value ((obj pomm--transient-lisp-variable-switch))
(oset obj value (oset obj value
pomm-reset-context-on-iteration-end)) (symbol-value (oref obj variable))))
(cl-defmethod transient-infix-read ((_ pomm--set-context-on-iteration-end-infix)) (cl-defmethod transient-infix-read ((obj pomm--transient-lisp-variable-switch))
"Toggle the switch on or off." (oset obj value
(setq pomm-reset-context-on-iteration-end (set (oref obj variable)
(not pomm-reset-context-on-iteration-end))) (not (symbol-value (oref obj variable))))))
(transient-define-infix pomm--set-reset-context-on-iteration-end () (transient-define-infix pomm--set-reset-context-on-iteration-end ()
:class 'pomm--set-context-on-iteration-end-infix :class 'pomm--transient-lisp-variable-switch
:variable 'pomm-reset-context-on-iteration-end
:argument "--context-reset" :argument "--context-reset"
:key "-r" :key "-r"
:description "Reset the context on the interation end") :description "Reset the context on the interation end")