From: "Herbert Euler" <herberteuler@hotmail.com>
Cc: rms@gnu.org, lennart.borgman.073@student.lu.se,
emacs-devel@gnu.org, bug-cc-mode@gnu.org,
monnier@iro.umontreal.ca, miles@gnu.org
Subject: Re: Fill for // style comments in C
Date: Tue, 28 Nov 2006 20:34:53 +0800 [thread overview]
Message-ID: <BAY112-F25CEDA3238D1234F823AE0DAE50@phx.gbl> (raw)
In-Reply-To: <BAY112-F148E04A82F88FCD0E6B978DAE50@phx.gbl>
How about this?
*** cc-cmds.el.origal Tue Nov 28 20:31:16 2006
--- cc-cmds.el Tue Nov 28 20:30:53 2006
*************** (defun c-mask-paragraph (fill-paragraph
*** 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,3911 ----
(prog1
(save-restriction
(narrow-to-region beg end)
! (let* ((comment-start (save-excursion
! (goto-char (point-min))
! (if (looking-at "//")
! "//"
! comment-start)))
! (comment-end (if (string= comment-start "//")
! ""
! comment-end)))
! (apply fun args)))
(if point-rel
;; Restore point if it was outside the region.
(if (< point-rel 0)
Regards,
Guanpeng Xu
>From: "Herbert Euler" <herberteuler@hotmail.com>
>To: herberteuler@hotmail.com, rudalics@gmx.at
>CC: rms@gnu.org, lennart.borgman.073@student.lu.se, emacs-devel@gnu.org,
>bug-cc-mode@gnu.org, monnier@iro.umontreal.ca, miles@gnu.org
>Subject: Re: Fill for // style comments in C
>Date: Tue, 28 Nov 2006 19:35:59 +0800
>
>I added
>
> (read-string (format "%s" `(apply ,fun ,args)))
>
>before and after invoking `apply':
>
> (prog1
> (save-restriction
> (narrow-to-region beg end)
> (read-string (format "%s" `(apply ,fun ,args)))
> (apply fun args)
> (read-string (format "%s" `(apply ,fun ,args))))
>
>And I put the point in between the following comment and
>pressed M-q:
>
>// A real long comment that will cause the fill command in Emacs
>
>I saw what is actually called is
>
> (apply fill-paragraph (nil))
>
>But the behavior of `fill-paragraph' is not the same as when
>executing with pressing M-x fill-paragraph RET when the
>point is at the same point.
>
>Strange.
>
>Regards,
>Guanpeng Xu
>
>
>>From: "Herbert Euler" <herberteuler@hotmail.com>
>>To: rudalics@gmx.at
>>CC: rms@gnu.org, lennart.borgman.073@student.lu.se,
>>emacs-devel@gnu.org,bug-cc-mode@gnu.org, monnier@iro.umontreal.ca,
>>miles@gnu.org
>>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 <rudalics@gmx.at>
>>>To: Herbert Euler <herberteuler@hotmail.com>
>>>CC: miles@gnu.org, monnier@iro.umontreal.ca, bug-cc-mode@gnu.org,
>>>lennart.borgman.073@student.lu.se, rms@gnu.org, emacs-devel@gnu.org
>>>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/
>>
>>
>>
>>_______________________________________________
>>Emacs-devel mailing list
>>Emacs-devel@gnu.org
>>http://lists.gnu.org/mailman/listinfo/emacs-devel
>
>_________________________________________________________________
>Express yourself instantly with MSN Messenger! Download today it's FREE!
>http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
_________________________________________________________________
Don't just search. Find. Check out the new MSN Search!
http://search.msn.com/
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
next prev parent reply other threads:[~2006-11-28 12:34 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-18 0:09 Fill for // style comments in C Lennart Borgman
2006-11-18 0:29 ` Miles Bader
2006-11-19 12:47 ` Richard Stallman
2006-11-27 2:34 ` Richard Stallman
2006-11-27 6:07 ` Stefan Monnier
2006-11-27 6:34 ` Miles Bader
2006-11-27 7:44 ` Herbert Euler
2006-11-27 9:47 ` martin rudalics
2006-11-27 13:15 ` Herbert Euler
2006-11-28 2:32 ` Miles Bader
2006-11-28 5:19 ` Herbert Euler
2006-11-28 5:58 ` Miles Bader
2006-11-28 6:27 ` Herbert Euler
2006-11-28 21:41 ` martin rudalics
2006-11-29 16:26 ` Richard Stallman
2006-11-29 18:21 ` Stefan Monnier
2006-11-28 8:20 ` Herbert Euler
2006-11-28 11:35 ` Herbert Euler
2006-11-28 12:34 ` Herbert Euler [this message]
2006-11-28 14:13 ` Herbert Euler
2006-11-28 15:31 ` Miles Bader
2006-11-29 3:29 ` Richard Stallman
2006-11-27 8:45 ` Lennart Borgman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BAY112-F25CEDA3238D1234F823AE0DAE50@phx.gbl \
--to=herberteuler@hotmail.com \
--cc=bug-cc-mode@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=lennart.borgman.073@student.lu.se \
--cc=miles@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=rms@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.