GNU bug report logs -
#69398
`LaTeX-fill-paragraph` behavior within indented environments
Previous Next
To reply to this bug, email your comments to 69398 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-auctex <at> gnu.org
:
bug#69398
; Package
auctex
.
(Mon, 26 Feb 2024 00:22:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Ruiyang Wu <ywwry66 <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-auctex <at> gnu.org
.
(Mon, 26 Feb 2024 00:22:03 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)]
Hi there,
When the point is on the first letter of a line inside an indented environment (e.g., itemize, proof, etc.), running `LaTeX-fill-paragraph` will move the point to the beginning of the line. Here is a MWE:
\documentclass{article}
\begin{document}
\begin{itemize}
\item In indented environments, when the point is at the first letter
of a line, running ``LaTeX-fill-paragraph'' will move the point to
the beginning of the line. Ideally, it should stay with the letter.
\end{itemize}
\end{document}
1. If the point is on the first “o” in the line immediately after “\item”, running `LaTeX-fill-paragraph` moves the point to column 0, while “o” is moved to column 2 because of the filling operation.
2. If the point is on the first “f” in the same line as above, the point stays on “f” after running `LaTeX-fill-paragraph` (both moved to column 3).
I think it is better to have consistent point behavior as in scenario 2, because users probably want to continue editing after running `M-q’, and it is much more efficient if the point stays on the same letter before and after filling.
Best,
Ruiyang
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#69398
; Package
auctex
.
(Sun, 03 Mar 2024 08:43:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 69398 <at> debbugs.gnu.org (full text, mbox):
Hi Ruiyang,
>>>>> Ruiyang Wu <ywwry66 <at> gmail.com> writes:
> Hi there,
> When the point is on the first letter of a line inside an indented environment (e.g., itemize, proof, etc.), running `LaTeX-fill-paragraph` will move the point to the beginning of the line. Here is a MWE:
> \documentclass{article}
> \begin{document}
> \begin{itemize}
> \item In indented environments, when the point is at the first letter
> of a line, running ``LaTeX-fill-paragraph'' will move the point to
> the beginning of the line. Ideally, it should stay with the letter.
> \end{itemize}
> \end{document}
> 1. If the point is on the first “o” in the line immediately after “\item”, running `LaTeX-fill-paragraph` moves the point to column 0, while “o” is moved to column 2 because of the filling operation.
> 2. If the point is on the first “f” in the same line as above, the point stays on “f” after running `LaTeX-fill-paragraph` (both moved to column 3).
> I think it is better to have consistent point behavior as in scenario 2, because users probably want to continue editing after running `M-q’, and it is much more efficient if the point stays on the same letter before and after filling.
Sorry for late response. I confirmed what you reported (with fill-column
being 70) and had brief look at the relevant code. Unfortunately, the
code uses `save-excursion' to preserve the point, so it seems that
something very exceptional is happening. I'll try to figure out the
origin and fix it, but it can take a non trivial span of time. :-(
Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#69398
; Package
auctex
.
(Sun, 03 Mar 2024 14:46:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 69398 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi Ikumi,
Thanks for the reply and please take your time.
Best,
Ruiyang
> On Mar 3, 2024, at 3:41 AM, Ikumi Keita <ikumi <at> ikumi.que.jp> wrote:
>
> Hi Ruiyang,
>
> Sorry for late response. I confirmed what you reported (with fill-column
> being 70) and had brief look at the relevant code. Unfortunately, the
> code uses `save-excursion' to preserve the point, so it seems that
> something very exceptional is happening. I'll try to figure out the
> origin and fix it, but it can take a non trivial span of time. :-(
>
> Regards,
> Ikumi Keita
> #StandWithUkraine #StopWarInUkraine
> #Gaza #StopMassiveKilling #CeasefireNOW
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#69398
; Package
auctex
.
(Wed, 06 Mar 2024 15:50:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 69398 <at> debbugs.gnu.org (full text, mbox):
Hi Ruiyang,
>>>>> Ruiyang Wu <ywwry66 <at> gmail.com> writes:
> Hi Ikumi,
> Thanks for the reply and please take your time.
I figured out the reason but haven't come up with a satisfactory
solution.
[Basis]
The elisp function `save-excursion' uses marker internally to keep track
of the original position.
[Analysis]
,----
| \documentclass{article}
|
| \begin{document}
| \begin{itemize}
| \item In indented environments, when the point is at the first letter
| of a line, running ``LaTeX-fill-paragraph'' will move the point to
| the beginning of the line. Ideally, it should stay with the letter.
| \end{itemize}
| \end{document}
`----
During the course of the filling, in `LaTeX-indent-outer-do', the line
in question once loses its indent:
,----
| \item In indented environments, when the point is at the first letter
| of a line, running ``LaTeX-fill-paragraph'' will move the point to the beginning of the line. Ideally, it should stay with the letter.
| \end{itemize}
`----
At this time, the marker locates at the "correct" position, namely at
the first "o" in the line immediately after "item". In other words, it
is at the beginning of the line immediately after "item".
Then `LaTeX-indent-outer-do' calls `indent-to', which inserts
whitespaces, to give the correct indentation. However, this insertion is
done at the position of the marker that the `save-excursion' uses. This
means that emacs doesn't send the marker after the inserted whitespaces
because that's the default behavior of emacs. Therefore, the marker
stays at the beginning of the line and the point is moved to that
marker position after M-q finishes, rather than the position after the
indentation.
[Solution?]
We can work around this particular example by replacing
(save-excursion
...)
in `LaTeX-fill-paragraph' with
(let ((m (point-marker)))
(set-marker-insertion-type m t) ; Send marker after the inserted text.
...
(goto-char m)
(set-marker m nil))
, but I'm not sure this is the right thing to do:
1. This wouldn't match with behavior with other filling functions.
2. Even if we tweak all such occurences of `save-excursion', it isn't
clear whether it is right that the position always "sticks" to the
letter where before M-q is typed.
Does anyone find a good solution?
Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW
This bug report was last modified 1 year and 100 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.