Function: yaml-electric-bar-and-angle

yaml-electric-bar-and-angle is an interactive and natively compiled function defined in yaml-mode.el.

Signature

(yaml-electric-bar-and-angle ARG)

Documentation

Insert the bound key and possibly begin a block literal.

Inserts the bound key. If inserting the bound key causes the current line to match the initial line of a block literal, then inserts the matching string from yaml-block-literal-electric-alist, a newline, and indents appropriately.

Key Bindings

yaml-mode-map > yaml-mode-map |

Source Code

;; Defined in /nix/store/fxfawcfn8g3mqnf4q0lmvgvy0vp3nxrx-emacs-packages-deps/share/emacs/site-lisp/elpa/yaml-mode-20260830.2340/yaml-mode.el
(defun yaml-electric-bar-and-angle (arg)
  "Insert the bound key and possibly begin a block literal.
Inserts the bound key.  If inserting the bound key causes the current
line to match the initial line of a block literal, then inserts the
matching string from `yaml-block-literal-electric-alist', a newline,
and indents appropriately."
  (interactive "*P")
  (self-insert-command (prefix-numeric-value arg))
  (let ((extra-chars
         (assoc last-command-event
                yaml-block-literal-electric-alist)))
    (cond
     ((and extra-chars (not arg) (eolp)
           (save-excursion
             (beginning-of-line)
             (looking-at yaml-block-literal-re)))
      (insert (cdr extra-chars))
      (newline-and-indent)))))