Function: combobulate-define-envelope

combobulate-define-envelope is a natively compiled function defined in combobulate-envelope.el.

Signature

(combobulate-define-envelope &rest ARGS)

Documentation

Define an envelope using ARGS.

ARGS is a list of keyword arguments. The following keywords are supported:

:name (required) - The name of the envelope.

:description (required) - A description of the envelope.

:template (required) - The template to apply to the nodes.

:nodes - A list of node types that the envelope can be applied
to.

:procedures - A list of procedures that the envelope can be
applied to. If :nodes is defined, then this is ignored.

:shorthand - A shorthand for the nodes that the envelope can be
applied to. This shorthand is a string that is used to look up a procedure in the language-specific procedure-shorthand-alist.

:point-placement - Where to place point after the envelope is
applied. This can be either start, stay or end. The default is start.

:key (required) - A key to bind the envelope to. It will be
bound to the language-specific key map combobulate-LANGUAGE-envelope-map, which itself is bound to combobulate-key-map under the sub prefix e.

:extra-key - An extra key to bind the envelope to. It will be
bound to the language-specific map directly and so any key is valid.

Source Code

;; Defined in /nix/store/b5fvrwzi3zvkabyzx0in6gw1cj963z46-emacs-packages-deps/share/emacs/site-lisp/combobulate-envelope.el
(defun combobulate-define-envelope (&rest args)
  "Define an envelope using ARGS.

ARGS is a list of keyword arguments. The following keywords are
supported:

`:name' (required) - The name of the envelope.

`:description' (required) - A description of the envelope.

`:template' (required) - The template to apply to the nodes.

`:nodes' - A list of node types that the envelope can be applied
to.

`:procedures' - A list of procedures that the envelope can be
applied to. If `:nodes' is defined, then this is ignored.

`:shorthand' - A shorthand for the nodes that the envelope can be
applied to. This shorthand is a string that is used to look up a
procedure in the language-specific `procedure-shorthand-alist'.

`:point-placement' - Where to place point after the envelope is
applied. This can be either `start', `stay' or `end'. The default
is `start'.

`:key' (required) - A key to bind the envelope to. It will be
bound to the language-specific key map
`combobulate-LANGUAGE-envelope-map', which itself is bound to
`combobulate-key-map' under the sub prefix `e'.

`:extra-key' - An extra key to bind the envelope to. It will be
bound to the language-specific map directly and so any key is
valid."
  (map-let (:description :key :extra-key :name) args
    (let ((fn-name (combobulate--envelope-get-function-name args)))
      ;; Do not redefine the function if it already exists. This can
      ;; actually cause a serious performance cascade as each invocation.
      (unless (fboundp fn-name)
        ;; Store the function symbol for later recall in things like
        ;; transient.
        (defalias fn-name
          `(lambda () ,(format "%s\n%s" description
                          "This command triggers Combobulate's envelope system.")
             (interactive)
             (combobulate-execute-envelope ,name))))
      (define-key (combobulate-read envelope-map) (kbd key) fn-name)
      (when extra-key
        (define-key (combobulate-read map) (kbd extra-key) fn-name)))))