branch: externals/transient commit cfd17a714b0ef9401d570946795a38fe1d8d6e08 Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
manual: Add an example using :setup-children --- docs/transient.org | 31 ++++++++++++++++++++++++++++++- docs/transient.texi | 31 ++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/docs/transient.org b/docs/transient.org index 83bf8d68e8..c68b47d0cd 100644 --- a/docs/transient.org +++ b/docs/transient.org @@ -1012,7 +1012,10 @@ constructor of that class. to use the same form as understood by ~transient-define-prefix~, described below. If you use the latter approach, you can use the ~transient-parse-suffixes~ and ~transient-parse-suffix~ functions to - transform them from the convenient to the expected form. + transform them from the convenient to the expected form. Depending + on the used group class, ~transient-parse-suffixes~'s SUFFIXES must be + a list of group vectors (for ~transient-columns~) or a list of suffix + lists (for all other group classes). If you explicitly specify children and then transform them using ~:setup-children~, then the class of the group is determined as usual, @@ -1024,6 +1027,32 @@ constructor of that class. is used and a warning is displayed. This warning will eventually be replaced with an error. + #+BEGIN_SRC emacs-lisp + (transient-define-prefix my-finder-by-keyword () + "Select a keyword and list matching packages." + ;; The real `finder-by-keyword' is more convenient + ;; of course, but that is not the point here. + [:class transient-columns + :setup-children + (lambda (_) + (transient-parse-suffixes + 'my-finder-by-keyword + (let ((char (1- ?A))) + (mapcar ; a list ... + (lambda (partition) + (vconcat ; of group vectors ... + (mapcar (lambda (elt) + (let ((keyword (symbol-name (car elt)))) + ; ... where each suffix is a list + (list (format "%c" (cl-incf char)) + keyword + (lambda () + (interactive) + (finder-list-matches keyword))))) + partition))) + (seq-partition finder-known-keywords 7)))))]) + #+END_SRC + - The boolean ~:pad-keys~ argument controls whether keys of all suffixes contained in a group are right padded, effectively aligning the descriptions. diff --git a/docs/transient.texi b/docs/transient.texi index b6254aa5b0..a96ea3b301 100644 --- a/docs/transient.texi +++ b/docs/transient.texi @@ -1201,7 +1201,10 @@ prefix's @code{transient--layout} property, but it is often more convenient to use the same form as understood by @code{transient-define-prefix}, described below. If you use the latter approach, you can use the @code{transient-parse-suffixes} and @code{transient-parse-suffix} functions to -transform them from the convenient to the expected form. +transform them from the convenient to the expected form. Depending +on the used group class, @code{transient-parse-suffixes}'s SUFFIXES must be +a list of group vectors (for @code{transient-columns}) or a list of suffix +lists (for all other group classes). If you explicitly specify children and then transform them using @code{:setup-children}, then the class of the group is determined as usual, @@ -1213,6 +1216,32 @@ For backward compatibility, if you fail to do so, @code{transient-column} is used and a warning is displayed. This warning will eventually be replaced with an error. +@lisp +(transient-define-prefix my-finder-by-keyword () + "Select a keyword and list matching packages." + ;; The real `finder-by-keyword' is more convenient + ;; of course, but that is not the point here. + [:class transient-columns + :setup-children + (lambda (_) + (transient-parse-suffixes + 'my-finder-by-keyword + (let ((char (1- ?A))) + (mapcar ; a list ... + (lambda (partition) + (vconcat ; of group vectors ... + (mapcar (lambda (elt) + (let ((keyword (symbol-name (car elt)))) + ; ... where each suffix is a list + (list (format "%c" (cl-incf char)) + keyword + (lambda () + (interactive) + (finder-list-matches keyword))))) + partition))) + (seq-partition finder-known-keywords 7)))))]) +@end lisp + @item The boolean @code{:pad-keys} argument controls whether keys of all suffixes contained in a group are right padded, effectively aligning the