From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Clemens Newsgroups: gmane.emacs.bugs Subject: bug#47294: 27.1; completing-read: History handling and sorting Date: Sun, 21 Mar 2021 15:29:49 +0100 Message-ID: <00acdb37-028d-10c2-7130-95ae03e3a662@posteo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27044"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 To: 47294@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 21 15:30:21 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lNz5w-0006vI-98 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 21 Mar 2021 15:30:20 +0100 Original-Received: from localhost ([::1]:43450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNz5v-0005ar-79 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 21 Mar 2021 10:30:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNz5e-0005ae-Pc for bug-gnu-emacs@gnu.org; Sun, 21 Mar 2021 10:30:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43672) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNz5e-0006Wv-Gx for bug-gnu-emacs@gnu.org; Sun, 21 Mar 2021 10:30:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lNz5e-0002hh-Dj for bug-gnu-emacs@gnu.org; Sun, 21 Mar 2021 10:30:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Clemens Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 21 Mar 2021 14:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 47294 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.161633699810355 (code B ref -1); Sun, 21 Mar 2021 14:30:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 Mar 2021 14:29:58 +0000 Original-Received: from localhost ([127.0.0.1]:55218 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lNz5Z-0002gx-Np for submit@debbugs.gnu.org; Sun, 21 Mar 2021 10:29:57 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:45058) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lNz5Y-0002go-6Y for submit@debbugs.gnu.org; Sun, 21 Mar 2021 10:29:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNz5X-0005aA-VJ for bug-gnu-emacs@gnu.org; Sun, 21 Mar 2021 10:29:55 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:46342) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNz5V-0006Op-Ex for bug-gnu-emacs@gnu.org; Sun, 21 Mar 2021 10:29:55 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id F2A42160060 for ; Sun, 21 Mar 2021 15:29:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1616336990; bh=GzmOjm9WoYChEA8OGf8xknKVC2HRzScMqOwSpTWFL5Y=; h=To:Subject:From:Date:From; b=R/u8KHdSSdX3mp2jNwsQU8jZwNOEJRfeVyszJxOaZqTJriS1WoRZlZDJpnSTtR0Jb u75oqCTPW6sjn4+H/xJAz8qBlRmZIraYIz7p7ZPL37yRrtaquTikp+e4KfKcuhrJOn R47mui/2uaggEQk6Sg8odGXA0pzkK5QpNHNiSRFlSXNwEgR+WV56MzARcuxCsL6hvB koFCKSOiuXCMl8aVPTT5BqgVKmY+2khyNrLew/EunhLWcItKZbxyG6Rds1AtLD08Hg zihiTOhIAa+gp87waGq48W2LwwK0ZhzX+Vh2DzEUxzet8qo59QWuPY6+KtEtH+sfcz D2Cl3gOaib4pA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4F3Kld3l1Jz6tmd for ; Sun, 21 Mar 2021 15:29:49 +0100 (CET) Content-Language: en-US Received-SPF: pass client-ip=185.67.36.65; envelope-from=clemera@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:202775 Archived-At: 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))))))))) ```