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

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

[elpa] externals/transient d1caef5192 198/366: Add new `init-value' infi


From: Jonas Bernoulli
Subject: [elpa] externals/transient d1caef5192 198/366: Add new `init-value' infix slot
Date: Tue, 25 Jan 2022 18:54:40 -0500 (EST)

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

    Add new `init-value' infix slot
    
    If this value bound then it is called with the object as only
    argument instead of the primary `transient-init-value' method
    of the object class.
    
    Re #96.
---
 docs/transient.org  |  9 +++++++--
 docs/transient.texi | 11 +++++++++--
 lisp/transient.el   |  8 ++++++++
 3 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/docs/transient.org b/docs/transient.org
index d7736b5bd0..bfbed9ab59 100644
--- a/docs/transient.org
+++ b/docs/transient.org
@@ -8,7 +8,7 @@
 #+TEXINFO_DIR_CATEGORY: Emacs
 #+TEXINFO_DIR_TITLE: Transient: (transient).
 #+TEXINFO_DIR_DESC: Transient Commands
-#+SUBTITLE: for version 0.2.0 (v0.2.0-45-g313eee0f+1)
+#+SUBTITLE: for version 0.2.0 (v0.2.0-46-g1b9929ec+1)
 
 #+TEXINFO_DEFFN: t
 #+OPTIONS: H:4 num:4 toc:2
@@ -37,7 +37,7 @@ Calling a suffix command usually causes the transient to be 
exited
 but suffix commands can also be configured to not exit the transient.
 
 #+TEXINFO: @noindent
-This manual is for Transient version 0.2.0 (v0.2.0-45-g313eee0f+1).
+This manual is for Transient version 0.2.0 (v0.2.0-46-g1b9929ec+1).
 
 #+BEGIN_QUOTE
 Copyright (C) 2018-2020 Jonas Bernoulli <jonas@bernoul.li>
@@ -1593,6 +1593,11 @@ They are defined here anyway to allow sharing certain 
methods.
 
 - ~value~ The value.  Should not be accessed directly.
 
+- ~init-value~ Function that is responsable for setting the object's
+  value.  If bound, then this is called with the object as the only
+  argument.  Usually this is not bound, in which case the object's
+  primary ~transient-init-value~ method is called instead.
+
 - ~unsavable~ Whether the value of the suffix is not saved as part of
   the prefixes.
 
diff --git a/docs/transient.texi b/docs/transient.texi
index b692001b69..6b487f803a 100644
--- a/docs/transient.texi
+++ b/docs/transient.texi
@@ -31,7 +31,7 @@ General Public License for more details.
 @finalout
 @titlepage
 @title Transient User and Developer Manual
-@subtitle for version 0.2.0 (v0.2.0-45-g313eee0f+1)
+@subtitle for version 0.2.0 (v0.2.0-46-g1b9929ec+1)
 @author Jonas Bernoulli
 @page
 @vskip 0pt plus 1filll
@@ -65,7 +65,7 @@ Calling a suffix command usually causes the transient to be 
exited
 but suffix commands can also be configured to not exit the transient.
 
 @noindent
-This manual is for Transient version 0.2.0 (v0.2.0-45-g313eee0f+1).
+This manual is for Transient version 0.2.0 (v0.2.0-46-g1b9929ec+1).
 
 @quotation
 Copyright (C) 2018-2020 Jonas Bernoulli <jonas@@bernoul.li>
@@ -1973,6 +1973,13 @@ They are defined here anyway to allow sharing certain 
methods.
 @code{value} The value.  Should not be accessed directly.
 
 
+@item
+@code{init-value} Function that is responsable for setting the object's
+value.  If bound, then this is called with the object as the only
+argument.  Usually this is not bound, in which case the object's
+primary @code{transient-init-value} method is called instead.
+
+
 @item
 @code{unsavable} Whether the value of the suffix is not saved as part of
 the prefixes.
diff --git a/lisp/transient.el b/lisp/transient.el
index a5959286b3..63dc78f538 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -650,6 +650,7 @@ slot is non-nil."
    (argument    :initarg :argument)
    (shortarg    :initarg :shortarg)
    (value                             :initform nil)
+   (init-value  :initarg :init-value)
    (unsavable   :initarg :unsavable   :initform nil)
    (multi-value :initarg :multi-value :initform nil)
    (always-read :initarg :always-read :initform nil)
@@ -2312,6 +2313,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-infix))
+  "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 ((obj transient-prefix))
   (if (slot-boundp obj 'value)
       (oref obj value)



reply via email to

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