all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* fill-paragraph / fill region in latex (auctex) buffer
@ 2005-11-14 19:25 David Reitter
  0 siblings, 0 replies; 6+ messages in thread
From: David Reitter @ 2005-11-14 19:25 UTC (permalink / raw)


When I do fill-paragraph on a long line that starts with a %, the  
line is correctly wrapped and a % is added in front of each line.
This is in latex-mode (AUCTeX).

fill-paragraph-function is nil.

When I select a region with the same text, the behavior is different  
- no %'s are inserted, and I get an undesirable result.
This is annoying, because I would want to use fill-region on a whole  
buffer in order to wrap lines, and it turns all the commented out  
stuff into text that appears in my latex document...

Is this a bug?
If so, is it due to Emacs or to AUCTeX?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fill-paragraph / fill region in latex (auctex) buffer
       [not found] <mailman.15243.1131996330.20277.help-gnu-emacs@gnu.org>
@ 2005-11-22 20:17 ` Stefan Monnier
  2005-11-22 21:14   ` Ralf Angeli
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2005-11-22 20:17 UTC (permalink / raw)


> When I select a region with the same text, the behavior is different  - no
> %'s are inserted, and I get an undesirable result.
> This is annoying, because I would want to use fill-region on a whole  buffer
> in order to wrap lines, and it turns all the commented out  stuff into text
> that appears in my latex document...

> Is this a bug?

Yes.

> If so, is it due to Emacs or to AUCTeX?

Emacs.


        Stefan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fill-paragraph / fill region in latex (auctex) buffer
  2005-11-22 20:17 ` fill-paragraph / fill region in latex (auctex) buffer Stefan Monnier
@ 2005-11-22 21:14   ` Ralf Angeli
  2005-11-23  7:20     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Ralf Angeli @ 2005-11-22 21:14 UTC (permalink / raw)


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

>> When I select a region with the same text, the behavior is different  - no
>> %'s are inserted, and I get an undesirable result.
>> This is annoying, because I would want to use fill-region on a whole  buffer
>> in order to wrap lines, and it turns all the commented out  stuff into text
>> that appears in my latex document...
>
>> Is this a bug?
>
> Yes.
>
>> If so, is it due to Emacs or to AUCTeX?
>
> Emacs.

In which sense?  That you cannot hook specialized filling functions
into `fill-region'?

-- 
Ralf

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fill-paragraph / fill region in latex (auctex) buffer
  2005-11-22 21:14   ` Ralf Angeli
@ 2005-11-23  7:20     ` Stefan Monnier
  2005-11-24 11:27       ` Ralf Angeli
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2005-11-23  7:20 UTC (permalink / raw)


>>> When I select a region with the same text, the behavior is different  - no
>>> %'s are inserted, and I get an undesirable result.
>>> This is annoying, because I would want to use fill-region on a whole  buffer
>>> in order to wrap lines, and it turns all the commented out  stuff into text
>>> that appears in my latex document...
>> 
>>> Is this a bug?
>> Yes.
>>> If so, is it due to Emacs or to AUCTeX?
>> Emacs.
> 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).


        Stefan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fill-paragraph / fill region in latex (auctex) buffer
  2005-11-23  7:20     ` Stefan Monnier
@ 2005-11-24 11:27       ` Ralf Angeli
  2005-11-25  4:20         ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Ralf Angeli @ 2005-11-24 11:27 UTC (permalink / raw)


* 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fill-paragraph / fill region in latex (auctex) buffer
  2005-11-24 11:27       ` Ralf Angeli
@ 2005-11-25  4:20         ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2005-11-25  4:20 UTC (permalink / raw)


> 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.

I don't think so: fill-region-as-paragraph is really the function that fills
"one paragraph".  So to handle comments, the most important part is to
change fill-region so as to recognize that blocks of comments are paragraphs
on their own.  I.e. it's the forward-paragraph and backward-paragraph
functionality that needs to be made aware of comments (and strings,
incidentally).  Tho I'm unsure about the M-{ and M-} part: fill.el should
maybe have its notion of paragraphs.

> 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.

I'd rather add something like fill-paragraph-forward-function should could
then be used both by fill-region and by fill-paragraph.


        Stefan

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-11-25  4:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.15243.1131996330.20277.help-gnu-emacs@gnu.org>
2005-11-22 20:17 ` fill-paragraph / fill region in latex (auctex) buffer Stefan Monnier
2005-11-22 21:14   ` Ralf Angeli
2005-11-23  7:20     ` Stefan Monnier
2005-11-24 11:27       ` Ralf Angeli
2005-11-25  4:20         ` Stefan Monnier
2005-11-14 19:25 David Reitter

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.