radian-software / prescient.el

☄️ Simple but effective sorting and filtering for Emacs.
MIT License
603 stars 25 forks source link

Improve `prescient-sort-full-matches-first` with multiple filter methods #147

Closed okamsn closed 1 year ago

okamsn commented 1 year ago

We currently get a list of regexps from prescient-filter-regexps, which creates a list of or-ed regexps created by the chosen filter methods for each query. Currently, depending on the order in which the regexps are made, a filter method which matches part of the candidate is seen before a filter method which matches all of the candidate.

For example, this returns "re", not "restart-emacs".

;; -> "re", not "restart-emacs"
(save-match-data
  (let ((str "restart-emacs")
        (prescient-filter-method '(literal initialism)))
    (string-match (car (prescient-filter-regexps "re")) str)
    (match-string 0 str)))

We can make sure the matching (for this function in particular) is done greedily, or we can handle the full list of non-or-ed regexps.