unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: "João Távora" <joaotavora@gmail.com>,
	"Andrew Schwartzmeyer" <andrew@schwartzmeyer.com>
Cc: emacs-devel@gnu.org
Subject: RE: Add user customization fido-completion-styles
Date: Tue, 2 Jun 2020 09:14:42 -0700 (PDT)	[thread overview]
Message-ID: <3483a8d9-1474-45cf-afad-8d276b96ef3f@default> (raw)
In-Reply-To: <877dwpn2id.fsf@gmail.com>

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	other threads:[~2020-06-02 16:14 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-31 21:02 Add user customization fido-completion-styles Andrew Schwartzmeyer
2020-05-31 23:43 ` João Távora
2020-05-31 23:59   ` Dmitry Gutov
2020-06-01  0:21     ` João Távora
2020-06-01  0:37   ` Andrew Schwartzmeyer
2020-06-01  4:37     ` Andrew Schwartzmeyer
2020-06-02 11:14       ` João Távora
2020-06-02 16:14         ` Drew Adams [this message]
2020-06-02 17:51           ` João Távora
2020-06-02 18:11             ` Eli Zaretskii
2020-06-02 18:24               ` João Távora
2020-06-02 18:35                 ` Eli Zaretskii
2020-06-02 19:11                   ` João Távora
2020-06-02 19:25                     ` Eli Zaretskii
2020-06-02 20:00                       ` João Távora
2020-06-02 20:51             ` Drew Adams
2020-06-02 15:40   ` Tassilo Horn
2020-06-02 15:55     ` João Távora
2020-06-02 16:47       ` Tassilo Horn
2020-06-02 17:03         ` João Távora
2020-06-02 18:05           ` Tassilo Horn
2020-06-02 17:10         ` Tassilo Horn
2020-06-02 19:28           ` João Távora

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3483a8d9-1474-45cf-afad-8d276b96ef3f@default \
    --to=drew.adams@oracle.com \
    --cc=andrew@schwartzmeyer.com \
    --cc=emacs-devel@gnu.org \
    --cc=joaotavora@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).