emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Add user customization fido-completion-styles


From: Drew Adams
Subject: RE: Add user customization fido-completion-styles
Date: Tue, 2 Jun 2020 09:14:42 -0700 (PDT)

FWIW:

If you choose the sort order "by flx score" in
Icicles, and if you type no pattern to match in
the minibuffer, then the candidates (e.g. commands,
for `M-x') are sorted by `string-lessp' (but
respecting `completion-ignore-case').

In general, the predefined sort orders in Icicles
do something reasonable when the main sorting
test says two candidates are incomparable.

Some such orders have more than one fallback level,
i.e., more than one kind of sorting, the 2nd
taking over when the 1st can't compare, the 3rd
taking over when the 2nd can't compare, etc.

Often the (last) fallback is alphabetical order.
For example, for flx-score sorting, the test
predicate is this:

(defun icicle-flx-score-greater-p (s1 s2)
  "Non-nil means the `flx-score' of S1 is greater than that of S2.
That is, the cars of the `flx-score' values are compared.

If `flx-score' returns nil for either argument, then they are compared
using `icicle-case-string-less-p'.

This function requires library `flx.el'."
  (let* ((input   (if (and (icicle-file-name-input-p)  
                           insert-default-directory)
                      (file-name-nondirectory icicle-current-input)
                    icicle-current-input))
         (score1  (flx-score s1 input))
         (score2  (flx-score s2 input)))
    (if (and score1  score2)
        (> (car score1) (car score2))
      (icicle-case-string-less-p s1 s2))))

I don't know why Emacs shouldn't act similarly.

As for performance, for `M-x' there certainly is
no problem.  `M-x' with no input pattern to match
shows the 6000-some candidates immediately.

https://www.emacswiki.org/emacs/Icicles_-_Sorting_Candidates
___

FWIW2:

Icicles extends the idea of combining predicates
in the definition of a single sort predicate, in
two ways:

1. Interactively, you can apply multiple sort
   orders, sequentially.

2. A sort comparer can itself be defined as a
   list ((PRED...) FINAL-PRED), where each PRED
   and  FINAL-PRED are binary predicates.

#1 is described here:

https://www.emacswiki.org/emacs/Icicles_-_Sorting_Candidates#AddingASavedSortOrder

In #2, each PRED returns true, false, or undecided,
where undecided means that the next PRED takes over
deciding, and so on.  FINAL-PRED just returns true
or false.  (True is `(t)', false is `(nil)', and
undecided is nil.)

This way of combining yes-no-maybe predicates is
described here:

https://www.emacswiki.org/emacs/ApplesAndOranges
___

(Note: Icicles uses the flx-scoring provided by
3rd-party library `flx.el', from Le Wang (if loaded),
not the flx completing style you recently added to
vanilla Emacs.

https://github.com/lewang/flx)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]