5

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}

but instead get

\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?

1
  • What version of Emacs and AucTeX? Does this happen if you temporarily disable all your AucTeX settings? Feb 11, 2011 at 13:12

3 Answers 3

3

In my configuration, it does insert a linebreak when needed.

From Seamus comment, you can see the definition of the insert function, the important part is:

(unless (bolp) (LaTeX-newline))

that checks if you are at a beginning of a line and if not inserts a new line.

You can check your latex.el file to see how it's defined (just click on the filename when it says "LaTeX-insert-item is an interactive Lisp function in `latex.el'."). As Seamus says, redefining it in your .emacs with the code he provides (it's the same in my latex.el) should solve it (unless it's your LaTeX-newline that is broken).

1

Well, here is how LaTeX-insert-item is defined in a version of latex.el I googled up:

(defun 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."
  (interactive "*")
  (let ((environment (LaTeX-current-environment)))
    (when (and (TeX-active-mark)
           (> (point) (mark)))
      (exchange-point-and-mark))
    (unless (bolp) (LaTeX-newline))
    (if (assoc environment LaTeX-item-list)
    (funcall (cdr (assoc environment LaTeX-item-list)))
      (TeX-insert-macro "item"))
    (indent-according-to-mode)))

Would adding this to your .emacs solve the problem? As for why it's gone funny, I've no idea.

1

I had the same problem.

Can you check, wether comment-auto-fill-only-comments is non-nil, ie, t?

Setting this variable to nil made LaTeX-insert-item work for me again.

For reference:

  • LaTeX-insert-item calls LaTeX-newline, as @Mortimer pointed out
  • Under normal circumstances, this will eventually call indent-new-comment-line (alias comment-indent-new-line)
  • This function does nothing if comment-auto-fill-only-comments is non-nil, as the comment states:

    ;; If we are not inside a comment and we only auto-fill comments,
    ;; don't do anything (unless no comment syntax is defined).
    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .