GNU bug report logs -
#47294
27.1; completing-read: History handling and sorting
Previous Next
Reported by: Clemens <clemera <at> posteo.net>
Date: Sun, 21 Mar 2021 14:30:02 UTC
Severity: normal
Tags: moreinfo
Found in version 27.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
One can pass `t` to ignore history to `read-from-minibuffer`. I
assumed this is also true for `completing-read` and discovered this
would throw an error (for example when using icomplete
`completion-all-sorted-completions` is called which doesn't handle the
`t` value). Can we change things to allow this API also for
`completing-read`?
Another observation is that the implementation of
`completion-all-sorted-completions` could be made faster by using a
hash table as Daniel Mendler implemented it for Selectrum:
```elisp
(let* ((list (and (not (eq minibuffer-history-variable t))
(symbol-value minibuffer-history-variable)))
(hist (make-hash-table :test #'equal
:size (length list))))
;; Store the history position first in a hashtable in order to
;; keep the sorting fast and the complexity at O(n*log(n)).
(seq-do-indexed (lambda (elem idx)
(unless (gethash elem hist)
(puthash elem idx hist)))
list)
(sort candidates
(lambda (c1 c2)
(let ((h1 (gethash c1 hist most-positive-fixnum))
(h2 (gethash c2 hist most-positive-fixnum))
(l1 (length c1))
(l2 (length c2)))
(or (< h1 h2)
(and (= h1 h2)
(or (< l1 l2)
(and (= l1 l2) (string< c1 c2)))))))))
```
This bug report was last modified 2 years and 326 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.