[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#7413: Suggestion for adaptive-fill
From: |
Simon Tatham |
Subject: |
bug#7413: Suggestion for adaptive-fill |
Date: |
Tue, 16 Nov 2010 10:21:02 +0000 |
I'd like to suggest a small extra piece of configurability for
Emacs's adaptive fill functionality.
Adaptive fill mode is capable of filling a paragraph in a source
code file which has comment characters down the left, and replacing
them after filling:
# This is a
# comment.
And it can also fill a paragraph which uses '-' as a bullet
character, and automatically line up subsequent lines below the
character after the bullet rather than below the bullet:
- Like
this.
But one thing it won't currently _quite_ cope with is both at once:
# - This is a bulleted paragraph
# in a source comment.
If the paragraph already has more than one line, even this will
work, because the fill-context-prefix function in fill.el observes
that the second line's prefix is derived from the first by replacing
some characters with spaces, and therefore decides it's a sensible
prefix to keep using. But if the paragraph is only one line long and
needs to be broken on to multiple lines, then fill-context-prefix
cannot infer from " # - " that the second line's prefix should be
" # ", because currently its only options for handling a
one-line prefix are to use the prefix unmodified or replace the
_whole_ thing with spaces.
So my suggestion is that it would be useful to have a user-definable
function hook checked for the one-line case, perhaps called
'adaptive-fill-infer-prefix-function' or some such, which is given
the fill prefix for a one-line paragraph and returns the appropriate
prefix to use when breaking it on to a second line and beyond.
Secondarily, I suggest that a default implementation of that
function might want to consider the case where the start of the
prefix matches comment-start-skip and the remainder matches
first-line-regexp, and in that situation replace only the latter
part with spaces.
I've currently implemented similar functionality in my .emacs by
applying `defadvice' to the fill-context-prefix function, but my
feeling is that if I have to use defadvice on an internal emacs
function then it's worth at least suggesting a change so I don't
have to in future :-)
(I'll send you my defadvice-based code if you like, but it's more a
hack than a finished patch at the moment.)
Cheers,
Simon
--
Simon Tatham "infinite loop _see_ loop, infinite"
<anakin@pobox.com> - Index, Borland Pascal Language Guide
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#7413: Suggestion for adaptive-fill,
Simon Tatham <=