From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sean Whitton Newsgroups: gmane.emacs.bugs Subject: bug#42210: bug#41890: 28.0.50; [PATCH]: Add bindings for project.el Date: Sat, 18 Jul 2020 09:06:25 -0700 Message-ID: <87y2ngg64e.fsf@iris.silentflame.com> References: <87mu50b43d.fsf@warpmail.net> <87pn92t1ye.fsf@iris.silentflame.com> <874kqcsnu5.fsf@iris.silentflame.com> <54a1ed24-9d0e-4671-eb70-9d8c253e7aac@yandex.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16849"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 41890@debbugs.gnu.org, 42210@debbugs.gnu.org, juri@linkov.net To: Dmitry Gutov , "Philip K." , "Basil L. Contovounesios" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 18 18:07:13 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 1jwpMn-0004HZ-0L for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Jul 2020 18:07:13 +0200 Original-Received: from localhost ([::1]:54108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jwpMm-0004eh-1W for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Jul 2020 12:07:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jwpMc-0004bb-IO for bug-gnu-emacs@gnu.org; Sat, 18 Jul 2020 12:07:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47687) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jwpMc-0000Fb-8C for bug-gnu-emacs@gnu.org; Sat, 18 Jul 2020 12:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jwpMc-0004Is-3c for bug-gnu-emacs@gnu.org; Sat, 18 Jul 2020 12:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Jul 2020 16:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42210 X-GNU-PR-Package: emacs Original-Received: via spool by 42210-submit@debbugs.gnu.org id=B42210.159508839616500 (code B ref 42210); Sat, 18 Jul 2020 16:07:02 +0000 Original-Received: (at 42210) by debbugs.gnu.org; 18 Jul 2020 16:06:36 +0000 Original-Received: from localhost ([127.0.0.1]:59232 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jwpMB-0004Hz-KX for submit@debbugs.gnu.org; Sat, 18 Jul 2020 12:06:36 -0400 Original-Received: from new1-smtp.messagingengine.com ([66.111.4.221]:57129) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jwpM8-0004He-O2; Sat, 18 Jul 2020 12:06:34 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 76F7F5809BE; Sat, 18 Jul 2020 12:06:27 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sat, 18 Jul 2020 12:06:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=fm3; bh=7PLsnE35wnNAk0su08Gl2/3ERF DxqZxfH3bu7zZMYXM=; b=ozkqTbmyYDhkuwT2kVMNha8q6V6PSX1+9yN3VwCgiW +n7kY4ArUdH5d9+1TU7FS8q7gnhAvsVYpLT+rFnsP+o55QqRuDvdZa5uiEJeqbpe fknKt6RxzYApahQ1KUY/hcfRY+aTXWvrKFOFIhUfspP2+195toOWHK1qjCX+AH7X p5A/XdIMK4FpN7IwJAC9wB2ASsCSS+Zrz6HY3xnFoglVlwbNZdD20cRuemYW/hC+ PTsytHmaW5m0N4NXXBPL1b1W+/pMNFlrqo0TpNXNzUMziK7/aUW8SXYRCQw2XC8u yWpsPcQiL60/MkbcjPw3YT8PvxZ7YCiRWwrUSP5FWr3A== 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=fm3; bh=7PLsnE 35wnNAk0su08Gl2/3ERFDxqZxfH3bu7zZMYXM=; b=C6JcWZ0mq8tIUHPbPG/k6Y jXYwQVB0w/vYk58bW6gZhJ80JhBpaSP+osUAD7asnBqBwn8J02wLOqRbqQldLR30 cN2azeM5KLtkY2E2FuYHPBa9uouY9bjF7rSvlGh4ElBrvqhw/fyfBgbJHkNPgGkT WAsp0C79tmwA59DeFb9I0TIpxj8zOCEmxbxfhLZNqbPxcRpOxFHIlMmcuqOJIYvr MkOHygsWrOZuClUA9eDoeC45ZFJGRrAAecONzb4oNjwdZcIU2U68bN1ZjvMVzoYJ azIIKSrSJZt/WK8Pl974/O737FlaSlLbt/gFX6TP4V3gS3/9gStjzK+gXo2+r43Q == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrfeelgdeliecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenog fhohhrsghiugguvghnufhorhhtjfgurhculdehtddtmdenucfjughrpefhvffujghffffk gggtsehmtderredttddtnecuhfhrohhmpefuvggrnhcuhghhihhtthhonhcuoehsphifhh hithhtohhnsehsphifhhhithhtohhnrdhnrghmvgeqnecuggftrfgrthhtvghrnhepieff hfffudfhjefgfeeuleeutdevtdektdehiefgieetleevveekgeduhedtudefnecuhfhorh gsihguuggvnhfuohhrthfjughrpeffhffkuffvgggjtghfsehmtderredttddtnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhpfihhihhtth honhesshhpfihhihhtthhonhdrnhgrmhgv X-ME-Proxy: In-Reply-To: <54a1ed24-9d0e-4671-eb70-9d8c253e7aac@yandex.ru> 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:183176 Archived-At: --=-=-= Content-Type: text/plain Hello Dmitry and others, On Sun 12 Jul 2020 at 11:12PM +03, Dmitry Gutov wrote: > There's no decision indeed. I'd like to know what people think, and if > there's no strong opinion, how the proposal would look in practice. > > So unless you're strapped for time, a prototype patch would help. Okay, here's a prototype. I had to rebase Philip's patch so I thought I might as well attach my version of that too. I have been wanting the new C-x 4 p bindings all week as C-x p f with fido-mode has replaced a lot of my use of C-x C-f, so I hope I can replace my use of C-x 4 f with C-x 4 p f soon :) -- Sean Whitton --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Use-same-keys-in-project-switch-project-as-in-projec.patch >From c9f20a5a547631ab12cd3cf8da2ca51b71cfb28e Mon Sep 17 00:00:00 2001 From: Philip K Date: Thu, 18 Jun 2020 16:06:19 +0200 Subject: [PATCH 1/2] 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 67ce3dc7d9..4f0233c8b7 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -974,27 +974,46 @@ project-known-project-roots ;;; 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 is of the form (KEY LABEL COMMAND), where COMMAND is the -command to run when KEY is pressed. LABEL is used to distinguish -the menu entries 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 " ")) @@ -1004,14 +1023,14 @@ project-switch-project The available commands are presented as a dispatch menu made from `project-switch-commands'." (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.27.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-WIP-Add-project-other-place-commands-and-functions-w.patch >From 37bc752289bd101ceb725446b425944630971f61 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 18 Jul 2020 08:59:19 -0700 Subject: [PATCH 2/2] WIP: Add project-other-place-commands and functions which use it --- lisp/progmodes/project.el | 51 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 4f0233c8b7..f67698ac96 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -985,6 +985,36 @@ project-switch-commands Used by `project-switch-project' to construct a dispatch menu of commands available upon \"switching\" to another project. +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") + +;; "other-place" because non-prototype patch will also add an entry +;; in ctl-x-5-map and under C-x t p +(defcustom project-other-place-commands + '((project-find-file . "Find file") + (project-switch-to-buffer . "Switch to buffer") + (project-dired . "Dired") + ;; Eshell uses the current window by default, but Shell defaults + ;; to using the other window. If a user has added an entry to + ;; `display-buffer-alist' for Shell, they probably want to add an + ;; entry here, too + (project-eshell . "Eshell") + (project-switch-project . "Switch project")) + "Alist mapping commands to descriptions. +Used by `project-other-window-command' to construct a dispatch menu of +commands available to be displayed in another window. + +Commands in this list should be ones which normally display their +buffer in the current window. + 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." @@ -1006,7 +1036,7 @@ project-switch-use-entire-map :type 'bool :version "28.1") -(defun project--keymap-prompt () +(defun project--keymap-prompt (cmds) "Return a prompt for the project swithing dispatch menu." (mapconcat (pcase-lambda (`(,cmd . ,label)) @@ -1014,7 +1044,7 @@ project--keymap-prompt (format "[%s] %s" (propertize (key-description key) 'face 'bold) label))) - project-switch-commands + cmds " ")) ;;;###autoload @@ -1025,12 +1055,27 @@ project-switch-project (interactive) (let* ((default-directory (project-prompt-project-dir)) (project-current-inhibit-prompt t) - (key (read-key-sequence-vector (project--keymap-prompt))) + (key (read-key-sequence-vector + (project--keymap-prompt project-switch-commands))) (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))))) +(defun project-other-window-command () + (interactive) + (let* ((key (read-key-sequence-vector + (project--keymap-prompt project-other-place-commands))) + (cmd (lookup-key project-prefix-map key))) + (if (and cmd (assq cmd project-other-place-commands)) + (let ((display-buffer-overriding-action + '((display-buffer-pop-up-window) + (inhibit-same-window . t)))) + (call-interactively cmd)) + (user-error "%s is undefined" (key-description key))))) + +;;;###autoload (define-key ctl-x-4-map "p" 'project-other-window-command) + (provide 'project) ;;; project.el ends here -- 2.27.0 --=-=-=--