I've recently made this little function:
(defun luctins/rust-continue-comment ()
(interactive)
(if (nth 4 (syntax-ppss))
(let ((co (concat "\n"
(save-match-data
(mwim-beginning-of-line)
(re-search-forward "///?!?" (line-end-position) t 1)
(match-string 0)))))
(if (length> co 0)
(progn (mwim-end-of-line)
(insert co)
(indent-for-tab-command))
(message "failed to match")))))
(define-key rust-mode-map (kbd "C-<return>") 'luctins/rust-continue-comment)
that when called inside a comment, extends the comment type by one line so it's easier to type out long doc comments with line breaks.
How could I make this operate directly on the buffer contents, and not on interactive cursor movements?