* problems with c-fill-paragraph, c++ comments in c modules
@ 2010-08-23 22:06 Ragweed
2010-08-27 20:13 ` Alan Mackenzie
0 siblings, 1 reply; 2+ messages in thread
From: Ragweed @ 2010-08-23 22:06 UTC (permalink / raw
To: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: problems with c-fill-paragraph, c++ comments in c modules
2010-08-23 22:06 problems with c-fill-paragraph, c++ comments in c modules Ragweed
@ 2010-08-27 20:13 ` Alan Mackenzie
0 siblings, 0 replies; 2+ messages in thread
From: Alan Mackenzie @ 2010-08-27 20:13 UTC (permalink / raw
To: help-gnu-emacs
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).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-08-27 20:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-23 22:06 problems with c-fill-paragraph, c++ comments in c modules Ragweed
2010-08-27 20:13 ` Alan Mackenzie
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.