# emacs / AuCTeX and itemize

I am having an issue with my newline's within itemized lists in AucTex mode of Emacs. If I do, C-c C-e RET itemize RET, I expect the following

\begin{itemize}
\item
\end{itemize}


\begin{itemize}\item
\end{itemize}


Additionally, when I do C-c C-j at the end of an item, it just gives me a new \item without putting me on an new line. So, C-h k C-c C-j reveals

C-c C-j runs the command LaTeX-insert-item, which is an interactive
compiled Lisp function in latex.el'.

It is bound to C-c C-j, M-RET, <menu-bar> <LaTeX> <Item>.

(LaTeX-insert-item)

Insert a new item in an environment.
You may use LaTeX-item-list' to change the routines used to insert the item.


So, it seems that my LaTeX-insert-item is somehow broken? How can I recover the correct C-c C-j behaviour?

-

## migrated from stackoverflow.comMay 22 '11 at 22:08

This question came from our site for professional and enthusiast programmers.

I know this is an old issue, but I recently got into the same problem.

Following Tyler's advice, I found that the problem was caused by (setq comment-auto-fill-only-comments t) in my init.el. This line was inside of emacs-lisp-mode-hook, but the variable was set globally. Either setting comment-auto-fill-only-comment to nil or making it buffer-local (to other buffers) solved this problem.

I also found a thread in AUCTeX mailing list discussing this problem.

-

Step 1: close Emacs completely and start it up again. This will fix the problem if it was caused by you inadvertently changing some setting/variable.

Step 2: if that didn't work:

comment out everything in your .emacs except for the line loading AUCTeX. In my case, the line is:

(load "auctex.el" nil t t)


The command

M-;


will comment-out everything in the active region. It will also uncomment everything in the region, if it is already commented, so you'll want to use that rather than manually adding a whole pile of ;;.

Following step 2, you should have an unmodified version of Emacs + AUCTeX, so you should have the correct behaviour back. This will confirm that the problem is something in your .emacs file conflicting with AUCTeX. If the problem persists, it may be a bug in AUCTeX, although that seems unlikely for such a commonly-used feature.

Step 3: Uncomment more of your .emacs, and restart. If the problem returns, it was caused by the now-uncommented code. If it doesn't, repeat the process until you find the code that triggers the problem.

Step 4: solve the problem yourself, or ask another question about the specific code that you discovered that caused the conflict.

-
I suppose that's a conductive way to solve the problem. –  phimuemue Feb 3 '11 at 16:43
(defadvice LaTeX-insert-item (around my-LaTeX-insert-item activate) (let ((LaTeX-insert-into-comments nil)) ad-do-it)) I found that from an earlier question I had asked, which fixes the problem. –  stevejb Feb 3 '11 at 23:18
I'm glad that resolves your problem! defadvice is a little tricky, though. You may be papering over some other issue in your .emacs that is the actual source of the problem. The defadvice is increasing the complexity of your config, which may come back to bite you in the future if the defadvice, or the original problem, interacts with some other function. –  Tyler Feb 3 '11 at 23:37

I found this earlier question I had asked on a very similar issue.

(defadvice LaTeX-insert-item (around my-LaTeX-insert-item activate)