From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Herbert Euler" Newsgroups: gmane.emacs.cc-mode.general,gmane.emacs.devel Subject: Re: Fill for // style comments in C Date: Tue, 28 Nov 2006 22:13:10 +0800 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1164723221 6859 80.91.229.2 (28 Nov 2006 14:13:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 28 Nov 2006 14:13:41 +0000 (UTC) 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 Original-X-From: cc-mode-help-bounces@lists.sourceforge.net Tue Nov 28 15:13:34 2006 Return-path: Envelope-to: sf-cc-mode-help@m.gmane.org Original-Received: from lists-outbound.sourceforge.net ([66.35.250.225]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Gp3iE-0004qh-2j for sf-cc-mode-help@m.gmane.org; Tue, 28 Nov 2006 15:13:30 +0100 Original-Received: from sc8-sf-list1-new.sourceforge.net (unknown [10.3.1.93]) by sc8-sf-spam2.sourceforge.net (Postfix) with ESMTP id 61E7912559; Tue, 28 Nov 2006 06:13:29 -0800 (PST) Original-Received: from sc8-sf-mx1-b.sourceforge.net ([10.3.1.91] helo=mail.sourceforge.net) by sc8-sf-list1-new.sourceforge.net with esmtp (Exim 4.43) id 1Gp3iB-0004ye-TI for cc-mode-help@lists.sourceforge.net; Tue, 28 Nov 2006 06:13:27 -0800 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by mail.sourceforge.net with esmtps (TLSv1:AES256-SHA:256) (Exim 4.44) id 1Gp3i9-0002nG-3I for cc-mode-help@lists.sourceforge.net; Tue, 28 Nov 2006 06:13:27 -0800 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by fencepost.gnu.org with esmtp (Exim 4.52) id 1Gp3i5-0005XK-NP for bug-cc-mode@gnu.org; Tue, 28 Nov 2006 09:13:21 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.52) id 1Gp3i3-00023R-Lv for bug-cc-mode@gnu.org; Tue, 28 Nov 2006 09:13:21 -0500 Original-Received: from [65.54.246.86] (helo=bay0-omc1-s14.bay0.hotmail.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Gp3hx-000215-FI; Tue, 28 Nov 2006 09:13:13 -0500 Original-Received: from hotmail.com ([64.4.26.29]) by bay0-omc1-s14.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 28 Nov 2006 06:13:12 -0800 Original-Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 28 Nov 2006 06:13:12 -0800 Original-Received: from 64.4.26.200 by by112fd.bay112.hotmail.msn.com with HTTP; Tue, 28 Nov 2006 14:13:10 GMT X-Originating-IP: [221.220.62.173] X-Originating-Email: [herberteuler@hotmail.com] X-Sender: herberteuler@hotmail.com In-Reply-To: Original-To: herberteuler@hotmail.com, rudalics@gmx.at X-OriginalArrivalTime: 28 Nov 2006 14:13:12.0059 (UTC) FILETIME=[567CCCB0:01C712F7] X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on monty-python X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=MSGID_FROM_MTA_HEADER autolearn=failed version=3.0.4 X-Spam-Score: 0.0 (/) X-Spam-Report: Spam Filtering performed by sourceforge.net. See http://spamassassin.org/tag/ for more details. Report problems to http://sf.net/tracker/?func=add&group_id=1&atid=200001 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: cc-mode-help@lists.sourceforge.net X-Mailman-Version: 2.1.8 Precedence: list List-Id: "Bug reports, feature requests, and general talk about CC Mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: cc-mode-help-bounces@lists.sourceforge.net Errors-To: cc-mode-help-bounces@lists.sourceforge.net Xref: news.gmane.org gmane.emacs.cc-mode.general:4134 gmane.emacs.devel:62937 Archived-At: And if what are critical are `comment-start' and `comment-end', why not making `command-start' and `comment-end' for c-mode the same as c++-mode? The two languages support the same comment styles now. Regards, Guanpeng Xu >From: "Herbert Euler" >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 20:34:53 +0800 > >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" >>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" >>>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 >>>>To: Herbert Euler >>>>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/ > > > >_______________________________________________ >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/ ------------------------------------------------------------------------- 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