Function: zig-ts--comment-indent-new-line

zig-ts--comment-indent-new-line is a natively compiled function defined in zig-ts-mode.el.

Signature

(zig-ts--comment-indent-new-line &optional SOFT)

Documentation

Break line at point and indent, continuing comment if within one.

SOFT works the same as in comment-indent-new-line.

Source Code

;; Defined in /nix/store/jxyx97fhclw4jb395hn97pz60n2rh0hs-emacs-packages-deps/share/emacs/site-lisp/elpa/zig-ts-mode-20260921.1554/zig-ts-mode.el
;;;; Comment continuation (M-j)

(defun zig-ts--comment-indent-new-line (&optional soft)
  "Break line at point and indent, continuing comment if within one.
SOFT works the same as in `comment-indent-new-line'."
  (let* ((pos (point))
         (state (syntax-ppss))
         (prefix
          (save-excursion
            (cond
             ((nth 4 state)
              (goto-char (nth 8 state))
              (when (looking-at (rx "//" (* (any "/!")) (* blank)))
                (cons (current-column) (match-string-no-properties 0))))
             ((and (nth 3 state)
                   (equal (treesit-node-type
                           (treesit-node-at (max (point-min) (1- pos))))
                          "multiline_string"))
              (goto-char (nth 8 state))
              (when (looking-at (rx "\\\\" (* blank)))
                (cons (current-column) (match-string-no-properties 0))))))))
    (delete-horizontal-space)
    (if soft (insert-and-inherit ?\n) (newline 1))
    (if prefix
        (progn (indent-to (car prefix)) (insert (cdr prefix)))
      (indent-according-to-mode))))