## 03 February 2011

Two features I'd like to see in emacs' completing-read:

• A way to make it return the value or the whole object instead of the string.
• A way to make it possibly loop using a new collection generated from the selection. That is useful for:
• Showing the user the likely options first, but allowing him to get the full list of options by choosing something like "\*More\*"
• Presenting a set of options that mostly behave alike, plus a few exceptional ones. Like "pick one of {A,B,C,etc} or \*Create a new entry\* and use it", or "Pick a function name or \*Rescan\* or pick from \*Variables\* instead". My hbmk' does this, and so does imenu'. Some packages such as filesets.el would probably have used this if it were available and would be more convenient.
• Chaining, where one selection leads to a new set of options that elaborates the choice. Sometimes your code wants to immediately do work on the first selection in which case this isn't useful. But more often your code doesn't commit to action until the user has committed to a choice, and sometimes there's nothing to do between successive selections.

## Wrote them, but that didn't suffice

I actually have written both of these. #1 I wrote back in the stone age; I believe I called it tehom-4.el. #2 I more-or-less wrote when I rewrote pcomplete to support pcmpl-elisp; it's not a separate thing and only does what pcomplete wanted, but it could be factored out and added to. Other people have had a hand at this too.

But being written doesn't make them available! If I write code that uses tehom-4, that gives it an additional dependency that's not bundled with emacs. AFAICT, nobody uses tehom-4 for another project, they just roll their own. And if I were to factor the #2 code out of pcomplete, it would just be the same story again.

That's an aspect of a problem I've bumped into a lot lately with emacs: Too little re-use of code. You can't really require non-bundled libraries unless you make them part of your package.

## How

I implemented (2) something like this: after completing-read finished, if the value was a list it would check the car of it. If it was:

complete-further'
completing-read would run again, using the cdr of the value as a collection. (I used the symbol further')
nil
Done, treat the cdr as the value.

Other possibilities

• Call the cdr as a function and use its return value as a collection.
• Show something (Help message, context, anything) but not be finished.

## Minor wishlist items:

• A slightly more refined sense of the "require-match" param, including:
nil
Do not require match at all
always-interact
Require match. Always interact, even if there are zero completions
yn
Require match.
• Abort if there are no completions.
• If there's only one completion, interact to give user a chance to abort.
t
Require match.
• Abort if there are no completions.
• If there's only one completion, just use it.
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.23993882536888123, "perplexity": 2072.1993033240906}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2017-13/segments/1490218189466.30/warc/CC-MAIN-20170322212949-00512-ip-10-233-31-227.ec2.internal.warc.gz"}