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: Thu, 23 Jul 2020 19:04:13 -0700 Message-ID: <878sf9u0rm.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> <87y2ngg64e.fsf@iris.silentflame.com> <99e82681-e645-2888-3d24-26698ee0c7e0@yandex.ru> <871rl6gmip.fsf@iris.silentflame.com> <874kq1d7wf.fsf@iris.silentflame.com> <87zh7s8mlv.fsf@mail.linkov.net> <87blk849lh.fsf@iris.silentflame.com> <87tuxz2vt8.fsf@iris.silentflame.com> <1d2621fe-2e06-cc2d-3c3f-b44d61427ac2@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="27618"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "Basil L. Contovounesios" , "Philip K." , 41890@debbugs.gnu.org, 42210@debbugs.gnu.org To: Dmitry Gutov , Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 24 04:05: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 1jyn5F-00075a-Eq for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 Jul 2020 04:05:13 +0200 Original-Received: from localhost ([::1]:55474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jyn5E-0004wf-GU for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Jul 2020 22:05:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jyn55-0004v3-3w for bug-gnu-emacs@gnu.org; Thu, 23 Jul 2020 22:05:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34829) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jyn54-0003NK-Qz for bug-gnu-emacs@gnu.org; Thu, 23 Jul 2020 22:05:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jyn54-0007PE-N3 for bug-gnu-emacs@gnu.org; Thu, 23 Jul 2020 22:05: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: Fri, 24 Jul 2020 02:05: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.159555626428412 (code B ref 42210); Fri, 24 Jul 2020 02:05:02 +0000 Original-Received: (at 42210) by debbugs.gnu.org; 24 Jul 2020 02:04:24 +0000 Original-Received: from localhost ([127.0.0.1]:46374 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jyn4S-0007O6-2a for submit@debbugs.gnu.org; Thu, 23 Jul 2020 22:04:24 -0400 Original-Received: from new2-smtp.messagingengine.com ([66.111.4.224]:46785) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jyn4O-0007Nm-U8; Thu, 23 Jul 2020 22:04:22 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id A72645801EB; Thu, 23 Jul 2020 22:04:15 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 23 Jul 2020 22:04:15 -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=aavMk66eQx9ZYn3YpJ79EQtPyg 3845N/U1qf18rDvKk=; b=CpolAEDld9FhlFsi8otHfhNgSKSJmg8tTYMjJvX0+O ujs6bVTv1cZs2FV9FxaeUpA8sKLsv/KWyyvW9DBQnWFo/uGpDkiMhed47HU42Rur 1Xp0TRg4IMeP/h7a8xfHp8EOg/8jTgaEoZtBF5y2zV7gwi4EqDmGbzGD602H+8fb oJ+mOl0sFsyL92H4C+7Y34h1HOM3pypJrp8/+G16AKuFEDTZfHPFewXSeI6c1sxd MDkXu/1kvgNPYnQkU6GyjwIsHA16ZFGsLFyQ5TL8J9J3gkcxEAUBXyQ0S40lM/Ci ba1XgMBTE/0SCvknBiuciiiZKhTT2XEyPwcspJKnGe6w== 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=aavMk6 6eQx9ZYn3YpJ79EQtPyg3845N/U1qf18rDvKk=; b=Xd0zDN4MXnPds3FozE9yc8 v+CJmIJy7GqBKS5hqZQiJhKF5eTm9k2I3dmiu32pc02AHuf/OMHTuB+hG07IocCA FifzNlir+Zag4McOVrymAjQnH5cq7aoKpv7dABXtGWjFX5QQgZDSHLYQvo+lTGud nzzvjgqXTfPCDt82BX5RhF6lWiDMTP/xMGHDyVswusBo6VevACijPmcAQStAbUmo CzXmNXEdMVMcUGG918sroknJRy5EFk1f6km49zPlqx/Kna6jcxduujzZ2I4puzNo CtlCdQI2O5DfYPoKjWv6OgyPkHE9JNCtym2Pllfw7VUv/95ULXnE8meUcm77alAw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrhedvgdehudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenog fhohhrsghiugguvghnufhorhhtjfgurhculdehtddtmdenucfjughrpefhvffujghffffk gggtsehmtderredttddtnecuhfhrohhmpefuvggrnhcuhghhihhtthhonhcuoehsphifhh hithhtohhnsehsphifhhhithhtohhnrdhnrghmvgeqnecuggftrfgrthhtvghrnhepieff hfffudfhjefgfeeuleeutdevtdektdehiefgieetleevveekgeduhedtudefnecuhfhorh gsihguuggvnhfuohhrthfjughrpeffhffkuffvgggjtghfsehmtderredttddtnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhpfihhihhtth honhesshhpfihhihhtthhonhdrnhgrmhgv X-ME-Proxy: In-Reply-To: <1d2621fe-2e06-cc2d-3c3f-b44d61427ac2@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:183470 Archived-At: --=-=-= Content-Type: text/plain Hello, On Fri 24 Jul 2020 at 02:46AM +03, Dmitry Gutov wrote: > On 22.07.2020 22:28, Sean Whitton wrote: >>> [...] > > Since we're struggling between the choices, and you don't feel a strong > attachment to the prompt either, yes, please. > > Then we can install it and maybe continue the discussion of an optional > patch which will add the prompt on top of it. Cool, what do you think to the attached? >> Hmm, a further complication: I would like to be able to bind C-x 4 p C-o >> to work like C-x 4 C-o. >> >> I think this could be achieved by having an additional keymap, and the >> command bound to C-x 4 p can look up keys in both project-prefix-map and >> this new keymap. > > Yup. The new keymap could inherit from project-prefix-map, then the > lookup should be just one funcall. In the end I didn't use inheritance; hopefully it is clear from the patch why I thought this would not be a good idea. -- Sean Whitton --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-project-display-buffer-and-project-display-buffe.patch >From 5a55c6376a5ccec957adee88e03503f651ee7448 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 23 Jul 2020 18:00:59 -0700 Subject: [PATCH 1/2] Add project-display-buffer and project-display-buffer-other-frame * lisp/progmodes/project.el (project-switch-to-buffer): Add optional switching-function argument. * lisp/progmodes/project.el (project-display-buffer, project-display-buffer-other-frame): Add commands. --- lisp/progmodes/project.el | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index a0930553bd..f47e6bcc1c 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -878,12 +878,15 @@ project-compile (compile command comint))) ;;;###autoload -(defun project-switch-to-buffer () +(defun project-switch-to-buffer (&optional switching-function) "Switch to another buffer belonging to the current project. This function prompts for another buffer, offering as candidates buffers that belong to the same project as the current buffer. Two buffers belong to the same project if their project instances, -as reported by `project-current' in each buffer, are identical." +as reported by `project-current' in each buffer, are identical. + +Optional argument SWITCHING-FUNCTION is the function used to +switch the buffer. It defaults to `switch-to-buffer'." (interactive) (let* ((pr (project-current t)) (current-buffer (current-buffer)) @@ -896,7 +899,7 @@ project-switch-to-buffer (equal pr (with-current-buffer (cdr buffer) (project-current))))))) - (switch-to-buffer + (funcall (or switching-function #'switch-to-buffer) (read-buffer "Switch to buffer: " (when (funcall predicate (cons other-name other-buffer)) @@ -904,6 +907,24 @@ project-switch-to-buffer nil predicate)))) +;;;###autoload +(defun project-display-buffer () + "Display a buffer of the current project without selecting it. + +See `project-switch-to-buffer' for what it means for a buffer to +belong to the current project." + (interactive) + (project-switch-to-buffer #'display-buffer)) + +;;;###autoload +(defun project-display-buffer-other-frame () + "Display a buffer of the current project, preferably in another frame. + +See `project-switch-to-buffer' for what it means for a buffer to +belong to the current project." + (interactive) + (project-switch-to-buffer #'display-buffer-other-frame)) + (defcustom project-kill-buffers-ignores '("\\*Help\\*") "Conditions for buffers `project-kill-buffers' should not kill. -- 2.27.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Add-project-other-place-commands.patch >From c303620b4a9c04771fe9188b500fc5a8e88c8ea6 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 23 Jul 2020 18:55:42 -0700 Subject: [PATCH 2/2] Add project other place commands * lisp/progmodes/project.el (project-other-window-map, project-other-frame-map, project--other-place-command, project-other-window-command, project-other-frame-command, project-other-tab-command): Add these functions and maps. * lisp/progmodes/project.el: Bind project-other-window-command to C-x 4 p, project-other-frame-command to C-x 5 p and project-other-tab-command to C-x t p. --- lisp/progmodes/project.el | 67 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index f47e6bcc1c..13b1eafe3e 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -592,6 +592,73 @@ project-prefix-map ;;;###autoload (define-key ctl-x-map "p" project-prefix-map) +;; We can't have these place-specific maps inherit from +;; project-prefix-map because project--other-place-command needs to +;; know which map the key binding came from, as if it came from one of +;; these maps, we don't want to set display-buffer-overriding-action + +(defvar project-other-window-map + (let ((map (make-sparse-keymap))) + (define-key map "\C-o" #'project-display-buffer) + map) + "Keymap for additional project commands to display in other windows.") + +(defvar project-other-frame-map + (let ((map (make-sparse-keymap))) + (define-key map "\C-o" #'project-display-buffer-other-frame) + map) + "Keymap for additional project commands to display in other frames.") + +(defun project--other-place-command (action &optional map) + (let* ((key (read-key-sequence-vector nil t)) + (place-cmd (lookup-key map key)) + (generic-cmd (lookup-key project-prefix-map key)) + (display-buffer-overriding-action (unless place-cmd action))) + (if-let ((cmd (or place-cmd generic-cmd))) + (call-interactively cmd) + (user-error "%s is undefined" (key-description key))))) + +;;;###autoload +(defun project-other-window-command () + "Invoke a project command but display its buffer in another window. + +The following commands are available: + +\\{project-prefix-map} +\\{project-other-window-map}" + (interactive) + (project--other-place-command '((display-buffer-pop-up-window) + (inhibit-same-window . t)) + project-other-window-map)) + +;;;###autoload (define-key ctl-x-4-map "p" #'project-other-window-command) + +;;;###autoload +(defun project-other-frame-command () + "Invoke a project command but display its buffer in another frame. + +The following commands are available: + +\\{project-prefix-map} +\\{project-other-frame-map}" + (interactive) + (project--other-place-command '((display-buffer-pop-up-frame)) + project-other-frame-map)) + +;;;###autoload (define-key ctl-x-5-map "p" #'project-other-frame-command) + +;;;###autoload +(defun project-other-tab-command () + "Invoke a project command but display its buffer in another tab. + +The following commands are available: + +\\{project-prefix-map}" + (interactive) + (project--other-place-command '((display-buffer-in-new-tab)))) + +;;;###autoload (define-key tab-prefix-map "p" #'project-other-tab-command) + (defun project--value-in-dir (var dir) (with-temp-buffer (setq default-directory dir) -- 2.27.0 --=-=-=--