Subject: Re: bug#74056: `LaTeX-insert-item' inserts comment characters if called from inside comment

From: Vangelis Evangelou <[email-masked]>
Date: Tue, 29 Oct 2024 10:08:09 +0000

Hi Ikumi.

Thanks for your reply.

I suggest to set the customize option `LaTeX-insert-into-comments' to
> nil. You will get the expected behavior then.

That is correct. Effectively `LaTeX-newline' calls `newline' if the above
is nil. I thought to avoid the middleman and call `newline' directly, but I
recognise that there are situations, e.g., editing dtx files, where the
current behaviour is desirable. On that note, I wonder whether
`LaTeX-insert-into-comments' should be made a buffer-local variable so it
is set accordingly in various modes. I know that this can be achieved with
`setq-local' so it's not a major issue.

I'd like to confirm your intention. It seems that you are saying that
> "When I type M-RET in a line with only whitespace charactares, the \item
> shoule be placeed in that line, not the line created anew below that
> line."

That is correct.

Best,
Vangelis

On Tue, 29 Oct 2024 at 06:44, Ikumi Keita <[email-masked]> wrote:

> Hi Vangelis,
>
> >>>>> Vangelis Evangelou <[email-masked]> writes:
> > Hello.
> > Consider the following latex snippet with the cursor position indicated
> by
> > |:
>
> > \begin{itemize}
> > \item My 1st item %%% comment |
> > \end{itemize}
>
> > At that point call `LaTeX-insert-item' (M-RET) to get the following:
>
> > \begin{itemize}
> > \item My 1st item %%% comment
> >   %%% \item |
> > \end{itemize}
>
> > while I would have expected
>
> > \begin{itemize}
> > \item My 1st item %%% comment
> > \item |
> > \end{itemize}
>
> I suggest to set the customize option `LaTeX-insert-into-comments' to
> nil. You will get the expected behavior then.
>
> I'd say that the default value of t of `LaTeX-insert-into-comments' is
> one of the strangest defaults of AUCTeX :-)
>
> > I cannot think of a situation where the current version is desirable.
>
> It seems that it will be useful in docTeX mode. But I personally agree
> that it isn't in most LaTeX documents.
>
> To developers: I propose to change the default value of
> `LaTeX-insert-into-comments' to nil. What do you think about it? It is
> set to t in docTeX mode anyway.
>
> > In addition to the above, `LaTeX-insert-item' always inserts a new line
> > unless the cursor is at the beginning of line:
>
> > (unless (bolp) (LaTeX-newline))
>
> > This is rarely the case. For example, if you enter a new line inside
> > itemize, the line is indented. It would be better to replace the (bolp)
> > check with a check that the line contains only whitespace characters.
>
> I'd like to confirm your intention. It seems that you are saying that
> "When I type M-RET in a line with only whitespace charactares, the \item
> shoule be placeed in that line, not the line created anew below that
> line." If so, I think it is a reasonable request.
>
> Regards,
> Ikumi Keita
> #StandWithUkraine #StopWarInUkraine
> #Gaza #StopMassiveKilling #CeasefireNOW
>