Function: transient--get-layout

transient--get-layout is a byte-compiled function defined in transient.el.gz.

Signature

(transient--get-layout PREFIX)

Source Code

;; Defined in /usr/src/emacs/lisp/transient.el.gz
(defun transient--get-layout (prefix)
  (cond*
    ((bind*
       (layout
        (or (get prefix 'transient--layout)
            ;; Migrate unparsed legacy group definition.
            (condition-case-unless-debug err
                (and-let* ((value (symbol-value prefix)))
                  (transient--set-layout
                   prefix
                   (if (and (listp value)
                            (or (listp (car value))
                                (vectorp (car value))))
                       (transient-parse-suffixes prefix value)
                     (list (transient-parse-suffix prefix value)))))
              (error
               (message "Not a legacy group definition: %s: %S" prefix err)
               nil))))))
    ((not layout)
     (error "Not a transient prefix command or group definition: %s" prefix))
    ((vectorp layout)
     (let ((version (aref layout 0)))
       (if (= version 2)
           layout
         (error "Unsupported layout version %s for %s" version prefix))))
    (t
     ;; Upgrade from version 1.
     (transient--set-layout
      prefix
      (named-let upgrade ((spec layout))
        (cond ((and (vectorp spec)
                    (length= spec 3))
               ;; This format is used by emoji.el from Emacs <= 29.4.
               (pcase-let ((`[,class ,args ,children] spec))
                 (vector class args (mapcar #'upgrade children))))
              ((vectorp spec)
               (pcase-let ((`[,level ,class ,args ,children] spec))
                 (when level
                   (setq args (plist-put args :level level)))
                 (vector class args (mapcar #'upgrade children))))
              ((and (listp spec)
                    (length= spec 3)
                    (or (null (car spec))
                        (natnump (car spec)))
                    (symbolp (cadr spec)))
               (pcase-let ((`(,level ,class ,args) spec))
                 (when level
                   (setq args (plist-put args :level level)))
                 (cons class args)))
              ((listp spec)
               (mapcar #'upgrade spec))
              (t spec)))))))