Giter Site home page Giter Site logo

Comments (9)

oantolin avatar oantolin commented on August 20, 2024 1

I think there was a third style which in addition to being strict anchored the match at the beginning!

Since initialisms already only match characters at word boundaries I don't find this non-strict matching really causes many false positives, at least not for command names which is really the only thing I use initialism matching for.

from orderless.

minad avatar minad commented on August 20, 2024

One could even use a variant of flex which is more strict and doesn't skip the same letter. abc -> a[^b]*b[^c]*c. These regexps perform better.

from orderless.

daanturo avatar daanturo commented on August 20, 2024

My implementation, inspired by @minad 's comment:

(defun my-orderless-non-greedy-flex (component)
  (rx-to-string
   `(seq ,@(cl-loop
            for (head . tail) on (string-to-list component)
            collect `(group ,head)
            when tail
            collect `(* (not ,(car tail)))))))

(my-orderless-non-greedy-flex "abc")
=> "\\(?:\\(a\\)[^b]*\\(b\\)[^c]*\\(c\\)\\)"

from orderless.

oantolin avatar oantolin commented on August 20, 2024

Thanks for the suggestion, @daanturo. I went with @minad's suggested compilation.

from orderless.

minad avatar minad commented on August 20, 2024

@oantolin Are there more matching styles which could be made more strict such that we get better complexity? Initialism?

I think it is worth the trade off since regexps like the ones generated by the old flex compiler behaved really badly for long candidates. We discussed this a while ago in another issue.

from orderless.

oantolin avatar oantolin commented on August 20, 2024

I don't think initialism would benefit from a similar compilation since it already only matches characters at word boundaries. But it does make sense to think about each style to make sure we aren't missing any obvious compiler optimizations.

from orderless.

minad avatar minad commented on August 20, 2024

For initialism does ac match axxx-bxxx-cxxx or only axxx-cxxx? I mean such an optimization, maybe there are others for other styles?

I think I prefer matching less with better performance instead of more flexible matching. I also like literal more than flex. But one should keep in mind that restricting the style may be undesired for other users who prefer more typo tolerance.

from orderless.

oantolin avatar oantolin commented on August 20, 2024

For initialism does ac match axxx-bxxx-cxxx or only axxx-cxxx?

It does match axxx-bxxx-cxxx. There used to be a related matching style called "strict initialism" that would only match "axxx-cxxx".

from orderless.

minad avatar minad commented on August 20, 2024

Yes, but didn't the strict style also have anchoring? I thought we could maybe use an unanchored strict style.

from orderless.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.