all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Christoph <cschol2112@googlemail.com>
Cc: bug-gnu-emacs@gnu.org
Subject: bug#193: Fix for bug#193.
Date: Sun, 11 Jul 2010 18:55:59 +0000	[thread overview]
Message-ID: <20100711185559.GE3134@muc.de> (raw)
In-Reply-To: <4C37CFB8.2020707@gmail.com>

Hi, Christoph,

On Fri, Jul 09, 2010 at 07:41:12PM -0600, Christoph wrote:
> Hi Alan,

> On 7/9/2010 12:51 PM, Alan Mackenzie wrote:
> >Hi, Deniz,

> >On Sun, Jun 27, 2010 at 02:47:52PM +0200, Deniz Dogan wrote:
> >>Did anyone ever agree on what needs to be done to fix the problem?

> >Would you try this patch, please, and then tell me whether or not it
> >works fully.  Thanks!

> M-q works fine for me with C as well as C++ style comments, both ways, 
> i.e. shorting long comments and extending short comments to fill the line.

> The only "quirk" I found:

> Using C-style comments, if the original comment looks like this:

> /* This is a short comment
>    which is extended                      */

> the resulting comment is:

> /* This is a short comment which is extended  */

> Notice the two spaces after the last word 'extended', before the close 
> comment marker.

The reason being that the filling function assumed that a comment ends
with a sentence, and should therefore leave two spaces after it.
However, if there's no full stop (etc.), the two spaces is silly.

> This might be nitpicking but I thought I bring it up.

We need nitpickers.  ;-)  Thanks for drawing it to my attention.  Would
you please try this amended patch: It should leave just one space after
"is extended", but two spaces after "is extended.".


*** 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.



> Christoph

Looking forward to hearing back from you,

-- 
Alan Mackenzie (Nuremberg, Germany).



------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first


  reply	other threads:[~2010-07-11 18:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-06 21:49 Fill for // (C++) style comments in C (C99) Richard Hansen
2010-06-27 12:47 ` bug#193: Deniz Dogan
2010-07-05 20:06   ` bug#193: Alan Mackenzie
2011-03-05 20:43     ` bug#193: Glenn Morris
2010-07-06 19:29   ` bug#193: Alan Mackenzie
2010-07-06 19:29   ` bug#193: Alan Mackenzie
2010-07-09 18:51   ` bug#193: Fix for bug#193 Alan Mackenzie
2010-07-10  1:41     ` Christoph
2010-07-11 18:55       ` Alan Mackenzie [this message]
2010-07-14  1:08         ` Christoph
2010-08-06 18:59           ` Alan Mackenzie

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=20100711185559.GE3134@muc.de \
    --to=acm@muc.de \
    --cc=bug-gnu-emacs@gnu.org \
    --cc=cschol2112@googlemail.com \
    /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.