all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [acm@muc.de: Re: bug#193:] Horrible mangling of fill-paragraph
@ 2011-11-27 10:59 Alan Mackenzie
  2011-11-28 16:17 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Mackenzie @ 2011-11-27 10:59 UTC (permalink / raw)
  To: Stefan Monnier, emacs-devel

Hi, Stefan and everybody else.

Bug #193 (summarised in detail below) was a mismatch introduced by an
addition to `fill-paragraph' (revision 48193) made by Stefan.  This
concatenates comment-start onto paragraph-start, which fouls up M-q in C
Mode.

The "solution" at the time was to bypass fill-paragraph and use
fill-region-as-paragraph directly.  Unfortunately, this renders
filladapt mode[*] unworkable.

[*] Kyel E. Jones improved adaptive fill, available at
www.wonderworks.com or the CC Mode website.

My current "solution" to both these problems is a "corrected" version of
fill-region inside CC Mode together with an eval-after-load to put it
into filladapt mode.  This is needed for stand-alone CC Mode, but is
suboptimal for Emacs 24.

Stefan, can you remember the use case for rev 48193?  If not, would it
be OK to revert that bit of it?

-- 
Alan Mackenzie (Nuremberg, Germany).


----- Forwarded message from Alan Mackenzie <acm@muc.de> -----

Date: Tue, 6 Jul 2010 19:29:34 +0000
To: Deniz Dogan <deniz.a.m.dogan@gmail.com>
From: Alan Mackenzie <acm@muc.de>
Cc: 193@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
Subject: Re: bug#193:

On Sun, Jun 27, 2010 at 02:47:52PM +0200, Deniz Dogan wrote:
> Did anyone ever agree on what needs to be done to fix the problem?
 
A quick reminder of what the problem is.  In C mode (NOT C++ mode):
(i) Type M-q in a pair of short line comments like this

// Two short
// lines.

The command ought to join them into a single line comment.  Instead, it
does nothing;

(ii) Type M-q in a line comment which is longer than fill-column:

// A long line comment, which is far far far longer than a moderately or very small fill-column.

This miss-fills by splitting the line, but putting no comment marker on
the new second line:.

// A long line comment, which is far far far longer than a moderately or
very small fill-column.

These bugs are regressions between Emacs 21.4 and 22.1.

#########################################################################

Both these bugs seem to be caused by a strange clause in
`fill-paragraph', where what should be the fill-prefix ("// ") is made
a component of `paragraph-start'.  Thus (ii) every line in the comment
sequence is automatically made into its own paragraph; and (i) when
splitting lines, fill-paragraph doesn't insert the fill-prefix when this
is also a paragraph starter.

Here is the strange code:

     ;; Try to prevent code sections and comment sections from being
     ;; filled together.
     (when (and fill-paragraph-handle-comment comment-start-skip)
       (setq paragraph-start
             (concat paragraph-start "\\|[ \t]*\\(?:"
                     comment-start-skip "\\)")))

In C Mode, `comment-start-skip' is "\\(//+\\|/\\*+\\)\\s *".

The two bugs vanish when the above code is removed.

Stefan, can you remember why you put this code in (revision 48193 of
2008-04-11)?  Is there perhaps a way of achieving the same effect
without making the fill-prefix match `paragraph-start'?

> -- 
> Deniz Dogan

-- 
Alan Mackenzie (Nuremberg, Germany).


----- End forwarded message -----



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

* Re: [acm@muc.de: Re: bug#193:] Horrible mangling of fill-paragraph
  2011-11-27 10:59 [acm@muc.de: Re: bug#193:] Horrible mangling of fill-paragraph Alan Mackenzie
@ 2011-11-28 16:17 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2011-11-28 16:17 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

> Stefan, can you remember the use case for rev 48193?

Of course: it's to make M-q behave better for all those modes that don't
setup their own paragraph filling code.  Without this code, typing M-q
in something like:

    (some code where you type M-q
      some more code
      ;; some comment
      ;; some more comment

may end up filling all 4 lines together into something invalid like

    (some code where you type M-q some more code ;; some comment ;; some
      more comment

> If not, would it be OK to revert that bit of it?

Wouldn't it make sense for CC mode to set fill-paragraph-handle-comment
to nil since CC mode does its own filling of comments anyway?


        Stefan



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

end of thread, other threads:[~2011-11-28 16:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-27 10:59 [acm@muc.de: Re: bug#193:] Horrible mangling of fill-paragraph Alan Mackenzie
2011-11-28 16:17 ` Stefan Monnier

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.