creichert / ido-vertical-mode.el

makes ido-mode display vertically
211 stars 22 forks source link

Highlight matching substrings when ido-enable-flex-matching is set #45

Open mardukbp opened 7 years ago

mardukbp commented 7 years ago

A typical query with flex matching may contain strings separated by spaces and ido-vertical-completions does not handle this case.

My quick-and-dirty solution was to add this:

In let*

(query (split-string name " "))
(nquery (length query))

In the loop that sets the face of the matching substring:

(dotimes (j nquery)
  (let ((query-j (nth j query)))
    (when (string-match (if ido-enable-regexp query-j (regexp-quote query-j)) comps-i)
      (ignore-errors
    (add-face-text-property (match-beginning 0)
                (match-end 0)
                'ido-vertical-match-face
                nil comps-i)))))
creichert commented 7 years ago

Nice, I agree this would be nice to support. Are you interested in trying to improve the solution and make a PR?

mardukbp commented 7 years ago

After three months, this has worked great for me. But I forgot to say that I also modified ido-set-matches-1 so that it only matches consecutive characters. For example, if my query is are, I do not want ido to match algol rapid ego.

What improvements would you suggest? If I had time, I would rewrite ido-mode.el and merge ido-vertical-mode. I think the code in ido-mode.el is very hard to understand and some things are hard-coded that should be customizable.