diff options
author | João Távora <joaotavora@gmail.com> | 2019-02-14 23:33:49 +0000 |
---|---|---|
committer | João Távora <joaotavora@gmail.com> | 2019-02-14 23:33:49 +0000 |
commit | 0d19e08da647c42562428dd608e5284cf414415e (patch) | |
tree | 090e74e45424caa7632fce426d4f9626b65d5d88 /test/lisp/emacs-lisp/bytecomp-tests.el | |
parent | a4c7de35decaace94eba678161b0d4c8266647d2 (diff) | |
download | emacs-0d19e08da647c42562428dd608e5284cf414415e.tar.gz emacs-0d19e08da647c42562428dd608e5284cf414415e.tar.bz2 emacs-0d19e08da647c42562428dd608e5284cf414415e.zip |
Change scoring strategy for 'flex' completion style
The previous strategy had problems comparing scores of matches to
strings of different lengths. This one seems slightly more sensible,
and uses a new constant `flex-score-match-tightness' instead of the
more abstract `flex-score-falloff'.
It's not completely without problems, and I think it shouldn't count
"holes" at the front and at the back, but that needs a different
"pattern-to-regexp" conversion in completion-pcm--hilit-commonality.
(defun test ()
(mapcar (lambda (a)
(cons (substring-no-properties a)
(get-text-property 0 'completion-score a)))
(sort (completion-pcm--hilit-commonality
'(prefix "f" star "o" star "o" point)
'("foo"
"barfoobaz"
"foobarbaz"
"barbazfoo"
"fabrobazo"
"foot"
"foto"
"fotttttttttttttttttttttttto"))
(lambda (a b)
(> (get-text-property 0 'completion-score a)
(get-text-property 0 'completion-score b))))))
(let ((flex-score-match-tightness 100)) (test))
=> (("foo" . 1.0)
("foot" . 0.375)
("foto" . 0.375)
("foobarbaz" . 0.16260162601626016) ;; one hole
("barbazfoo" . 0.16260162601626016) ;; one hole
("barfoobaz" . 0.10964912280701755) ;; two holes
("fabrobazo" . 0.10964912280701755) ;; two holes
("fotttttttttttttttttttttttto" . 0.04982561036372696))
(let ((flex-score-match-tightness 0.1)) (test))
=> (("foo" . 1.0)
("foot" . 0.375)
("foto" . 0.375)
("barfoobaz" . 0.007751937984496124) ;; two holes
("fabrobazo" . 0.007751937984496124) ;; two holes
("foobarbaz" . 0.00641025641025641) ;; one hole
("barbazfoo" . 0.00641025641025641) ;; one hole
("fotttttttttttttttttttttttto" . 0.0004789272030651341))
* lisp/minibuffer.el (flex-score-falloff): Rename to
flex-score-match-tightness.
(completion-pcm--hilit-commonality): Update function.
Diffstat (limited to 'test/lisp/emacs-lisp/bytecomp-tests.el')
0 files changed, 0 insertions, 0 deletions