0

I'm looking for a completion-mode that let the user select the completion-table to use interactively.

So, for example, instead of applying all functions in completion-at-point-functions, apply only the first, and get one set of completions. Then, if user hits some key, switch to the next function in completion-at-point-functions, and get another set of completions, etc. That would let the user select the source of the completion-at-point interactively. And even switch completion style interactively too, i.e. fuzzy/non-fuzzy, etc.

Is that possible? Does any package implement something like that?

1 Answer 1

1

I can't speak much to the first thing you request: switching among completion-at-point functions interactively, adding the matches from each.

I can, however, speak to the second thing you request: "switch completion style interactively too, i.e. fuzzy/non-fuzzy, etc."

(You really should pose only one, specific question per post.)


Icicles lets you switch completion methods and styles on the fly. This feature is covered in topic Icicles - Completion Methods and Styles.

Icicles is mainly for minibuffer completion. It's not really about completing buffer text with completion-at-point-functions.

With vanilla Emacs you have one set (a list) of completion styles, which is the value of option completion-styles. You can also, in effect, define other sets of completion styles for use with different "categories" of completion candidates, such as buffers, commands, etc. But all such sets are essentially defined ahead of time, and which gets used in any given context is pretty much baked in.

With whatever list of completion styles is in effect for a given category (or in general, with completion-styles), you have no control over which of the styles in that list is actually used to complete your minibuffer pattern. And you have no way of knowing which one was used.

With Icicles, you can define any number of completion-style sets, using option icicle-completion-style-sets. And you can switch among them on the fly any time during completion, using C-M-(.

Among other things, this means you can try completing using one style set and, if that doesn't succeed, switch to another, interactively.

Any of the sets in icicle-completion-style-sets can contain any number of styles, in any order. In particular, a set can be a singleton, which means that you can selectively try to complete using different individual styles (which implies that you can know which style was used).


All of that is the behavior you get when the current Icicles completion method is vanilla.

But more important is that Icicles lets you use different completion methods (not just styles). Completion method vanilla is the only method that is subdivided into styles and style sets.

Icicles provides several completion methods (10 of them, including 6 "fuzzy" methods). And you can define others if you like. Icicles divides them into two groups, for completion using two different keys: TAB and S-TAB (you can choose any keys you like; those are used by default). Consult the Icicles doc for much more about this.

You can switch among the TAB methods at any time during completion using C-(, and you can switch among the S-TAB methods using M-(. You can switch between the current TAB and S-TAB methods just by hitting those keys (that's why there are two: because you more often want to switch between two than cycle among several).

If you provide a prefix argument to C-( or M-(, then the newly chosen method is used only for the current command. The previously active method is restored as soon as you return to the top level. Without a prefix arg the newly chosen method remains in effect until you change again.

(When cycling completion-style sets using C-M-( the effect is always just for the current command.)

By default, TAB completion uses method vanilla, which uses the styles in option completion-styles. And by default, S-TAB completion uses method apropos, which uses regexp matching (which essentially includes substring matching). Apropos matching is particularly useful, IMO.


Options icicle-TAB-completion-methods-per-command and icicle-S-TAB-completion-methods-per-command let you define define the methods to be made available during specific commands that read input with completion. That is, they give you command-specific control over C-( and M-(.


Related, but more important than any of this (and perhaps somewhat related to your first question), is that with Icicles you can complete some minibuffer pattern, with some method/styles, then add to or subtract from the resulting set of completion candidates by completing some other minibuffer pattern, with the same or different method/styles.

This feature is called progressive completion. Typically you subtract - successive approximation, by incrementally filtering with different minibuffer patterns (or even predicates). You do this using S-SPC, which puts you in a recursive minibuffer for another completion pattern.

Progressive completion filters out completions that don't match your current minibuffer pattern. The patterns you enter progressively this way are ANDed: all of them need to be satisfied.

But you can also filter out the completions that do match the current pattern.

That is, you can complement the current set of candidates, using C-~. The current candidate set is replaces with its set complement. So first you type a pattern to match, then you use C-~ to have it not match.

This is thus AND NOT. Use this to progressively eliminate candidates that match different input patterns. See Chipping Away the Non-Elephant.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.