auctex-devel
[Top][All Lists]

Re: Better sorting for TeX-symbol-list

 From: Gustavo Barros Subject: Re: Better sorting for TeX-symbol-list Date: Sat, 11 Jun 2022 14:53:35 -0300 User-agent: mu4e 1.6.11; emacs 28.1

Hi Arash,

On Sat, 11 Jun 2022 at 17:42, Arash Esbati <arash@gnu.org> wrote:


I'm not sure if I understand your suggestion correctly since I don't
think that the return value of the function TeX-symbol-list' is to be
exposed to users directly.



Well, TeX-simbol-list' is already sorted by the parser, I'm only suggesting a change in the method employed for it. And, true, it could also be done by the completion framework, whatever it may be. But, first, current is the default. Second, it is typically a long list, isn't it better to sort it just once, when parsing, then every time we reach for TeX-insert-macro'?


Again, why should we care from a user perspective?


For me, it is a task for the completion system to respect or ignore the
case and/or sort the candidates.  Maybe you just want to adjust the
variable completions-sort'.  Example:

(let ((completions-sort (lambda (list)
(sort list #'string-collate-lessp))))
'("declare"
"declarefoo"
"Declare"
"DeclareRobustCommand")))

Is this what you're looking after?



It makes a difference from the user perspective because, if you are looking for a macro, especially a short one, and have case-fold enabled, you may have even typed the full name of the thing you are looking for, but be nowhere near it, and thus have no other alternative other then navigating down, or go through the trouble of using some more advanced search technique, like regexp features.


And, true, the list is probably re-sorted by different completion frameworks. So, you're right that everyone is resorting the list anyway. I'm using 'ivy-mode', and it can be a pain to reach for short ones with string-lessp'.


If you'd like to see how it looks like, try the following. Start with emacs -Q', configure:

#+begin_src emacs-lisp
(setq TeX-parse-self t)
(setq TeX-auto-save t)
(ivy-mode)
#+end_src

Now visit the following file:

#+begin_export latex
\documentclass{article}

\usepackage{acro}

\begin{document}

\end{document}
#+end_export

and try to complete for the macro \ac'.


Redefine TeX-car-string-lessp' to use string-collate-lessp', reload the styles (C-u C-c C-n), and try again.


Things get even more complicated when you're using vertico for example
which also cater for history and length of candidates.  So again, I
don't think the sorting of the candidates input is relevant.


True again. And maybe it's just Ivy's fault, I don't know.
Well, it was just a small suggestion, no problem. :)

Best,
Gustavo.

`