mirror of
https://github.com/SqrtMinusOne/pomm.el.git
synced 2025-12-10 22:53:03 +03:00
refactor: extract transient class
This commit is contained in:
parent
adfb483168
commit
2f95a2a1c5
1 changed files with 11 additions and 10 deletions
21
pomm.el
21
pomm.el
|
|
@ -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")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue