From 8c77159f4f33d37e5c443d780a5cd88ccb545235 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 25 Oct 2024 19:29:58 +0200 Subject: factor out poll classes subbing off tp-option-var. FIX #601 --- lisp/mastodon-transient.el | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-transient.el b/lisp/mastodon-transient.el index 38da285..67ea667 100644 --- a/lisp/mastodon-transient.el +++ b/lisp/mastodon-transient.el @@ -278,6 +278,18 @@ the format fields.X.keyname." "An infix option class for our options. We always read.") +(defclass mastodon-transient-opt (tp-option tp-option-var) + (())) + +(defclass mastodon-transient-poll-bool (tp-bool tp-option-var) + ()) + +(defclass mastodon-transient-poll-choice (tp-option-str tp-option-var) + ()) + +(defclass mastodon-transient-expiry (tp-option tp-option-var) + ()) + (cl-defmethod transient-init-value ((obj mastodon-transient-field)) "Initialize value of OBJ." (let* ((prefix-val (oref transient--prefix value))) @@ -307,35 +319,6 @@ CONS is a cons of the form \"(fields.1.name . val)\"." (not (equal (cdr cons) (alist-get server-key server-elt nil nil #'string=))))) -(defclass mastodon-transient-poll-bool (tp-bool) - ()) - -(cl-defmethod transient-init-value ((obj mastodon-transient-poll-bool)) - "Initialize OBJ, a poll option. -Pull value from `tp-transient-settings' if possible.'" - (let ((key (oref obj alist-key))) - (oset obj value - (alist-get key tp-transient-settings)))) - -(defclass mastodon-transient-poll-choice (tp-option-str) - ()) - -(cl-defmethod transient-init-value ((obj mastodon-transient-poll-choice)) - "Initialize OBJ, an expiry option. -Pull value from `tp-transient-settings' if possible.'" - (let ((key (oref obj alist-key))) - (oset obj value - (alist-get key tp-transient-settings)))) - -(defclass mastodon-transient-expiry (tp-option) - ()) - -(cl-defmethod transient-init-value ((obj mastodon-transient-expiry)) - "Initialize OBJ, an expiry option. -Pull value from `tp-transient-settings' if possible.'" - (oset obj value - (alist-get 'expiry tp-transient-settings))) - (cl-defmethod transient-infix-read ((_obj mastodon-transient-expiry)) "Reader function for OBJ, a poll expiry." (cdr (mastodon-toot--read-poll-expiry))) -- cgit v1.2.3