help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: fill-paragraph / fill region in latex (auctex) buffer


From: Ralf Angeli
Subject: Re: fill-paragraph / fill region in latex (auctex) buffer
Date: Thu, 24 Nov 2005 12:27:05 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

* Stefan Monnier (2005-11-23) writes:

>> In which sense?  That you cannot hook specialized filling functions
>> into `fill-region'?
>
> Either that, or that fill-region doesn't understand the fact that blocks of
> comments are paragraphs (actually fill-paragraph doesn't quite understand
> it either: it only works when you're inside the comment, and even then only
> in some cases).

`fill-region' should probably call a comment-aware function for
filling paragraphs.  I managed to improve this a bit by using
            (if (and fill-paragraph-handle-comment
                     comment-start (equal comment-end "")
                     (setq fill-pfx (fill-comment-paragraph)))
                (goto-char end)
              (setq fill-pfx (fill-region-as-paragraph (point) end justify
                                                       nosqueeze)))
instead of the simple `fill-region-as-paragraph' call (in the else
part of the above form) currently in `fill-region' and making `end' a
marker.  But it would probably make more sense to make
`fill-region-as-paragraph' aware of comments.

Anyway, AUCTeX provides specialized filling functions using
specialized functions for moving forward and backward over paragraphs
and these functions as well as their key bindings are documented in
AUCTeX's manual.  The functions are able to fill paragraphs and
regions with comments correctly and are even capable of doing
syntax-aware indentation inside of comments.

So for the problem at hand the OP should simply use the functions
provided by AUCTeX instead of `fill-region'.  Of course it would be
nice if the specialized function(s) could be hooked into `fill-region'
because then the menu entry `Edit --> Fill' would work as well.

-- 
Ralf


reply via email to

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