emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/transient 3284f6a0fe 213/366: transient-init-value: Sup


From: Jonas Bernoulli
Subject: [elpa] externals/transient 3284f6a0fe 213/366: transient-init-value: Support per-object functions for prefixes
Date: Tue, 25 Jan 2022 18:54:42 -0500 (EST)

branch: externals/transient
commit 3284f6a0fe10cede4e5139f87645bc517d5893f7
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    transient-init-value: Support per-object functions for prefixes
    
    This is identical to the implementation for infixes and one could
    therefore be tempted to "simplify" matters by actually complicating
    them, but I prefer to "embrace the boilerplate" instead.
---
 lisp/transient.el | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lisp/transient.el b/lisp/transient.el
index e11dfa7fd4..8ef0458feb 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -539,6 +539,7 @@ If `transient-save-history' is nil, then do nothing."
    (command     :initarg :command)
    (level       :initarg :level)
    (variable    :initarg :variable    :initform nil)
+   (init-value  :initarg :init-value)
    (value) (default-value :initarg :value)
    (scope       :initarg :scope       :initform nil)
    (history     :initarg :history     :initform nil)
@@ -2329,6 +2330,13 @@ abstract `transient-infix' class must implement this 
function.
 Non-infix suffix commands usually don't have a value."
   nil)
 
+(cl-defmethod transient-init-value :around ((obj transient-prefix))
+  "If bound, then call OBJ's `init-value' function.
+Otherwise call the primary method according to objects class."
+  (if (slot-boundp obj 'init-value)
+      (funcall (oref obj init-value) obj)
+    (cl-call-next-method obj)))
+
 (cl-defmethod transient-init-value :around ((obj transient-infix))
   "If bound, then call OBJ's `init-value' function.
 Otherwise call the primary method according to objects class."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]