Hello, Kai, Peter.
On Tue, Nov 22, 2011 at 08:48:21AM +0100, Kai Tetzlaff wrote:
> Peter Milliken <Peter.Milliken@...> writes:
> Hi Peter and Alan,
[ .... ]
> I have tried to narrow down the source of the problem and found that the
> following patch against cc-mode CVS fixes it (it might have some
> unwanted side-effects, but i'm using this patch since quite a while
> without problems):
> diff -r c8c4f1bd6913 lisp/cc-mode/cc-cmds.el
> --- a/lisp/cc-mode/cc-cmds.el Tue Aug 23 08:22:34 2011 +0200
> +++ b/lisp/cc-mode/cc-cmds.el Tue Aug 23 08:20:42 2011 +0200
> @@ -4373,11 +4373,8 @@
> (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))
> + 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.
I've searched my log and found out why I applied that patch:
(i) Leave your (Kai's) patch in place (i.e. reverse my patch).
(i) Disable filladapt-mode.
(ii) In C Mode (NOT C++ Mode) enter two contiguous short line comments:
// A short
(iii) Do M-q. Nothing happens.
(iv). Enter a long line comment, longer than fill-column:
// A very long line comment which goes beyond fill-column which is probably 78 or 80.
(v) Do M-q. This line is split, but without "//" on the second line.
The reason for this behaviour is a change in Emacs's `fill-paragraph'
some while ago, which ....
;; Try to prevent code sections and comment sections from being
;; filled together.
(when (and fill-paragraph-handle-comment comment-start-skip)
(concat paragraph-start "\\|[ \t]*\\(?:" <=============
comment-start-skip "\\)"))) <=============
.... concatenates paragraph-start and comment-start-skip. I questioned
this change in `fill-paragraph' back then, but got no response.
Therefore I used a different function in place of `fill-paragraph'. As
you and Peter reported, this causes problems in filladapt-mode.
I'll carry on thinking what to do about this.
Alan Mackenzie (Nuremberg, Germany).