From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.devel Subject: Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico Date: Mon, 12 Apr 2021 09:28:16 -0700 Message-ID: <87mtu3sc0v.fsf@ericabrahamsen.net> References: <9c9af088-580f-9fb1-4d79-237a74ce605c@inventati.org> <874kgkxxs0.fsf@posteo.net> <87blamp5hy.fsf@posteo.net> <2ce73f33-8675-211a-9eb7-ea63de1a161e@yandex.ru> <871rbh6pd4.fsf@posteo.net> <87sg3w6co0.fsf@posteo.net> <87pmyz4xom.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18486"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org, Dmitry Gutov To: Philip Kaludercic Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Apr 12 18:29:10 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lVzQz-0004iw-S0 for ged-emacs-devel@m.gmane-mx.org; Mon, 12 Apr 2021 18:29:09 +0200 Original-Received: from localhost ([::1]:55098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lVzQy-0000W6-Q1 for ged-emacs-devel@m.gmane-mx.org; Mon, 12 Apr 2021 12:29:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVzQM-0008W3-GB for emacs-devel@gnu.org; Mon, 12 Apr 2021 12:28:30 -0400 Original-Received: from ericabrahamsen.net ([52.70.2.18]:40034 helo=mail.ericabrahamsen.net) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVzQK-0006I1-IV for emacs-devel@gnu.org; Mon, 12 Apr 2021 12:28:30 -0400 Original-Received: from localhost (c-71-197-184-122.hsd1.wa.comcast.net [71.197.184.122]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 522FBFA099; Mon, 12 Apr 2021 16:28:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericabrahamsen.net; s=mail; t=1618244898; bh=yRt/dva/USG9haLBYqFXcZaBPobijmY87n5kEqXs7Fg=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=KiZErssTVhzFtzl7Isro9DAwuAhYi9ED6CuxUrWLkVi9HJoRN4iLZ32knAi0V1zgW 4Yn7UFBqkxIXEKJa24IHRfP72DJWHMUyVspSGyZsCI3zxx2yN5tIzT8kf7DxHrKXAM pd/d/pKqgAukgNIxmZgsgtR9iUSpeXOhD6dm2HJM= In-Reply-To: <87pmyz4xom.fsf@posteo.net> (Philip Kaludercic's message of "Mon, 12 Apr 2021 12:14:17 +0200") Received-SPF: pass client-ip=52.70.2.18; envelope-from=eric@ericabrahamsen.net; helo=mail.ericabrahamsen.net 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: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:267966 Archived-At: Philip Kaludercic writes: > Jean Louis writes: > >> * Philip Kaludercic [2021-04-11 18:53]: >>> Jean Louis writes: >>>=20 >>> > One way I use for complex data structures is to have some kind of ID >>> > and visual description, then by using the ID I fetch the data >>> > structure later. >>>=20 >>> I'm not sure I completely understood your example. What do hash tables >>> offer over lists of objects that can have a programmed >>> representation? >> >> Completing read supports hash tables, once representation candidate >> has been selected one can then use the key to get value of some quite >> different or very complex data structure. >> >> (setq h (make-hash-table :test 'equal)) >> (puthash "United States" [("ABC" 30 t)] h) >> (puthash "Australia" 2 h) >> (puthash "United Kingdom" 3 h) >> >> (message "%s" (gethash (completing-read "Choice: " h) h)) =E2=87=92 "[(A= BC 30 t)]" > > But don't you think that it is weird that completing-read returns the > representation and not the object itself. That is exactly what I want to > avoid by having the representation computed using a method. > > The best I can think of is using hash-maps to generate anonymous methods > but even that seems to be looking at the issue backwards. This is my main complaint with `completing-read' -- you can pass it data structures like alists or hash tables, but you still only get the string keys back out of it. In the past I've imagined being able to pass a lambda to `completing-read' (as if it didn't have enough arguments) that would be used to extract the desired value. If we're going to build an ad-hoc structure specifically for completion, we could just build it inside the call to `completing-read', and it could do the caching and value extraction.