From: "Omar Antolín Camarena" <omar@matem.unam.mx>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 45260@debbugs.gnu.org, "João Távora" <joaotavora@gmail.com>
Subject: bug#45260: 28.0.50; Maybe flex should only sort when there is no sorting metadata?
Date: Tue, 17 Aug 2021 10:27:23 -0500 [thread overview]
Message-ID: <8735r8852c.fsf@matem.unam.mx> (raw)
In-Reply-To: <deb8799c-fdb4-c4e1-bda6-f72e7095ea87@yandex.ru> (Dmitry Gutov's message of "Tue, 17 Aug 2021 17:49:39 +0300")
João said:
> I've not seen an example of a table where its original sorting
> mattered more _when_ there is some search pattern.
I'd argue the case I mentioned in the bug report is a good example. That
was the case of the consult-line command from Daniel Mendler's consult
package. That commands prompts for a line to go to using completions.
The completion candidates thus are all the lines in the current buffer.
The lines are prefixed with their line numbers in an affixation-function
and the display-sort-function is set to identity, so that the candidates
appear in the order they occur in the buffer.
The flex completion style is a pretty reasonable one to use with that
command, and it is a powerful way to find a line in a buffer by typing
realtively few characters in the line. But if you use a completion UI
that displays the candidates automatically while you type, such as
icomplete-mode (preferably icomplete-vertical-mode since these
candidates are full lines!), it is jarring that flex jumbles the line
order. I believe this to be a natural example where you want to keep the
candidates' order.
But also feel free to close this issue if you strongly disagree with it.
I'm not that invested since I do have what João suggested: an
"omar-flex" style that doesn't sort (through a completion-style I wrote
called orderless which includes a flex substyle, and to be honest I
hardly ever use flex, either João's version or the version in
orderless). Also, if I really want to use flex it is easy enough to
disable the sorting for specific commands such as consult-line:
(defun keep-flex-from-sorting (fn &rest args)
(put 'flex 'completion--adjust-metadata nil)
(unwind-protect
(apply fn args)
(put 'flex 'completion--adjust-metadata 'completion--flex-adjust-metadata)))
(advice-add 'consult-line :around #'keep-flex-from-sorting)
Since flex's sorting is what you want for the vast majorit of commands,
I think this advice approach is a perfectly serviceable work around.
[Since in Emacs I can usually work around any issue without needing any
upstream changes, I feel my debating skills have deteriorated: I don't
have to convince people my suggestions are a good idea! So I just
suggest but then don't insist. ;) ]
--
Omar
next prev parent reply other threads:[~2021-08-17 15:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-15 18:47 bug#45260: 28.0.50; Maybe flex should only sort when there is no sorting metadata? Omar Antolín Camarena
2021-08-17 10:41 ` João Távora
2021-08-17 12:42 ` Dmitry Gutov
2021-08-17 14:05 ` João Távora
2021-08-17 14:49 ` Dmitry Gutov
2021-08-17 15:27 ` Omar Antolín Camarena [this message]
2021-08-17 16:58 ` João Távora
2021-08-17 16:38 ` João Távora
2021-09-27 23:11 ` Dmitry Gutov
2021-09-27 23:25 ` João Távora
2021-09-27 23:40 ` Dmitry Gutov
2021-09-28 0:36 ` João Távora
2021-09-28 0:39 ` João Távora
2021-09-28 12:38 ` Dmitry Gutov
2021-09-28 16:09 ` João Távora
2021-09-28 16:30 ` Dmitry Gutov
2021-09-28 22:17 ` 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=8735r8852c.fsf@matem.unam.mx \
--to=omar@matem.unam.mx \
--cc=45260@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
--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).