oantolin / orderless

Emacs completion style that matches multiple regexps in any order
GNU General Public License v3.0
771 stars 27 forks source link

Use & to match affixation prefix #176

Closed meedstrom closed 3 months ago

meedstrom commented 3 months ago

In my package (org-node), I'm doing a completing-read command to match against Org subtrees. I have the full Org outline path included in each candidate. Like this:

Now one issue is that anything I type will match against any of the ancestor headings, which can be somewhat bothersome, so I'd like to move the ancestors into an affixation-function. But it'd be nice to be able to use Orderless' & to match against them when necessary.

What do you think? Is there a particular reason to look up only the postfix?

meedstrom commented 3 months ago

Btw, I believe I'm missing something. I cannot seem to match postfixes either. Test example:

(let ((completion-extra-properties
       (list :affixation-function
             (lambda (coll)
               (cl-loop for cand in coll
                        collect
                        (list cand "foo|| " " ||bar"))))))
  (completing-read "Node: " (list "a" "b" "c" "d" "e" "aba" "bda" "ccd" "eeb" "feb")))

Typing &bar matches nothing. Could you help me see?

minad commented 3 months ago

Right now, Orderless only supports the annotation-function provided by the completion table as part of its metadata.

meedstrom commented 3 months ago

Then I'm puzzled by the reference to :affixation-function here, what's it do? https://github.com/oantolin/orderless/blob/53f5204ad3f541e11eb6eeb9b86584964b7a3678/orderless.el#L307-320

minad commented 3 months ago

Oh, you are right. It should actually work. The problem is that we first check for the completion metadata which may be nil.

EDIT: The problem was different. Fixed in https://github.com/oantolin/orderless/commit/4040f67949eab1cfca5bb52dca816f8f65955853.

meedstrom commented 3 months ago

Thanks! That'll be handy, it's all coming together.

BTW, I ran across a 2021 comment of yours https://github.com/minad/corfu/issues/38#issuecomment-883775437, and I wonder if you know about any recent developments? Or are affixations still king?

minad commented 3 months ago

No, there hasn't been any progress regarding a more flexible annotation machinery.