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.bugs Subject: bug#41890: 28.0.50; [PATCH]: Add bindings for project.el Date: Thu, 18 Jun 2020 16:09:03 +0200 Message-ID: <87ftasea9s.fsf@warpmail.net> References: <87blljbarq.fsf@thornhill.no> 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="86979"; mail-complaints-to="usenet@ciao.gmane.io" Cc: juri@linkov.net To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 18 17:47:09 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 1jlwku-000MZH-BN for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 18 Jun 2020 17:47:09 +0200 Original-Received: from localhost ([::1]:40002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlwkt-00041Y-BV for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 18 Jun 2020 11:47:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33406) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlwfy-0004a7-H2 for bug-gnu-emacs@gnu.org; Thu, 18 Jun 2020 11:42:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42596) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlwfy-0000lO-7w for bug-gnu-emacs@gnu.org; Thu, 18 Jun 2020 11:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jlwfy-00050i-4a for bug-gnu-emacs@gnu.org; Thu, 18 Jun 2020 11:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Philip K." Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 18 Jun 2020 15:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41890 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by submit@debbugs.gnu.org id=B.159249487619200 (code B ref -1); Thu, 18 Jun 2020 15:42:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 18 Jun 2020 15:41:16 +0000 Original-Received: from localhost ([127.0.0.1]:54142 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlwfE-0004zb-FD for submit@debbugs.gnu.org; Thu, 18 Jun 2020 11:41:16 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:47954) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlwfB-0004zT-LU for submit@debbugs.gnu.org; Thu, 18 Jun 2020 11:41:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlwfB-00044B-Av for bug-gnu-emacs@gnu.org; Thu, 18 Jun 2020 11:41:13 -0400 Original-Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:38113) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlwf7-0000eH-0f for bug-gnu-emacs@gnu.org; Thu, 18 Jun 2020 11:41:13 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id E7B8E90F for ; Thu, 18 Jun 2020 11:41:03 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 18 Jun 2020 11:41:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=warpmail.net; h= resent-from:resent-date:resent-to:from:to:cc:subject:in-reply-to :date:message-id:mime-version:content-type:resent-message-id; s= fm3; bh=N7WBnsWUed3wSLVdvyQdPu7BQ3/rOt8AgsijUq2kBrY=; b=hH7yY+JJ EHKnqrKZ2x1mfotGUFH9AEVSfIE+9Rc1sYU5/nPFAMHSADeAUN9EI/67xdCb+nSI I0BJbL9wJomdRKxBa4cj+ATQZXuErFOu4ICUqBTqW78058CbnHDVZmfXKZFJGweX M3FJa2tEx/omJQVt184TI/hMFTyogpC4SUpToXoXgdPDMEm3fnL8MjmXNnO6vb7B /f11KJwjNYky4gVJgferaOPaPUc0GKYkrnvevyAI2Rrs0bzU8qnwQNchkXBi6iTz N7x9tdBfV6hwEDmitlhap3AdbkD1/AEFYZGs5pvijB/awjNyBr6GMeee2d56M7eL IFP2uJtDyUdM0g== 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:resent-date:resent-from :resent-message-id:resent-to:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=N7WBnsWUed3wSLVdv yQdPu7BQ3/rOt8AgsijUq2kBrY=; b=f7GVBg4f8NRlXlPTHdKzmblXLpR3ybBLz zpWVeyYWu/NZ4IsWxZA77e9CZbBV6i0KfA5bQDUHghfzF7+BXtXoUgMZLOplrz4m euuWlVsb4ruYPaj7r7CJTpsitduJ4jbKX5SjXgRJKwEul0UJWJSQZ1jfHDHH2Nvl 27HUuAKZD/S40dRGCQTJBvkmhzZe4b9eXDo0PPzlFTql3HqL5uzt38dEjC3wh7To X2hFLUSD4PAaWi1bcdQkwT3LFRW9g615CyalSAvG39c0d99MzC7I9rqTlUesUQ8j N4u3KET+AreLRZ2fbJUpeu7XUh1ZiVoGu67NQuyKrf9jWOUhWlcRQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudejgedgledvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne fouhhlthhiphgrrhhtucgvrhhrohhrucdlfedtmdenucfjughrpefhvffujgffkfggtges mhdtreertddttdenucfhrhhomhepfdfrhhhilhhiphcumfdrfdcuoehphhhilhhiphesfi grrhhpmhgrihhlrdhnvghtqeenucggtffrrghtthgvrhhnpeejieeuvdellefffefgueet keelkeegveffieeffffhgfeuueehvdelvdeuvefhgeenucfkphepjeelrddvudelrddule elrddvudehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhho mhepphhhihhlihhpseifrghrphhmrghilhdrnhgvth X-ME-Proxy: Original-Received: from localhost (p4fdbc7d7.dip0.t-ipconnect.de [79.219.199.215]) by mail.messagingengine.com (Postfix) with ESMTPA id 0A79F3280059 for ; Thu, 18 Jun 2020 11:41:02 -0400 (EDT) Resent-From: philip@warpmail.net Resent-Date: 18 Jun 2020 17:41:00 +0200 Resent-To: bug-gnu-emacs@gnu.org In-Reply-To: <3ad1ecbb-36d6-79c0-7a7b-6ff3a561e512@yandex.ru> (message from Dmitry Gutov on Thu, 18 Jun 2020 01:06:49 +0300) X-Draft-From: ("gmane.emacs.devel" 252309) X-RMAIL-ATTRIBUTES: -------- Resent-Message-Id: <20200618154103.0A79F3280059@mailuser.nyi.internal> Received-SPF: pass client-ip=64.147.123.21; envelope-from=philip@warpmail.net; helo=wout5-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/18 11:41:04 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_TVD_MIME_EPI=0.01, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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:182115 Archived-At: --=-=-= Content-Type: text/plain Dmitry Gutov writes: > On 18.06.2020 00:05, Juri Linkov wrote: >>>> I tried implementig it, and it seems to work. The patch below isn't a >>>> full commit, since I changed the structure of project-switch-commands >>>> (it's now mapping command to description), but didn't update the >>>> docstring. >>> >>> This is looking pretty good. >> >> I agree. >> >>> It's a backward incompatibility, though. >> >> Not a problem since it was added recently. > > Here's another concern: right now, if the user types some other > character by accident, the command will keep showing the prompt until > the user hits one of the chars corresponding to the displayed options. > > If we just look in the (bigger) project keymap, in some cases we would > call commands that are not shown at the screen as a result of accidental > presses. And that's a negative. > > Perhaps we could add a user option that would default to the current > behavior? But then the implementation couldn't use the transient map, > though. The patch below fixes that, but allows changing if you only want the listed keys to be valid (the default) or every key in project-prefix-map. It turned out that the transiment map approach didn't work, as it ignored the value in default-directory, thus running all commands in whatever the current project was. -- Philip K. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Use-same-keys-in-project-switch-project-as-in-projec.patch >>From 608a94a2fee42b89b0ae395ce9d5622cb884d9d1 Mon Sep 17 00:00:00 2001 From: Philip K Date: Thu, 18 Jun 2020 16:06:19 +0200 Subject: [PATCH] Use same keys in project-switch-project as in project-prefix-map * project.el (project-switch-commands): Convert to user option and change structure. (project-switch-use-entire-map): Add new option. (project--keymap-prompt): Adapt to change in project-switch-commands (project-switch-project): Use project-prefix-map instead of project-switch-commands to query valid commands. --- lisp/progmodes/project.el | 63 +++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index e24d81c1b4..33946f78a8 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -900,27 +900,46 @@ project-prompt-project-dir ;;; Project switching ;;;###autoload -(defvar project-switch-commands - '((?f "Find file" project-find-file) - (?g "Find regexp" project-find-regexp) - (?d "Dired" project-dired) - (?v "VC-Dir" project-vc-dir) - (?e "Eshell" project-eshell)) - "Alist mapping keys to project switching menu entries. +(defcustom project-switch-commands + '((project-find-file . "Find file") + (project-find-regexp . "Find regexp") + (project-dired . "Dired") + (project-vc-dir . "VC-Dir") + (project-shell . "Shell") + (project-eshell . "Eshell")) + "Alist mapping commands to descriptions. 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.") +Each element looks like (COMMAND LABEL), where COMMAND should be +bound in `project-prefix-map'. LABEL is used to distinguish the +choice in the dispatch menu." + :type '(alist :key-type function + :value-type string) + :options (mapcan (lambda (ent) + (and (commandp (cdr ent)) + (list (cdr ent)))) + (cdr project-prefix-map)) + :version "28.1") + +(defcustom project-switch-use-entire-map t + "Make `project-switch-project' use entire `project-prefix-map'. +If nil, `project-switch-project' will only recognize commands +listed in `project-switch-commands', and signal an error when +others are invoked. Otherwise, all keys in +`project-switch-commands', are legal even if they aren't listed +in the minibuffer." + :type 'bool + :version "28.1") (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)) + (pcase-lambda (`(,cmd . ,label)) + (let ((key (where-is-internal cmd project-prefix-map t))) + (format "[%s] %s" + (propertize (key-description key) 'face 'bold) + label))) project-switch-commands " ")) @@ -930,14 +949,14 @@ 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 choice) - (setq choice (assq (read-event (project--keymap-prompt)) - project-switch-commands))) - (let ((default-directory dir) - (project-current-inhibit-prompt t)) - (call-interactively (nth 2 choice))))) + (let* ((default-directory (project-prompt-project-dir)) + (project-current-inhibit-prompt t) + (key (read-key-sequence-vector (project--keymap-prompt))) + (cmd (lookup-key project-prefix-map key))) + (if (and cmd (or project-switch-use-entire-map + (assq cmd project-switch-commands))) + (call-interactively cmd) + (user-error "%s is undefined" (key-description key))))) (provide 'project) ;;; project.el ends here -- 2.20.1 --=-=-=-- >>From nobody Thu Jun 18 16:11:26 2020 From: "Philip K." To: Dmitry Gutov Cc: contovob@tcd.ie, 41868@debbugs.gnu.org Subject: Re: bug#41868: [PATCH] Add project-clean-up command In-Reply-To: (message from Dmitry Gutov on Thu, 18 Jun 2020 16:04:17 +0300) X-Draft-From: ("gmane.emacs.devel" 252309) Date: Thu, 18 Jun 2020 16:11:26 +0200 Message-ID: <87d05wea5t.fsf@warpmail.net> MIME-Version: 1.0 Content-Type: text/plain Dmitry Gutov writes: > On 18.06.2020 09:46, Philip K. wrote: > >>> Thank you, I pushed with some minor changes. >>> >>> - Docstring further rephrased based on Basil's suggestion. >>> - The variable renamed to project-kill-buffers-skip-conditions, hope you >>> don't mind. >> >> I don't mind, I just thought that I had sent a patch fixing that >> already? > > If you did, I couldn't find it. Sorry. My mistake, it seems like I never sent the mail :/ But since it was mostly the same, it's irrelevant. >>> Should we add a key binding for it as well? >> >> I think 'k' in project-prefix-map would fit well, as soon as that gets >> merged. > > Sounds good. > > Unless we also wanted a project-scoped version of kill-buffer? I'm not sure how interesting that would be. Buf in that case, I think 'k' would be better for that command, and 'K' for kill all the buffers. -- Philip K.