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

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

Re: Filling Block Comment


From: Stefan Monnier
Subject: Re: Filling Block Comment
Date: Tue, 21 Mar 2006 11:53:43 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> (require 'newcomment)
> (setq comment-start "/*")
> (setq comment-end "*/")
> (set (make-local-variable 'fill-paragraph-function)           
> 'fill-comment-paragraph)

> the block comment

> /* xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz */

> is filled as (something like)

> /* xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz
> /* xyz xyz xyz */

> instead of

> /* xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz
> xyz xyz xyz */

Indeed, the filling code doesn't know much about comments and often gets
it wrong.

> How do I make `fill-comment-paragraph' work with block comments?

You don't?
Instead, write your own function that will try to find the beginning/end of
the enclosing comment and then calls fill-region-as-paragraph.

I had started to work on extending fill.el so that it used syntax-tables to
correctly respect comment and string boundaries when filling, but never got
far enough to get something really usable.


        Stefan


reply via email to

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