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#41890: bug#42210: bug#41890: 28.0.50; [PATCH]: Add bindings for project.el Date: Fri, 24 Jul 2020 14:20:59 -0700 Message-ID: <87wo2swqx0.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> <878sf9u0rm.fsf@iris.silentflame.com> <83sgdhe9jc.fsf@gnu.org> <871rl1t0aa.fsf@iris.silentflame.com> <83ft9gevt4.fsf@gnu.org> 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="12106"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 41890@debbugs.gnu.org, 42210@debbugs.gnu.org, juri@linkov.net, contovob@tcd.ie, philip@warpmail.net, dgutov@yandex.ru To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 24 23:22: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 1jz58t-000311-NH for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 Jul 2020 23:22:12 +0200 Original-Received: from localhost ([::1]:58884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jz58s-0004xG-9J for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 Jul 2020 17:22:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jz58k-0004wq-Kn for bug-gnu-emacs@gnu.org; Fri, 24 Jul 2020 17:22:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37264) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jz58k-00009g-BL for bug-gnu-emacs@gnu.org; Fri, 24 Jul 2020 17:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jz58k-0007QZ-6q for bug-gnu-emacs@gnu.org; Fri, 24 Jul 2020 17:22: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 21:22: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 41890-submit@debbugs.gnu.org id=B41890.159562567128483 (code B ref 41890); Fri, 24 Jul 2020 21:22:02 +0000 Original-Received: (at 41890) by debbugs.gnu.org; 24 Jul 2020 21:21:11 +0000 Original-Received: from localhost ([127.0.0.1]:48808 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jz57u-0007PJ-S1 for submit@debbugs.gnu.org; Fri, 24 Jul 2020 17:21:11 -0400 Original-Received: from new1-smtp.messagingengine.com ([66.111.4.221]:50363) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jz57r-0007Os-76; Fri, 24 Jul 2020 17:21:09 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 21B0D58052C; Fri, 24 Jul 2020 17:21:02 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 24 Jul 2020 17:21:02 -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=IK/2gPXXPBNscTmc1cNdW3O1hF O2g4AjsJt5bI45Q4A=; b=FwbrS/1SY58eQ5FweXbM1Z6puq5BRljZiqgla7zN5W H1VqYpddXx5/MU0Ftya6au+I0E0b1JXIelbC2FfflF9DJ0GnQ6/HuifffbNDSDgz vdbO6T2cT3fzaLTXVz2Z0qrsJnqDXJiNjYOGfvUHa6t/iKICrBwiGDh/QtIJrCKa n0liDxfBNL/voW2uEJAlKAP+Y9cWymtqHuPPrFNbnhzBM1W691SPFaLN5hzHiYXt 4m15baLL5qbUlqYCeZEuGsph0WpTc/GRwaWvOBjs3nOBsXopgaT/t0jaH1QIh1Nn OksSL9qY7ZLtoW6JR7LHxn7g5ba+9GKSgfXUlVPqaDHw== 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=IK/2gP XXPBNscTmc1cNdW3O1hFO2g4AjsJt5bI45Q4A=; b=nKoqwHPuhjScqvMTuG72yn wiIPeeTDbw9/C3Ny2QVMNubX0C1DwZVh2SsUOi879ADLOEsnhZyqL7b8aEVBKVkE Xer7+eWPZWKe/HnqfWeu80K1KYaVULwH/flzOvP3lmtAGu53RJH5liFZdV8UEEyJ legUuURh2StS2O+jxa+GNTnaJFvGkv/qkFYC/1g58U87khP/t66nfZpovibGEckT aGri1yOHhslvTVrcatHYFj8Rn909pjBqbNjpFw4oj9NfC5xl5GXCP6NgS/gO9jLj 9vutjx/oAsas/ZK5gpzkScaKhFToV8+87mF08xhJpbfTaRn4rC1faMuCvwoYkQ9Q == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrheefgdduieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gohfhorhgsihguuggvnhfuohhrthfjughrucdlhedttddmnecujfgurhephffvufgjfhff kfggtgesmhdtreertddttdenucfhrhhomhepufgvrghnucghhhhithhtohhnuceoshhpfi hhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpeei fffhffduhfejgfefueeluedtvedtkedtheeigfeiteelveevkeegudehtddufeenucfhoh hrsghiugguvghnufhorhhtjfgurhepfffhkffuvfggjggtfhesmhdtreertddttdenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsphifhhhith htohhnsehsphifhhhithhtohhnrdhnrghmvg X-ME-Proxy: In-Reply-To: <83ft9gevt4.fsf@gnu.org> 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:183507 Archived-At: --=-=-= Content-Type: text/plain Hello, On Fri 24 Jul 2020 at 07:12PM +03, Eli Zaretskii wrote: > Just switch to that buffer, I think. Okay, then I think the attached addresses feedback received. Thanks! -- Sean Whitton --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0001-Factor-out-project-read-project-buffer-from-proje.patch >From 08394aa143a5e0fc627e259b4deee3a1c3317960 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 24 Jul 2020 13:36:39 -0700 Subject: [PATCH v2 1/3] Factor out project--read-project-buffer from project-switch-buffer * lisp/progmodes/project.el (project--read-project-buffer): New function extracted from project-switch-buffer. * lisp/progmodes/project.el (project-switch-buffer): Instead of unconditionally reading a project buffer from the user, add buffer-or-name argument, and populate it using project--read-project-buffer when called interactively. Update docstring. --- lisp/progmodes/project.el | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index a0930553bd..9534eb2ef6 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -877,14 +877,7 @@ project-compile (default-directory (project-root pr))) (compile command comint))) -;;;###autoload -(defun project-switch-to-buffer () - "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." - (interactive) +(defun project--read-project-buffer () (let* ((pr (project-current t)) (current-buffer (current-buffer)) (other-buffer (other-buffer current-buffer)) @@ -896,13 +889,22 @@ project-switch-to-buffer (equal pr (with-current-buffer (cdr buffer) (project-current))))))) - (switch-to-buffer - (read-buffer - "Switch to buffer: " - (when (funcall predicate (cons other-name other-buffer)) - other-name) - nil - predicate)))) + (read-buffer + "Switch to buffer: " + (when (funcall predicate (cons other-name other-buffer)) + other-name) + nil + predicate))) + +;;;###autoload +(defun project-switch-to-buffer (buffer-or-name) + "Display buffer BUFFER-OR-NAME in the selected window. +When called interactively, prompts for a buffer belonging to the +current project. Two buffers belong to the same project if their +project instances, as reported by `project-current' in each +buffer, are identical." + (interactive (list (project--read-project-buffer))) + (switch-to-buffer buffer)) (defcustom project-kill-buffers-ignores '("\\*Help\\*") -- 2.27.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Add-project-display-buffer-and-project-display-bu.patch >From a86e847607b281643603865c7231e52fb467da9c Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 24 Jul 2020 13:54:49 -0700 Subject: [PATCH v2 2/3] Add project-display-buffer and project-display-buffer-other-frame * lisp/progmodes/project.el (project-display-buffer, project-display-buffer-other-frame): Add commands. --- lisp/progmodes/project.el | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 9534eb2ef6..f674749497 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -906,6 +906,30 @@ project-switch-to-buffer (interactive (list (project--read-project-buffer))) (switch-to-buffer buffer)) +;;;###autoload +(defun project-display-buffer (buffer-or-name) + "Display BUFFER-OR-NAME in some window, without selecting it. +When called interactively, prompts for a buffer belonging to the +current project. Two buffers belong to the same project if their +project instances, as reported by `project-current' in each +buffer, are identical." + (interactive (list (project--read-project-buffer))) + (display-buffer buffer)) + +;;;###autoload +(defun project-display-buffer-other-frame (buffer-or-name) + "Display BUFFER-OR-NAME preferably in another frame. +When called interactively, prompts for a buffer belonging to the +current project. Two buffers belong to the same project if their +project instances, as reported by `project-current' in each +buffer, are identical. + +This function uses `display-buffer-other-frame' as a subroutine, +which see for how it is determined where the buffer will be +displayed." + (interactive (list (project--read-project-buffer))) + (display-buffer-other-frame buffer)) + (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=v2-0003-Add-project-other-place-commands.patch >From f2b038a73a6868a0b6a3b1396ce670cdeeeb75cc Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 23 Jul 2020 18:55:42 -0700 Subject: [PATCH v2 3/3] 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 f674749497..7a0bf1fdbf 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 project commands that display buffers 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 project commands that display buffers 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 () + "Run project command, displaying resultant 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 () + "Run project command, displaying resultant 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 () + "Run project command, displaying resultant buffer in a new 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 --=-=-=--