[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: CC Mode 5.28 (C++); comment-indent-newline does not insert a comm en
From: |
Martin Stjernholm |
Subject: |
Re: CC Mode 5.28 (C++); comment-indent-newline does not insert a comm ent delimiter after the new line. |
Date: |
25 Nov 2001 19:52:51 +0100 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
"Stefan Monnier" <monnier+gnu/address@hidden> wrote:
> Right now, M-j does pretty much the same thing as the line breaking
> of do-auto-fill except for:
>
> 1 - it doesn't obey comment-line-break-function
> 2 - it doesn't obey adaptive-fill-prefix
>
> I actually find both differences annoying. So how about a new
> function to bind to M-j:
I think it's a good idea.
> (defun fill-here ()
> "Force soft line break at point, like auto-filling would do.
> Break line at point, preserving any fill prefix and continuing comment
> if we are inside a comment."
> (interactive)
> (let ((comment-auto-fill-only-comments nil)
> (fill-prefix fill-prefix))
> ;; Choose a fill-prefix automatically.
> (when (and adaptive-fill-mode
> (or (null fill-prefix) (string= fill-prefix "")))
> (let ((prefix
> (fill-context-prefix
> (save-excursion (fill-backward-paragraph) (point))
> (save-excursion (fill-forward-paragraph) (point)))))
/.../
Not that it's really related, but I'd like a more general interface
here so that it's possible to plug in a replacement for
fill-context-prefix. The use of fill-{backward|forward}-paragraph by
the caller is a bit useless then, since those functions aren't likely
to do the right thing in these cases (e.g. in a C comment surrounded
by code). The check on adaptive-fill-mode is also not extension
friendly.