GNU bug report logs - #7413
Suggestion for adaptive-fill

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Simon Tatham <anakin@HIDDEN>; dated Tue, 16 Nov 2010 10:18:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 16 Nov 2010 10:17:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 16 05:17:15 2010
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PIIbA-0001DE-01
	for submit <at> debbugs.gnu.org; Tue, 16 Nov 2010 05:17:15 -0500
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <simon@HIDDEN>) id 1PIIaE-0001CQ-9m
	for submit <at> debbugs.gnu.org; Tue, 16 Nov 2010 05:16:15 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <simon@HIDDEN>) id 1PIIf2-0006dB-Hd
	for submit <at> debbugs.gnu.org; Tue, 16 Nov 2010 05:21:13 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED,
	T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([199.232.76.165]:44943)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <simon@HIDDEN>) id 1PIIf2-0006d6-Fa
	for submit <at> debbugs.gnu.org; Tue, 16 Nov 2010 05:21:12 -0500
Received: from [140.186.70.92] (port=39116 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1PIIf0-0001V8-RK
	for bug-gnu-emacs@HIDDEN; Tue, 16 Nov 2010 05:21:12 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <simon@HIDDEN>) id 1PIIez-0006cF-7a
	for bug-gnu-emacs@HIDDEN; Tue, 16 Nov 2010 05:21:10 -0500
Received: from atreus.tartarus.org ([80.252.125.10]:55053)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <simon@HIDDEN>) id 1PIIez-0006Z2-0u
	for bug-gnu-emacs@HIDDEN; Tue, 16 Nov 2010 05:21:09 -0500
Received: from simon by atreus.tartarus.org with local (Exim 4.69)
	(envelope-from <simon@HIDDEN>)
	id 1PIIes-0000Un-9N; Tue, 16 Nov 2010 10:21:02 +0000
X-Mailer: Jed/Timber v0.2
From: Simon Tatham <anakin@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: Suggestion for adaptive-fill
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Message-Id: <E1PIIes-0000Un-9N@HIDDEN>
Date: Tue, 16 Nov 2010 10:21:02 +0000
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Spam-Score: -6.6 (------)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Tue, 16 Nov 2010 05:17:11 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.6 (------)

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@HIDDEN>     - Index, Borland Pascal Language Guide




Acknowledgement sent to Simon Tatham <anakin@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#7413; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.