From unknown Fri Jun 13 10:00:11 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#7413 <7413@debbugs.gnu.org> To: bug#7413 <7413@debbugs.gnu.org> Subject: Status: Suggestion for adaptive-fill Reply-To: bug#7413 <7413@debbugs.gnu.org> Date: Fri, 13 Jun 2025 17:00:11 +0000 retitle 7413 Suggestion for adaptive-fill reassign 7413 emacs submitter 7413 Simon Tatham severity 7413 wishlist thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 16 05:17:15 2010 Received: (at submit) by debbugs.gnu.org; 16 Nov 2010 10:17:15 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PIIbA-0001DE-01 for submit@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 ) id 1PIIaE-0001CQ-9m for submit@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 ) id 1PIIf2-0006dB-Hd for submit@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 ) id 1PIIf2-0006d6-Fa for submit@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@gnu.org; Tue, 16 Nov 2010 05:21:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PIIez-0006cF-7a for bug-gnu-emacs@gnu.org; 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 ) id 1PIIez-0006Z2-0u for bug-gnu-emacs@gnu.org; Tue, 16 Nov 2010 05:21:09 -0500 Received: from simon by atreus.tartarus.org with local (Exim 4.69) (envelope-from ) id 1PIIes-0000Un-9N; Tue, 16 Nov 2010 10:21:02 +0000 X-Mailer: Jed/Timber v0.2 From: Simon Tatham To: bug-gnu-emacs@gnu.org Subject: Suggestion for adaptive-fill MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: 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@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@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" - Index, Borland Pascal Language Guide