FillAdapt

Description

Filladapt by KyleJones enhances Emacs’ fill functions by guessing a fill prefix, such as a comment sequence in program code, and handling bullet points like “1.” or “*”. Get it from the author at

http://www.wonderworks.com/
http://www.wonderworks.com/download/filladapt.el

Here are some things adding to filladapt (in addition to the sections below),

Compared to Adaptive Fill

Emacs has a builtin AdaptiveFillMode?, but filladapt tends to do a better job. The token table makes filladapt largely mode-agnostic, so common commenting styles work without a specific adaptive-fill-regexp setup. And even better compounded forms like email cited text within a lisp comment fills as you’d hope.

When you do have to customize the token table tends to be easier than a single adaptive-fill-regexp. If something mis-matches it can be removed by name, perhaps just in particular modes. filladapt-pat.el (above) has a few interactive commands for that.

Of course both filladapt and adaptive-fill are matters of personal preference. You don’t have to use either!

Thanks Kevin for the clarifications. However it looks like filladapt.el redefines some functions in Emacs. (To see this you can use the tool “Investigate Elisp File” in the nXhtml menu.) So perhaps you can not compare what adaptive-fill-mode does to what filladapt does in the same Emacs?

I think filladapt.el needs a bit rewriting to fit into Emacs today.

Mechanism

Filladapt works by matching prefix patterns from filladapt-token-table. That table has for example // for C++ comments. Lines with the same prefix, or same multiple prefixes, are considered a paragraph. You can see this process in action dynamically with filladapt-debug.

    M-: (filladapt-debug)

The default setups suit most comment styles and bullet point styles. They don’t look at the major mode, so a mixture of styles in one buffer works fine. If you need to restrict styles to a particular major mode the easiest way is to make a buffer-local change to filladapt-token-table from the mode hook.

It’s worth noting filladapt still goes through fill-paragraph-function, so if it doesn’t seem to be working (even when the debug above shows a correct line/paragraph analysis), then perhaps a major mode function in that variable is to blame. (An example of that is makefile-mode on indented comments in Emacs 21 and 22; see the MakefileMode page for a fix.)

C/C++/Java and javadoc/doxygen comments

Filladapt is very cool, but to if you want it to be useful while editing C/C++/Java comments and javadoc/doxygen documentation, you need fix the token table. Here is what I use:

JonathanBaccash?’s hack was here.

[1] All you have to do is tell cc-mode to prepare for filladapt:

(add-hook 'c-mode-common-hook
	  (lambda ()
	    (when (featurep 'filladapt)
	      (c-setup-filladapt))))

CategoryFilling CategoryComments