Function: transient-suffix-object

transient-suffix-object is a byte-compiled function defined in transient.el.

Signature

(transient-suffix-object &optional COMMAND)

Documentation

Return the object associated with the current suffix command.

Each suffix commands is associated with an object, which holds additional information about the suffix, such as its value (in the case of an infix command, which is a kind of suffix command).

This function is intended to be called by infix commands, which are usually aliases of transient--default-infix-command, which is defined like this:

  (defun transient--default-infix-command ()
    (interactive)
    (let ((obj (transient-suffix-object)))
      (transient-infix-set obj (transient-infix-read obj)))
    (transient--show))

(User input is read outside of interactive to prevent the
command from being added to command-history(var)/command-history(fun). See #23.)

Such commands need to be able to access their associated object to guide how transient-infix-read reads the new value and to store the read value. Other suffix commands (including non-infix commands) may also need the object to guide their behavior.

This function attempts to return the object associated with the current suffix command even if the suffix command was not invoked from a transient. (For some suffix command that is a valid thing
to do, for others it is not.) In that case nil may be returned,
if the command was not defined using one of the macros intended to define such commands.

The optional argument COMMAND is intended for internal use. If you are contemplating using it in your own code, then you should probably use this instead:

  (get COMMAND 'transient--suffix)

Source Code

;; Defined in ~/.emacs.d/elpa/transient-20260414.1009/transient.el
(defun transient-suffix-object (&optional command)
  "Return the object associated with the current suffix command.

Each suffix commands is associated with an object, which holds
additional information about the suffix, such as its value (in
the case of an infix command, which is a kind of suffix command).

This function is intended to be called by infix commands, which
are usually aliases of `transient--default-infix-command', which
is defined like this:

  (defun transient--default-infix-command ()
    (interactive)
    (let ((obj (transient-suffix-object)))
      (transient-infix-set obj (transient-infix-read obj)))
    (transient--show))

\(User input is read outside of `interactive' to prevent the
command from being added to `command-history'.  See #23.)

Such commands need to be able to access their associated object
to guide how `transient-infix-read' reads the new value and to
store the read value.  Other suffix commands (including non-infix
commands) may also need the object to guide their behavior.

This function attempts to return the object associated with the
current suffix command even if the suffix command was not invoked
from a transient.  (For some suffix command that is a valid thing
to do, for others it is not.)  In that case nil may be returned,
if the command was not defined using one of the macros intended
to define such commands.

The optional argument COMMAND is intended for internal use.  If
you are contemplating using it in your own code, then you should
probably use this instead:

  (get COMMAND \\='transient--suffix)"
  (when command
    (cl-check-type command command))
  (cond-let*
    (transient--pending-suffix)
    (transient--current-suffix)
    [[this-command (advice--cd*r this-command)]]
    ((or transient--prefix
         transient-current-prefix)
     (let ((suffixes
            (cl-remove-if-not
             (lambda (obj)
               (eq (oref obj command)
                   (or command
                       (if (eq this-command 'transient-set-level)
                           ;; This is how it can look up for which
                           ;; command it is setting the level.
                           this-original-command
                         this-command))))
             (or transient--suffixes
                 transient-current-suffixes))))
       (cond
         ((length= suffixes 1)
          (car suffixes))
         ((cl-find-if (lambda (obj)
                        (equal (listify-key-sequence (kbd (oref obj key)))
                               (listify-key-sequence (this-command-keys))))
                      suffixes))
         ;; COMMAND is only provided if `this-command' is meaningless, in
         ;; which case `this-command-keys' is also meaningless, making it
         ;; impossible to disambiguate bindings for the same command.
         (command (car suffixes))
         ;; If COMMAND is nil, then failure to disambiguate likely means
         ;; that there is a bug somewhere.
         ((length> suffixes 1)
          (error "BUG: Cannot unambiguously determine suffix object"))
         ;; It is legitimate to use this function as a predicate of sorts.
         ;; `transient--pre-command' and `transient-help' are examples.
         (t nil))))
    ([obj (transient--suffix-prototype (or command this-command))]
     [obj (clone obj)]
     (transient-init-scope obj)
     (transient-init-value obj)
     obj)))