bug-auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-AUCTeX] 11.81; commenting error in DocTeX mode


From: Ralf Angeli
Subject: Re: [Bug-AUCTeX] 11.81; commenting error in DocTeX mode
Date: Fri, 30 Dec 2005 17:02:13 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

* Frank Küster (2005-12-30) writes:

> Ralf Angeli <address@hidden> wrote:
>
>> * Frank Küster (2005-12-29) writes:
>>
>>> I'm editing a dtx file that ends like this:
>> [...]
>>> %  \HistVersion{2002/05/10 v1.0}
>>> %    \begin{itemize}
>> [...]
>>> With transient-mark-mode enabled, I set a mark at the \ before
>>> HistVersion and moved point one line down; then I pressed M-;
>>> (comment-dwim).  This is what I get:
>> [...]
>>> %  % \HistVersion{2002/05/10 v1.0}
>>> % %  
>>> \begin{itemize}
>> [...]
>>> This is what I mean ;-):
>> [...]
>>> %  % \HistVersion{2002/05/10 v1.0}
>>> % %  
>>> %    \begin{itemize}
>>
>> Don't you rather mean
>> %  ^^A \HistVersion{2002/05/10 v1.0}
>> %    \begin{itemize}
>> ?
>
> Err, yes, I guess.  I'm never sure which comments are stripped (or
> rather I always tend to think that comment signs separated by more than
> one whitespace are kept, and forget the special comment sign), but
> moving a line from the documentation part to the implementation part is
> clearly wrong.

Okay, I looked at this and saw that the newline is inserted in
`comment-region-internal', that means a function in Emacs, not in
AUCTeX.  Here is the relevant code:

      ;; If the end is not at the end of a line and the comment-end
      ;; is implicit (i.e. a newline), explicitly insert a newline.
      (unless (or ce (eolp)) (insert "\n") (indent-according-to-mode))

I thought about writing to emacs-devel that instead of `(insert "\n")'
something like `(indent-new-comment-line)' should be used, but
thinking about the purpose of `comment-region' I think it would not
make much sense because the function cannot handle the insertion of
comment starters in prefixed lines anyway.  Suppose you have the lines

% a
% b

with mark just before the "a" and point at the start of the line below
the line with "% b".  `comment-region' will try to comment this as
regular text but in fact it is inserting comment starters in an
already commented region which is nonsensical (putting aside the case
where you want to comment whole lines of comments and normal
text/code).  The result will be

% % a
% % b

which looks quite sane.  But let's mark the inserted stuff with
brackets:

% [% ]a
[% ]% b

You can see that in lines of the region other than the first one
comment starters will be added to the start of the line which is of
course not what we want in docTeX mode.  What we need would be

% [% ]a
% [% ]b

but `comment-region' is not capable of handling that.

Okay, back to your problem.  If `(indent-new-comment-line)' was used
instead of `(insert "\n")' the result in your example would be

%  % \HistVersion{2002/05/10 v1.0}
% %
% %  \begin{itemize}
%    \item First standalone version.

Not really better than before.  So for now it would probably be better
to simply avoid using the comment and uncomment functions inside of
documentation parts (i.e. with point behind the line prefix) in docTeX
mode.

-- 
Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]