emacs-devel
[Top][All Lists]
Advanced

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

Re: Fill for // style comments in C


From: Herbert Euler
Subject: Re: Fill for // style comments in C
Date: Tue, 28 Nov 2006 16:20:01 +0800

In the orignal code,

   (apply 'fill-paragraph '(nil))

will be called both for c-mode and c++-mode.  And if you
put point in between

// A real long comment that will cause the fill command in Emacs making mistakes.

and evaluate

   (apply 'fill-paragraph '(nil))

by pressing M-:, you will see that the comment is refilled
correctly.  CC mode seems doing more than just filling,
but I don't have time to trace now.

Regards,
Guanpeng Xu


From: martin rudalics <address@hidden>
To: Herbert Euler <address@hidden>
CC: address@hidden, address@hidden, address@hidden, address@hidden, address@hidden, address@hidden
Subject: Re: Fill for // style comments in C
Date: Mon, 27 Nov 2006 10:47:29 +0100

> And in c-mode, pressing M-q in between comments like this:
>
> // A real long comment that will cause the fill command in Emacs C mode
> making mistakes.
>
> will get
>
> // A real long comment that will cause the fill command in Emacs C
> mode making mistakes.

It's because `c-fill-paragraph' calls `c-mask-paragraph' the latter
calls `fill-paragraph' and `fill-paragraph' gets it wrong since it has
`comment-end' set to " */" instead of nil.  Does the attached workaround
remove the problem?


*** progmodes/cc-cmds.el        Mon Nov 27 10:32:48 2006
--- progmodes/cc-cmds.el        Mon Nov 27 10:33:20 2006
***************
*** 3897,3903 ****
              (prog1
                  (save-restriction
                    (narrow-to-region beg end)
!                   (apply fun args))
                (if point-rel
                    ;; Restore point if it was outside the region.
                    (if (< point-rel 0)
--- 3897,3905 ----
              (prog1
                  (save-restriction
                    (narrow-to-region beg end)
!                   (if (eq c-lit-type 'c++)
!                       (apply 'fill-comment-paragraph args)
!                     (apply fun args)))
                (if point-rel
                    ;; Restore point if it was outside the region.
                    (if (< point-rel 0)

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! http://search.msn.com/





reply via email to

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