From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Boruch Baum Newsgroups: gmane.emacs.bugs Subject: bug#43709: minibuffer keybinding cheatsheet and launcher [CODE SUBMISSION] Date: Thu, 1 Oct 2020 11:31:47 -0400 Message-ID: <20201001153147.3ucillviu62t2prf@E15-2016.optimum.net> References: <20200929165957.ibj67dnyaem6nezg@E15-2016.optimum.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2404"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: NeoMutt/20180716 Cc: 43709@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 01 17:44:01 2020 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 1kO0kT-0000Va-7r for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Oct 2020 17:44:01 +0200 Original-Received: from localhost ([::1]:43386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kO0kS-0005It-07 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Oct 2020 11:44:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kO0Zq-0002FG-6F for bug-gnu-emacs@gnu.org; Thu, 01 Oct 2020 11:33:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54653) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kO0Zp-0002S9-Sq for bug-gnu-emacs@gnu.org; Thu, 01 Oct 2020 11:33:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kO0Zp-0005GO-Nf for bug-gnu-emacs@gnu.org; Thu, 01 Oct 2020 11:33:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Boruch Baum Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Oct 2020 15:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43709 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 43709-submit@debbugs.gnu.org id=B43709.160156632820156 (code B ref 43709); Thu, 01 Oct 2020 15:33:01 +0000 Original-Received: (at 43709) by debbugs.gnu.org; 1 Oct 2020 15:32:08 +0000 Original-Received: from localhost ([127.0.0.1]:37966 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kO0Yy-0005F1-43 for submit@debbugs.gnu.org; Thu, 01 Oct 2020 11:32:08 -0400 Original-Received: from mout.gmx.net ([212.227.17.20]:57541) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kO0Yv-0005EW-AP for 43709@debbugs.gnu.org; Thu, 01 Oct 2020 11:32:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1601566316; bh=xcgPch1ketr0lJMtVrK4zlCZQ3Sa6Qu/P8NYM7GtgYQ=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:References:In-Reply-To; b=UIZSmVEvSnfz4+eBYuT8qkpDf26KWhN0Z6UnUysff22rByEx+9sA7TvPXqFSryrH4 2ZIilHgLKTpwKB7EZspctSKcnNVrU9xZLkh8mk3eR9DuoC0t6o9xB382Z5sknbrrB7 lRRkb0/yYLDJiAY2BqfqU+P4G4dXccF1co2Nt1/g= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from E15-2016.optimum.net ([72.89.170.172]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1Mi2O1-1ksNVD3dbN-00e2Fm; Thu, 01 Oct 2020 17:31:56 +0200 Content-Disposition: inline In-Reply-To: X-Provags-ID: V03:K1:C+2r/LsSPPS0ul2FtJnLtGAA4MnY5ikxiDG1Nl86KSIRyWDWaME Tr1qQubajsUoGOVPtDGTwROBaB0aAkZSE1uaU2yoobBG2w94LVlg2Mr52fsGD2/dU3JfddL YHZN5PRznq7xhBwa1NkN4xllIDluwsXGE3pjFE/q/C3WXpczcCqGpU995agIRZU6fkwHV44 3N6MwupDG3Qm9UFoUdO9Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:Xam8xrCHQaE=:JiIFgfYk6TJok+BpPl2nWi I5ML5L2md84gh/394q8QwjAN+49P1TMqbwyFFuJcWj8ZVoP5IwMJ6zuo++pKN0+Nnt38HtGck 5fOGxRpfyyIIJrK+2OT6qWLOoh/MI9MMjrOyTMV9RpvelWpyUIK+BToce/58LiUv2UiivK1Mj LLHThBZ824ZuF8+v1OSdt4XPxDEIo06ldDRkgoaGfbLkXfdjbrnGOdeduEFMVMTiGEMKAiCvw XIcp3SPw+yGwvlt973KimFie9PxyUA4wE7wmodJmNHUERZRb06E3oBDXT6LT/Ftus9XRAh0fc mKkJm8vrDkNutqUfG2abAVrDz8ExGv6E7PVI6IHCtYqUqCDCb+YfTYQ8KHY0+K8ppPJwr/mGo 0RCt4vRraUuOyKo5FqTxr/RplSBLVenjzfxNSXKZ6+pN5nWeSTdFixgEOYcugphq6tZny/+rW 5jTUE8Crn/P1HTRxrilRacTK2Yg1PqPMHX5ncagt5dITxP5LhswHFyigGyKIyAj8VnQtuX9nX twhIp8ZSfb8k6W/5hJ4OWMV+9Ri91SKJRZacyDRiAeE5LavfjWD1x3M2FJi1VW5ZJOasimdvI g+TzcZtUJeuM5aIVBbUYkQpZOUcFKvn8NkJR9jPuxI7oBXIfwgbmpCH6e1B24dz6pg8UU5gTh Cpm4UWeRU8RQvU9Zqigtt/1xdoC3XGb+mBC1e+8eMsDe6EmCbdbyvOq38w93smZc057cZIKQk AsRKd4cNqDbomn+vbuHVZ3FiLmUjHiGE3qBFPQ6EaxEZWSVUY3ywqzQxIVFgiH7Iojun46qh 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:189522 Archived-At: On 2020-10-01 09:51, Stefan Monnier wrote: > I'm not completely sure what is the intended use scenario. 1) Interactively... 1.1) A user finds himself in an unfamiliar mode buffer, and isn't sure what that mode's options are and how to use them. You mention further that you tried it in a dired-mode, so you saw its default operation in such a case. For dired-mode, the result-list is very long; for other modes, such as occur-mode or a packages buffer, you'll get a shorter list. The more obscure the mode, the more useful this use-case. 1.2) A user has a vague idea of a command name of interest, so enters a regex or substring of it to see a list of keybindings and descriptions of matches (as relevant for the current buffer). 2) Programmatically... 2.1) A developer wants to offer a cheat sheet / launcher for a package (similar in function to transient/hydra) but with less programming. This package offers wide latitude of how to compose a command list, what to display, how to sort, how to prompt. The args can be trivially simple to quite complex. (defun my-mode-low-budget-transient () (interactive) (when (eq major-mode my-mode) (key-assist ...))) (define-key my-mode-map "?" 'my-mode-low-budget-transient) BTW, On the emacs-bug thread/URL, I shared with Drew Adams the original inspiration for the package, which includes the motivation for what seems like an obscure arg option (cmd . function) > [ To see why I say it's not quite ready, here's my experience with it: > I just tried it in a fresh new Emacs session, and after `M-x > key-assist` (which itself is a problem because most users won't > know/bother to run this command way, so we'd need some more "obvious" > way to run it) Always a problem with a new feature. When you say 'obvious', you seem to mean more than the normal publicizing of a new feature? > I get a prompt for something You mean the prompt "Optional: Enter command regexp or keymap name:"? > and without reading more the description I wouldn't know what the > prompt wants True of very many emacs commands. Not a justification though. It could be a multi-line verbose explanatory prompt. > (I think this prompt should only appear if requested explicitly) Reasonable. Could be argued both ways. I have no preference, and just thought it friendlier this way to explicitly present to the user all the options, especially since this is supposed to be a 'help' function. Programmatically, this prompt shouldn't ever appear. > and then it said "no choices found". That's curious. I haven't seen that in my testing. What was your response to the first prompt? What was the value of 'major-mode' of the 'current-buffer' when you ran the command? > So I tried again in a dired buffer, where it instead showed me a > minibuffer prompt "Select: " with no indication of what it is I > should be selecting, I had difficulty deciding what text to use for this prompt because many users can be expected to be using some non-default minibuffer completion supplemental package (eg. ido, icicles, ivy), and those all have slightly different behavior; many present a result-list without needing to TAB. > after that I hit TAB (because I read that it uses `completing-read`, > but for the un-initiated it might not be obvious) Again, true of very many emacs commands. Not a justification though. I'm not a regular on this list, but even slashdot.org is reporting that the list has been discussing making emacs friendlier to new users, and I'm on board with that, so I'll take any suggestions for improvement here, but it might be better done as a patch to 'completing-read'. > at which point it did show me a list of bindings and short > descriptions and when I selected the first entry (i.e. `!`) it > signal'd an error about wrong number of arguments. ] Got it. Thanks much for your concrete suggestion further down on how to correct this bug. Many of the other options *DO* work though; this is a bug in the improper way the function calls some interactive functions. > I do think it would be nice to have something like it, since it's an > alternative to the menus which has the advantage of being > auto-constructed, doesn't need the mouse, and focuses on the keybindings= . Yep. Also, for me it was important that it present command descriptions, even if in the end it came at the expense of omitting command names to make the strings shorter. > It would also be nice to make it usable from minibuffers as well ;-) Hmm, I wonder.. Maybe it already does programmatically on a per-case basis. Interactively, do you mean integrating into the minibuffer codebase? I've long wanted something like this for the minibuffer options to isearch- > See some comments below based on a quick look at the code. I appreciate the comments a lot. Thanks for the constructive review. > `where-is-internal` is supposed to return the shortest binding already > when asked to return the "firstonly". I wasn't getting my desired result with it.. > Your notion of length is slightly different, admittedly, but I wonder > what were the concrete cases that motivated doing your own sorting Oops. Forgetting just now. A secondary motivation for the sort was to offer multiple sort options. In the end, I left it as an option for programmers to pass their own sort function. For example, someone may want to treat prefixes / upper-case differently. > > (while (not (setq choice > > (cl-position > > (substring-no-properties ; Is -no-properties nece= ssary? > > (completing-read prompt choices nil t)) > > choices :test 'equal)))) > > Why do you have this loop? Doesn't the `require-match` arg of > `completing-read` make it unnecessary? I remember thinking so, too, and then needing to add the loop because completing-read was accepting a RET. My recollection is that it was sending an empty string to cl-position. > .... But besides all that, it's great, right? =2D- hkp://keys.gnupg.net CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0