# All lines itemized when mark is active

In AUCTeX I would like the behaviour of LaTeX-environment and/or LaTeX-insert-item to create multiple items for every line when called with mark active.

-
To be clear: you want to mark a region and wrap it with an itemize-like environment and put an \item at the beginning of every line? –  giordano Feb 21 at 22:08
Yes. That's exactly what I want. –  Nordlöw Feb 22 at 1:00

If I understood what you want, the following code should do the trick:

(defadvice LaTeX-env-item
(around LaTeX-env-item-region activate)
"When there is an active region, wrap the environment around it.
Insert \\item macros at the beginning of every non empty line of the region."
(let ((beg (min (point) (mark)))
(if (< (point) (mark))
(exchange-point-and-mark))
(save-excursion
(while (re-search-backward "^\$$.+\$$\$" beg t)
(replace-match "\\\\item \\1" t nil)
(beginning-of-line 1))))

This works with all environments inserted with LaTeX-env-item, i.e. enumerate, itemize, trivlist, description, and theindex by default.
BTW: Do you know of any way to automatically insert [<+->] arguments to the itemize environment when I'm in a beamer frame so I get pretty incremental display during presentation? –  Nordlöw Feb 22 at 1:25
@Nordlöw ask a new question, I have already the answer ;-). –  giordano Feb 22 at 11:13