From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Re: problems with c-fill-paragraph, c++ comments in c modules Date: Fri, 27 Aug 2010 20:13:19 +0000 (UTC) Organization: muc.de e.V. Message-ID: References: NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1291861231 15642 80.91.229.12 (9 Dec 2010 02:20:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 9 Dec 2010 02:20:31 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 09 03:20:27 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PQW7N-0006JA-VW for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 03:20:26 +0100 Original-Received: from localhost ([127.0.0.1]:45274 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQW7N-0005IE-7W for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 21:20:25 -0500 Original-Path: usenet.stanford.edu!goblin1!goblin3!goblin.stu.neva.ru!news.tu-darmstadt.de!news.muc.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 108 Original-NNTP-Posting-Host: marvin.muc.de Original-X-Trace: colin2.muc.de 1282939999 37780 2001:608:1000::2 (27 Aug 2010 20:13:19 GMT) Original-X-Complaints-To: news-admin@muc.de Original-NNTP-Posting-Date: Fri, 27 Aug 2010 20:13:19 +0000 (UTC) User-Agent: tin/1.6.2-20030910 ("Pabbay") (UNIX) (FreeBSD/4.11-RELEASE (i386)) Original-Xref: usenet.stanford.edu gnu.emacs.help:180990 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:76465 Archived-At: Hi, Ragweed, Ragweed wrote: > I've recently built Emacs 23.2.1 on a linux box and it doesn't behave > the same as the Emacs 21.4.1 on the same host with respect to c++ > comments in a c file. I can't figure out how to get Emacs 23.2.1 to > run c-fill-paragraph properly for c++-style comments when they're in a > c file. > Consider the following long c++ style comment in a file named test.c: >>// The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. > If I run c-fill-paragraph with the cursor on that line, Emacs 21.4.1 > converts it to what I want: >>// The quick brown fox jumps over the lazy dog. The quick brown fox jumps over >>// the lazy dog. The quick brown fox jumps over the lazy dog. > If I run c-fill-paragraph in 23.2.1, I get: > // The quick brown fox jumps over the lazy dog. The quick brown fox > jumps over > the lazy dog. The quick brown fox jumps over the lazy dog. > That is, it wraps the comment to the next line but doesn't prefix the > next line with the comment prefix. > If I rename the file to test.cpp, then emacs 23.2.1 DOES prefix the > line. > I renamed my .emacs file so that both versions of Emacs use their > default settings and ignore my normal customizations. Thanks for taking the trouble to report this bug. It was actually reported a couple of months ago and fixed in the repository. Would you please try applying the following patch (in directory ..../lisp/progmodes), compile the changed file (or just rebuild Emacs again), and report whether or not the patch does fix the problem. Thanks! Here is the patch: *** orig/cc-cmds.el 2010-07-05 20:17:46.000000000 +0000 --- cc-cmds.el 2010-07-11 18:46:13.066679040 +0000 *************** *** 3975,3980 **** --- 3975,3988 ---- (goto-char ender-start) (current-column))) (point-rel (- ender-start here)) + (sentence-ends-comment + (save-excursion + (goto-char ender-start) + (and (search-backward-regexp + (c-sentence-end) (c-point 'bol) t) + (goto-char (match-end 0)) + (looking-at "[ \t]*") + (= (match-end 0) ender-start)))) spaces) (save-excursion *************** *** 4017,4023 **** (setq spaces (max (min spaces ! (if sentence-end-double-space 2 1)) 1))) ;; Insert the filler first to keep marks right. (insert-char ?x spaces t) --- 4025,4033 ---- (setq spaces (max (min spaces ! (if (and sentence-ends-comment ! sentence-end-double-space) ! 2 1)) 1))) ;; Insert the filler first to keep marks right. (insert-char ?x spaces t) *************** *** 4229,4236 **** (let ((fill-paragraph-function ;; Avoid infinite recursion. (if (not (eq fill-paragraph-function 'c-fill-paragraph)) ! fill-paragraph-function))) ! (c-mask-paragraph t nil 'fill-paragraph arg)) ;; Always return t. This has the effect that if filling isn't done ;; above, it isn't done at all, and it's therefore effectively ;; disabled in normal code. --- 4239,4249 ---- (let ((fill-paragraph-function ;; Avoid infinite recursion. (if (not (eq fill-paragraph-function 'c-fill-paragraph)) ! fill-paragraph-function)) ! (start-point (point-marker))) ! (c-mask-paragraph ! t nil (lambda () (fill-region-as-paragraph (point-min) (point-max) arg))) ! (goto-char start-point)) ;; Always return t. This has the effect that if filling isn't done ;; above, it isn't done at all, and it's therefore effectively ;; disabled in normal code. -- Alan Mackenzie (Nuremberg, Germany).