Emacs has a function called indent-region
and some similar functions, which insert some predefined string at the beginning of the lines within the selected region.
Instead, I want an interactive function that inserts a string given by user input at the beginning of the lines within the selected region. What emacs-lisp code can do this?
Easiest way to do this is to make use of a rectangle.
It's kind of difficult to present, but basically you can use C-x r t
to insert a text on each line of a rectangle. You make a rectangle by starting with the pointer at, say, line 1, C-Space, move cursor down the amount of lines you want, and hit C-x r t
following by entering the text.
Here's the documentation.