From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: "Philip K." Newsgroups: gmane.emacs.devel Subject: Re: New feature in project.el: Remembering the previously used projects Date: Fri, 29 May 2020 09:31:34 +0200 Message-ID: <87eer3nqnd.fsf@warpmail.net> References: <6f0f6cc9-52f4-8383-9827-ead54e898472@yandex.ru> <87pnan8xuf.fsf@tcd.ie> <8834c5e9-90c7-a8ad-3dcd-b8fb95f99df5@yandex.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="29743"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: "Basil L. Contovounesios" , Simen =?utf-8?Q?Heggest?= =?utf-8?Q?=C3=B8yl?= , emacs-devel To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri May 29 09:32:23 2020 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 1jeZV9-0007ht-5d for ged-emacs-devel@m.gmane-mx.org; Fri, 29 May 2020 09:32:23 +0200 Original-Received: from localhost ([::1]:47778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeZV8-00008i-7K for ged-emacs-devel@m.gmane-mx.org; Fri, 29 May 2020 03:32:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeZUR-00086G-PU for emacs-devel@gnu.org; Fri, 29 May 2020 03:31:39 -0400 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:56643) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeZUQ-00063J-ED for emacs-devel@gnu.org; Fri, 29 May 2020 03:31:39 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 9AD2C5C00CE; Fri, 29 May 2020 03:31:37 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 29 May 2020 03:31:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=warpmail.net; h= from:to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; s=fm3; bh=O5wfYVxTud4Wogn+dX0/KnmH9Y 40PU/3+yVx3fNcx50=; b=Z0Q69k2Czz93f9urndQS/h/u0w2icIlVa2YgXIaQ7o e/DSWYM3Y6inRbt2lR9AlAg68QH6C4rRmRnYmPpaMwbhIVKDQGTEJ2hgpFF2H4ht kpwwRe8MFh9dc2A/1Vafh4fh77hxFk6Sah+so8JkRqtxyOp8mDq4kPo3IIkqzwE+ 1aYQgyLHeTpWFCstvLXVx0cv7UJW3vrnDuD9fn31KAM86RJT/RrMGTv3RO/plRwj mN+WASQDX872d7+WCnR4mlzHmpRUKGTai2izamjdVDlT46Y8j7thLZR4t0+7QEAs l/mDRKQgK0EKhdVTy/l9EIkNVxEz+7govXfK0LgiNqBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=O5wfYV xTud4Wogn+dX0/KnmH9Y40PU/3+yVx3fNcx50=; b=LGurKnYy6Ue63aH5ihe43n OrpLR9W51Xs9glsrSQ0JNCJjEt3pfSGFQf/bKMcqs6C7b69MXCfUOZe72nVKPHOK 5Cz77yrJrZ3FerNCgy94S/mowziz4T8ZyGB3xVXeiimmhvwYGyVztpfBSv5Jq1Kn kOYiLR+Y/3C1eV6LPnMUSmZJN0ooA8dAKHnPTHdcufcQzs439IxrzFHQMtmiUoxl rzyASN+Wvn99FnvDm1W7gpq729k1Gle+wWfwbnCzmM/lqvDeC6V98gMY4GYakYhu WaId9POrN47maF7CoAVS7MB2Lc1DXAGFm6HnwjiyQA9hD4KxpLXoX4ps19fvSTpQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedruddvjedgudduvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufhffjgfkfgggtgesmhdtreertdertdenucfhrhhomhepfdfrhhhi lhhiphcumfdrfdcuoehphhhilhhiphesfigrrhhpmhgrihhlrdhnvghtqeenucggtffrrg htthgvrhhnpeevieeggfekgefhledvjeeihedvgffhffdtiedvheejfeevledtfeegieek leefieenucfkphepjeelrddvudelrddvtdeirddvvdefnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomhepphhhihhlihhpseifrghrphhmrghilhdr nhgvth X-ME-Proxy: Original-Received: from localhost (p4fdbcedf.dip0.t-ipconnect.de [79.219.206.223]) by mail.messagingengine.com (Postfix) with ESMTPA id A56143280065; Fri, 29 May 2020 03:31:36 -0400 (EDT) In-Reply-To: <8834c5e9-90c7-a8ad-3dcd-b8fb95f99df5@yandex.ru> (Dmitry Gutov's message of "Fri, 29 May 2020 02:29:35 +0300") Received-SPF: pass client-ip=66.111.4.27; envelope-from=philip@warpmail.net; helo=out3-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/29 03:31:37 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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:251609 Archived-At: --=-=-= Content-Type: text/plain Dmitry Gutov writes: > On 29.05.2020 02:05, Basil L. Contovounesios wrote: >> Could project-switch-project reuse read-multiple-choice or similar? > > I'm attaching a patch that makes it use read-multiple-choice, check it > out. But I'm not sure the result looks better than what we have now. > > Suggestions on "similar" welcome. I tried to same thing last night, but didn't get around to submitting it in time. It's mosty the same, I just dropped project--keymap-prompt and changed the type of project-switch-commands, because it seemed easier that way. I think it can be improved by adding a "case-insenstive" option to read-multiple-choice, because for example currently it seems to highlight the second "f" in "Find file" ^ this one here ____________| I have tried something out, and will submit a patch right after this one. -- Philip K. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Reworked-project-switch-project-to-use-read-multiple.patch >From 8b320e00fbd89a3b8e9097b04cf307d3230e6ed6 Mon Sep 17 00:00:00 2001 From: Philip K Date: Fri, 29 May 2020 09:23:15 +0200 Subject: [PATCH] Reworked project-switch-project to use read-multiple-choice --- lisp/progmodes/project.el | 44 ++++++++++++++------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 92293d0e2d..cdc27d11f5 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -792,28 +792,21 @@ project-prompt-project-dir ;;; Project switching ;;;###autoload -(defvar project-switch-commands - '(("f" "Find file" project-find-file) - ("s" "Find regexp" project-find-regexp) - ("d" "Dired" project-dired) - ("e" "Eshell" project-eshell)) +(defcustom project-switch-commands + '((?f "Find file" project-find-file) + (?s "Find regexp" project-find-regexp) + (?d "Dired" project-dired) + (?e "Eshell" project-eshell)) "Alist mapping keys to project switching menu entries. Used by `project-switch-project' to construct a dispatch menu of commands available upon \"switching\" to another project. Each element looks like (KEY LABEL COMMAND), where COMMAND is the command to run when KEY is pressed. LABEL is used to distinguish -the choice in the dispatch menu.") - -(defun project--keymap-prompt () - "Return a prompt for the project swithing dispatch menu." - (mapconcat - (pcase-lambda (`(,key ,label)) - (format "[%s] %s" - (propertize (key-description `(,key)) 'face 'bold) - label)) - project-switch-commands - " ")) +the choice in the dispatch menu." + :type '(repeat (list (character :tag "Invocation Key") + (string :tag "Label") + (function :tag "Command")))) ;;;###autoload (defun project-switch-project () @@ -821,18 +814,13 @@ project-switch-project The available commands are picked from `project-switch-commands' and presented in a dispatch menu." (interactive) - (let ((dir (project-prompt-project-dir)) - (choice nil)) - (while (not (and choice - (or (equal choice (kbd "C-g")) - (assoc choice project-switch-commands)))) - (setq choice (read-key-sequence (project--keymap-prompt)))) - (if (equal choice (kbd "C-g")) - (message "Quit") - (let ((default-directory dir) - (project-current-inhibit-prompt t)) - (call-interactively - (nth 2 (assoc choice project-switch-commands))))))) + (let* ((default-directory (project-prompt-project-dir)) + (choice (read-multiple-choice + "Open project via" + (mapcar #'butlast project-switch-commands))) + (project-current-inhibit-prompt t)) + (call-interactively + (nth 2 (assq (car choice) project-switch-commands))))) (provide 'project) ;;; project.el ends here -- 2.20.1 --=-=-=--