Skip to content

Properly support matching ignoring order #329

Closed

Description

@jyp

I'd like to replace helm by avy in my configuration, but I cannot live with proper support for matching parts of the input in any order.

As indicated in #296, ivy--regex-ignore-order behaves incorrectly. It was concluded that doing matching by building a regexp matching all the permutations would be prohibitively slow. I'd like to offer the following counter arguments:

  1. If the user is willing to pay this cost, why not allow it?
  2. Notwithstanding the above point, the conclusion was reached on the assumption that the cost of matching a regexp is proportional to the length of the regexp. However, a proper regexp matcher should not behave like this. I'm guessing that emacs' native matcher is 'bad', but one could use an efficient matcher. (There exists a 'good' elisp implementation: http://www.emacswiki.org/emacs/TaggedNFA)
  3. Even using a slow matcher, one can implement matching-ignoring-order by filtering the candidates with each of the sub-expressions, in series. In fact, ivy--filter has already code to support this behaviour today:
                         (dolist (re re-list)
                           (setq res
                                 (ignore-errors
                                   (funcall
                                    (if (cdr re)
                                        #'cl-remove-if-not
                                      #'cl-remove-if)
                                    (let ((re-str (car re)))
                                      (lambda (x) (string-match re-str x)))
                                    res))))

unfortunately, several other places in the code assume that the regexp is a string. That is, if ivy--regex-ignore-order was to return a list, errors would be thrown.

Would it be reasonable to support list of regexps consistently?

Activity

  1. Konubinix commented on Jan 2, 2016

    @Konubinix
    Contributor
  2. jyp commented on Jan 2, 2016

    @jyp
    ContributorAuthor

    Thanks for the feedback. I'll see what I can do. Yet, the first step will be to obtain a copyright assigment from my employer, so don't hold your breath :)

  3. abo-abo commented on Jan 7, 2016

    @abo-abo
    Owner

    Thanks, please test.

  4. Konubinix commented on Jan 8, 2016

    @Konubinix
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions