[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/transient f5d81ef0ed 186/366: transient-lisp-variable:
From: |
Jonas Bernoulli |
Subject: |
[elpa] externals/transient f5d81ef0ed 186/366: transient-lisp-variable: New class |
Date: |
Tue, 25 Jan 2022 18:54:39 -0500 (EST) |
branch: externals/transient
commit f5d81ef0ed24be935f3c0192b746a1738d903d37
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
transient-lisp-variable: New class
---
lisp/transient.el | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/lisp/transient.el b/lisp/transient.el
index 8428674a04..ed1cabb01d 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -651,6 +651,7 @@ slot is non-nil."
(shortarg :initarg :shortarg)
(value :initform nil)
(multi-value :initarg :multi-value :initform nil)
+ (always-read :initarg :always-read :initform nil)
(allow-empty :initarg :allow-empty :initform nil)
(history-key :initarg :history-key :initform nil)
(reader :initarg :reader :initform nil)
@@ -2371,9 +2372,10 @@ limited number of possible values should you replace
this with a
simple method that does not handle history. (E.g. for a command
line switch the only possible values are \"use it\" and \"don't use
it\", in which case it is pointless to preserve history.)"
- (with-slots (value multi-value allow-empty choices) obj
+ (with-slots (value multi-value always-read allow-empty choices) obj
(if (and value
(not multi-value)
+ (not always-read)
transient--prefix)
(oset obj value nil)
(let* ((overriding-terminal-local-map nil)
@@ -3413,6 +3415,35 @@ we stop there."
(font-lock-add-keywords 'emacs-lisp-mode transient-font-lock-keywords)
+;;; Auxiliary Classes
+;;;; `transient-lisp-variable'
+
+(defclass transient-lisp-variable (transient-variable)
+ ((reader :initform transient-lisp-variable--reader)
+ (always-read :initform t))
+ "[Experimental] Class used for Lisp variables.")
+
+(cl-defmethod transient-init-value ((obj transient-lisp-variable))
+ (oset obj value (symbol-value (oref obj variable))))
+
+(cl-defmethod transient-infix-set ((obj transient-lisp-variable) value)
+ (set (oref obj variable)
+ (oset obj value value)))
+
+(cl-defmethod transient-format-description ((obj transient-lisp-variable))
+ (or (oref obj description)
+ (oref obj variable)))
+
+(cl-defmethod transient-format-value ((obj transient-lisp-variable))
+ (propertize (prin1-to-string (oref obj value))
+ 'face 'transient-value))
+
+(cl-defmethod transient-prompt ((obj transient-lisp-variable))
+ (format "Set %s: " (oref obj variable)))
+
+(defun transient-lisp-variable--reader (prompt initial-input _history)
+ (read--expression prompt initial-input))
+
;;; _
(provide 'transient)
;; Local Variables:
- [elpa] externals/transient fd7bb997ab 150/366: Complete CHANGELOG, (continued)
- [elpa] externals/transient fd7bb997ab 150/366: Complete CHANGELOG, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient afa0c2f984 152/366: Add redundant gitignore rules, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 629c963e1f 153/366: manual: Fix typo, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 53b71f9cc5 154/366: Fix documentation typo, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 35c9d2b541 155/366: Use recommended form of GPLv3 permissions statement, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 88d935c7cb 164/366: transient-display-buffer-action: inhibit-same-window by default, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient c1df3b2121 170/366: Ensure we use symbols in a few more places, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient b768a30199 174/366: transient--suffix-symbol: Verify that optimized path can be used, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 3bfde52f3a 175/366: Support dimming inapt commands, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 2243650b95 183/366: transient--emergency-exit: Signal the error, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient f5d81ef0ed 186/366: transient-lisp-variable: New class,
Jonas Bernoulli <=
- [elpa] externals/transient 96cec8e16e 187/366: manual: Use a favicon in html export, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 2a79b61664 192/366: transient--emergency-exit: Always signal the error, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 55bad19507 194/366: transient--pp-to-file: Bugfix, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient d1caef5192 198/366: Add new `init-value' infix slot, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 990eb0a292 201/366: Don't bind "M-<key>" to any common commands, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient c8d0a17eba 207/366: transient--init-prefix: New function, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 3c5ac3a989 208/366: transient--init-suffixes: New function, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 517fe3b15e 209/366: transient--flatten-suffixes: New function, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 1a1b2cc611 210/366: transient-args: Use new internal functions, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient b12528f6e1 216/366: transient--with-emergency-exit: Avoid re-signaling when debugging, Jonas Bernoulli, 2022/01/25