Function: combobulate-apply-envelope

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

Signature

(combobulate-apply-envelope ENVELOPE &optional NODE REGION)

Documentation

Envelop NODE near point or active region with ENVELOPE.

If REGION is non-nil, envelop the region instead of NODE.

Source Code

;; Defined in /nix/store/b5fvrwzi3zvkabyzx0in6gw1cj963z46-emacs-packages-deps/share/emacs/site-lisp/combobulate-envelope.el
(defun combobulate-apply-envelope (envelope &optional node region)
  "Envelop NODE near point or active region with ENVELOPE.

If REGION is non-nil, envelop the region instead of NODE."
  (map-let (:nodes :mark-node :description :template :point-placement :name :procedures) envelope
    (unless (and name)
      (error "Envelope `%s' is not valid." envelope))
    (if region
        (combobulate-envelop-region template)
      (with-navigation-nodes (:nodes nodes :procedures procedures)
        (if (setq node (or node (combobulate--get-nearest-navigable-node)))
            (save-excursion
              ;; If we are asked to mark the node, we do. If not, we still go to
              ;; the beginning
              (if mark-node
                  (combobulate--mark-node node t)
                (cond
                 ;; nothing to do if point is `stay'.
                 ((or (null point-placement) (member point-placement '(start end)))
                  (combobulate--goto-node node (eq point-placement 'end)))))
              ;; triggering an envelope will invalidate `node'.
              (setq node (combobulate-proxy-node-make-from-nodes node))
              (prog1 (combobulate-envelope-expand-instructions template)
                (combobulate-message "Enveloping" node "in" description)))
          (error "Cannot apply envelope `%s'. Point must be in one of \
these nodes: `%s'." name nodes))))))