GNU bug report logs -
#74056
`LaTeX-insert-item' inserts comment characters if called from inside comment
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 74056 in the body.
You can then email your comments to 74056 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-auctex <at> gnu.org
:
bug#74056
; Package
auctex
.
(Mon, 28 Oct 2024 09:42:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Vangelis Evangelou <evangelou <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-auctex <at> gnu.org
.
(Mon, 28 Oct 2024 09:42:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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 cannot think of a situation where the current version is desirable.
This happens because `LaTeX-insert-item' inserts a new line using
`LaTeX-newline' instead of `TeX-newline.
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. So my
proposal is to replace the above line with
(unless (string-match-p "^[[:blank:]]*$" (buffer-substring-no-properties
(line-beginning-position) (line-end-position))) (TeX-newline))
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#74056
; Package
auctex
.
(Mon, 28 Oct 2024 17:17:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 74056 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Correction: Instead of `LaTeX-newline' use `newline'. In my original
message I said to use `TeX-newline'. So the proposal is
(unless (string-match-p "^[[:blank:]]*$" (buffer-substring-no-properties
(line-beginning-position) (line-end-position))) (newline))
On Mon, 28 Oct 2024 at 09:40, Vangelis Evangelou <evangelou <at> gmail.com>
wrote:
> 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 cannot think of a situation where the current version is desirable.
>
> This happens because `LaTeX-insert-item' inserts a new line using
> `LaTeX-newline' instead of `TeX-newline.
>
> 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. So my
> proposal is to replace the above line with
>
> (unless (string-match-p "^[[:blank:]]*$" (buffer-substring-no-properties
> (line-beginning-position) (line-end-position))) (TeX-newline))
>
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#74056
; Package
auctex
.
(Tue, 29 Oct 2024 06:45:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 74056 <at> debbugs.gnu.org (full text, mbox):
Hi Vangelis,
>>>>> Vangelis Evangelou <evangelou <at> gmail.com> 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
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#74056
; Package
auctex
.
(Tue, 29 Oct 2024 10:10:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 74056 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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 <ikumi <at> ikumi.que.jp> wrote:
> Hi Vangelis,
>
> >>>>> Vangelis Evangelou <evangelou <at> gmail.com> 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
>
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#74056
; Package
auctex
.
(Tue, 29 Oct 2024 10:23:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 74056 <at> debbugs.gnu.org (full text, mbox):
Hi Keita,
Ikumi Keita <ikumi <at> ikumi.que.jp> writes:
> 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.
What do think about adding ":safe #'booleanp" to the `defcustom'? That
way, people can set the global value via customize and change the
behavior on per file basis.
> 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.
+1
Best, Arash
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#74056
; Package
auctex
.
(Tue, 29 Oct 2024 11:01:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 74056 <at> debbugs.gnu.org (full text, mbox):
>>>>> Vangelis Evangelou <evangelou <at> gmail.com> writes:
> 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.
If you are talking about the implementation of the major modes in
AUCTeX, it isn't a problem as you say.
> 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.
Thanks for confirmation. Then I'll work on that direction.
>>>>> Arash Esbati <arash <at> gnu.org> writes:
> What do think about adding ":safe #'booleanp" to the `defcustom'? That
> way, people can set the global value via customize and change the
> behavior on per file basis.
Ah, that's a good idea. Does the change below look good? (I refilled the
doc string as well.)
diff --git a/latex.el b/latex.el
index 02fd1e33..9f767f99 100644
--- a/latex.el
+++ b/latex.el
@@ -66,12 +66,13 @@ A comma-seperated list of strings."
(make-variable-buffer-local 'LaTeX-default-options)
-(defcustom LaTeX-insert-into-comments t
+(defcustom LaTeX-insert-into-comments nil
"Whether insertion commands stay in comments.
-This allows using the insertion commands even when
-the lines are outcommented, like in dtx files."
+This allows using the insertion commands even when the lines are
+outcommented, like in dtx files."
:group 'LaTeX-environment
- :type 'boolean)
+ :type 'boolean
+ :safe #'booleanp)
(defcustom docTeX-indent-across-comments nil
"If non-nil, indentation in docTeX is done across comments."
Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#74056
; Package
auctex
.
(Tue, 29 Oct 2024 11:45:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 74056 <at> debbugs.gnu.org (full text, mbox):
Ikumi Keita <ikumi <at> ikumi.que.jp> writes:
> Ah, that's a good idea. Does the change below look good? (I refilled the
> doc string as well.)
>
> diff --git a/latex.el b/latex.el
> index 02fd1e33..9f767f99 100644
> --- a/latex.el
> +++ b/latex.el
> @@ -66,12 +66,13 @@ A comma-seperated list of strings."
>
> (make-variable-buffer-local 'LaTeX-default-options)
>
> -(defcustom LaTeX-insert-into-comments t
> +(defcustom LaTeX-insert-into-comments nil
> "Whether insertion commands stay in comments.
> -This allows using the insertion commands even when
> -the lines are outcommented, like in dtx files."
> +This allows using the insertion commands even when the lines are
> +outcommented, like in dtx files."
> :group 'LaTeX-environment
> - :type 'boolean)
> + :type 'boolean
> + :safe #'booleanp)
Thanks, :package-version '(auctex . "14.0.8") is missing, and also an
entry in NEWS.org. And while we're at it, should we document the
variable in the manual and take this from the ToDo-list[1], WDYT?
Best, Arash
Footnotes:
[1] https://elpa.gnu.org/devel/doc/auctex.html#Mid_002dterm-Goals
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#74056
; Package
auctex
.
(Thu, 31 Oct 2024 09:50:01 GMT)
Full text and
rfc822 format available.
Message #26 received at 74056 <at> debbugs.gnu.org (full text, mbox):
Hi Arash,
>>>>> Arash Esbati <arash <at> gnu.org> writes:
> Thanks, :package-version '(auctex . "14.0.8") is missing, and also an
> entry in NEWS.org. And while we're at it, should we document the
> variable in the manual and take this from the ToDo-list[1], WDYT?
I added updates to documentation as well. How about this? (I'm thinking
to install `LaTeX-insert-item' change as a separate commit.)
diff --git a/NEWS.org b/NEWS.org
index b5a4bb91..28371831 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -30,6 +30,11 @@
- Add preliminary support for parsing =\graphicspath= in
=style/graphicx.el=.
+** Changed
+
+- Change the default value of ~LaTeX-insert-into-comments~ from ~t~ to
+ ~nil~.
+
* [14.0.7] - 2024-10-05
** Added
diff --git a/doc/auctex.texi b/doc/auctex.texi
index 718d4c2a..86913ef4 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -1616,6 +1616,22 @@ paragraph is considered to consist of all preceding and succeeding
lines starting with a @samp{%}, until the first non-comment line.
@end deffn
+In doc <at> TeX{} document, all documentations are commented out. @AUCTeX{}
+inserts @samp{%} (with a space after it) at the beginning of line when
+you issue some commands including sectioning (@kbd{C-c C-s}) and inserting
+environments (@kbd{C-c C-e}), on a commented line. This behavior is
+controlled by @code{LaTeX-insert-into-comments}.
+
+@defopt LaTeX-insert-into-comments
+When this option is non-@code{nil}, some editing comments are aware of
+comment prefix at the beginning of line and insert it in the line created
+anew.
+
+The default value of this option used to be @code{t}, which caused several
+unintuitive behavior in normal @LaTeX{} mode. Now it defaults to
+@code{nil} and set to @code{t} in doc <at> TeX{} mode.
+@end defopt
+
@node Indenting
@section Indenting
@cindex Formatting
diff --git a/doc/todo.texi b/doc/todo.texi
index d144ba72..825e21aa 100644
--- a/doc/todo.texi
+++ b/doc/todo.texi
@@ -78,7 +78,7 @@ texinfo mode.)
Following entries should be included in the document:
@itemize @minus
@item
-Variables @code{LaTeX-insert-into-comments}, @code{TeX-translate-location-hook}
+Variable @code{TeX-translate-location-hook}
@item
How to use @code{TeX-auto-add-type}, as well as functions and variables
diff --git a/latex.el b/latex.el
index 02fd1e33..554865ab 100644
--- a/latex.el
+++ b/latex.el
@@ -66,12 +66,14 @@ A comma-seperated list of strings."
(make-variable-buffer-local 'LaTeX-default-options)
-(defcustom LaTeX-insert-into-comments t
+(defcustom LaTeX-insert-into-comments nil
"Whether insertion commands stay in comments.
-This allows using the insertion commands even when
-the lines are outcommented, like in dtx files."
+This allows using the insertion commands even when the lines are
+outcommented, like in dtx files."
:group 'LaTeX-environment
- :type 'boolean)
+ :type 'boolean
+ :safe #'booleanp
+ :package-version '(auctex . "14.0.8"))
(defcustom docTeX-indent-across-comments nil
"If non-nil, indentation in docTeX is done across comments."
@@ -1533,7 +1535,14 @@ You may use `LaTeX-item-list' to change the routines used to insert the item."
(when (and (TeX-active-mark)
(> (point) (mark)))
(exchange-point-and-mark))
- (unless (bolp) (LaTeX-newline))
+ (if (save-excursion
+ ;; If the current line has only whitespace characters, put
+ ;; the new \item on this line, not creating a new line
+ ;; below.
+ (goto-char (line-beginning-position))
+ (looking-at "\\s-*$"))
+ (delete-region (point) (match-end 0))
+ (LaTeX-newline))
(if (assoc environment LaTeX-item-list)
(funcall (cdr (assoc environment LaTeX-item-list)))
(TeX-insert-macro "item"))
Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#74056
; Package
auctex
.
(Fri, 01 Nov 2024 07:26:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 74056 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi Arash and Vangelis,
>>>>> Vangelis Evangelou <evangelou <at> gmail.com> writes:
> There is a typo: "When this option is non-@code{nil}, some editing
> comments are aware of". "comments" -> "commands"
Thanks 😊
I attach the current patches.
Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW
[0001-Change-default-of-LaTeX-insert-into-comments-bug-740.patch (text/x-diff, attachment)]
[0002-Improve-insertion-of-item-bug-74056.patch (text/x-diff, attachment)]
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#74056
; Package
auctex
.
(Fri, 01 Nov 2024 08:27:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 74056 <at> debbugs.gnu.org (full text, mbox):
Hi Keita,
Ikumi Keita <ikumi <at> ikumi.que.jp> writes:
> I attach the current patches.
Thanks, I have 2 minor comments, see below.
> diff --git a/doc/auctex.texi b/doc/auctex.texi
> index 718d4c2a..fb20c817 100644
> --- a/doc/auctex.texi
> +++ b/doc/auctex.texi
> @@ -1616,6 +1616,22 @@ paragraph is considered to consist of all preceding and succeeding
> lines starting with a @samp{%}, until the first non-comment line.
> @end deffn
>
> +In doc <at> TeX{} document, all documentations are commented out. @AUCTeX{}
> +inserts @samp{%} (with an accompanying space) at the beginning of line
> +when you issue some commands including sectioning (@kbd{C-c C-s}) and
> +inserting environments (@kbd{C-c C-e}), on a commented line. This
> +behavior is controlled by @code{LaTeX-insert-into-comments}.
> +
> +@defopt LaTeX-insert-into-comments
> +When this option is non-@code{nil}, some editing commands are aware of
> +comment prefix at the beginning of line and insert it in the line created
> +anew.
> +
> +The default value of this option used to be @code{t}, which sometimes
> +caused unintuitive behaviors in normal @LaTeX{} mode. Now it defaults to
> +@code{nil} and is set to @code{t} in doc <at> TeX{} mode.
> +@end defopt
> +
I don't think we need to talk about the history in the manual. I
suggest to change the last paragraph to something like this:
The default value of this option is @code{nil} in normal @LaTeX{} mode
and is set to @code{t} in doc <at> TeX{} mode.
Reg. your other patch: Does it need an ERT-test?
Best, Arash
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#74056
; Package
auctex
.
(Sat, 02 Nov 2024 09:12:01 GMT)
Full text and
rfc822 format available.
Message #35 received at 74056 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi Arash,
>>>>> Arash Esbati <arash <at> gnu.org> writes:
> Thanks, I have 2 minor comments, see below.
> I don't think we need to talk about the history in the manual. I
> suggest to change the last paragraph to something like this:
> The default value of this option is @code{nil} in normal @LaTeX{} mode
> and is set to @code{t} in doc <at> TeX{} mode.
OK. I've further simplified.
> Reg. your other patch: Does it need an ERT-test?
I think it's better to have one. I added.
Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW
[0001-Change-default-of-LaTeX-insert-into-comments-bug-740.patch (text/x-diff, attachment)]
[0002-Improve-insertion-of-item-bug-74056.patch (text/x-diff, attachment)]
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#74056
; Package
auctex
.
(Sun, 03 Nov 2024 10:18:02 GMT)
Full text and
rfc822 format available.
Message #38 received at 74056 <at> debbugs.gnu.org (full text, mbox):
Hi Keita,
Ikumi Keita <ikumi <at> ikumi.que.jp> writes:
>>>>>> Arash Esbati <arash <at> gnu.org> writes:
>> Thanks, I have 2 minor comments, see below.
>
>> I don't think we need to talk about the history in the manual. I
>> suggest to change the last paragraph to something like this:
>
>> The default value of this option is @code{nil} in normal @LaTeX{} mode
>> and is set to @code{t} in doc <at> TeX{} mode.
>
> OK. I've further simplified.
>
>> Reg. your other patch: Does it need an ERT-test?
>
> I think it's better to have one. I added.
LGTM, thanks. Please go ahead and push them.
Best, Arash
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#74056
; Package
auctex
.
(Sun, 03 Nov 2024 15:01:02 GMT)
Full text and
rfc822 format available.
Message #41 received at 74056 <at> debbugs.gnu.org (full text, mbox):
>>>>> Arash Esbati <arash <at> gnu.org> writes:
> LGTM, thanks. Please go ahead and push them.
Thanks, I did. I'll close this bug.
Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW
bug closed, send any further explanations to
74056 <at> debbugs.gnu.org and Vangelis Evangelou <evangelou <at> gmail.com>
Request was from
Ikumi Keita <ikumi <at> ikumi.que.jp>
to
control <at> debbugs.gnu.org
.
(Sun, 03 Nov 2024 15:03:03 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 02 Dec 2024 12:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 277 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.