all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: help-gnu-emacs@gnu.org
Subject: Re: problems with c-fill-paragraph, c++ comments in c modules
Date: Fri, 27 Aug 2010 20:13:19 +0000 (UTC)	[thread overview]
Message-ID: <i5968v$14sk$1@colin2.muc.de> (raw)
In-Reply-To: b624b8c8-9fd0-4a44-9bfd-7401edcca871@k17g2000prf.googlegroups.com

Hi, Ragweed,

Ragweed <jeffrey.magill@gmail.com> 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).



      reply	other threads:[~2010-08-27 20:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-23 22:06 problems with c-fill-paragraph, c++ comments in c modules Ragweed
2010-08-27 20:13 ` Alan Mackenzie [this message]

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='i5968v$14sk$1@colin2.muc.de' \
    --to=acm@muc.de \
    --cc=help-gnu-emacs@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.