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: Sat, 25 Jul 2020 22:15:30 -0700 Message-ID: <87365ec0wd.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> <87wo2swqx0.fsf@iris.silentflame.com> <837dusdstb.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="29267"; mail-complaints-to="usenet@ciao.gmane.io" Cc: contovob@tcd.ie, philip@warpmail.net, 41890@debbugs.gnu.org, 42210@debbugs.gnu.org, juri@linkov.net To: Eli Zaretskii , dgutov@yandex.ru Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 26 07:16: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 1jzZ19-0007VG-Rr for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Jul 2020 07:16:12 +0200 Original-Received: from localhost ([::1]:46588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jzZ18-0006tx-8Q for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Jul 2020 01:16:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jzZ10-0006th-I8 for bug-gnu-emacs@gnu.org; Sun, 26 Jul 2020 01:16:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40071) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jzZ10-0001pb-9I for bug-gnu-emacs@gnu.org; Sun, 26 Jul 2020 01:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jzZ10-0006xx-68 for bug-gnu-emacs@gnu.org; Sun, 26 Jul 2020 01:16: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: Sun, 26 Jul 2020 05:16: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.159574053926736 (code B ref 41890); Sun, 26 Jul 2020 05:16:02 +0000 Original-Received: (at 41890) by debbugs.gnu.org; 26 Jul 2020 05:15:39 +0000 Original-Received: from localhost ([127.0.0.1]:51615 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jzZ0c-0006x9-LH for submit@debbugs.gnu.org; Sun, 26 Jul 2020 01:15:39 -0400 Original-Received: from new1-smtp.messagingengine.com ([66.111.4.221]:39477) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jzZ0b-0006wu-76; Sun, 26 Jul 2020 01:15:38 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id E0AE5580246; Sun, 26 Jul 2020 01:15:31 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 26 Jul 2020 01:15:31 -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=sb2cPq3wvHPQlJRpL3v5b695Wv hP+6gzeL4JYENx/1o=; b=qXMnp4eg5SXG4w45Q0UFzZBimpOnIJGxTDeXVw8bC3 Uixjkd36JB8Ul17xowGjQGsEJ2rDjAuPZ+Vh2aQR/MT+Q/hqcKk8y8ROhXe3U2x1 nZVG0FqqUPvGljWSMhLDWAOjjAhfUqp4OzepgjCmIP7suOqAjvCthuD7D13Qb9iW J4EmRo9k6sBhbUG1svSWyXXGFIZSJX/cKSPC2XBNzETbPAT8tpFso3XNCBTeoViL 6q85YHcyiJFXPKb/Ygc6hfyXYtPaZ9RzAf8ycYfrALexrBZXSnSj4FDOwXxvoDTU a0qnQfJpndwcy+jg6PxqmKqqfiYxcUOEt2bqaP5Dos0w== 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=sb2cPq 3wvHPQlJRpL3v5b695WvhP+6gzeL4JYENx/1o=; b=Mj0bCOZS7d1Fq3+60o+QQl YKlq0wPcPrY1wnqBpD6UAKphqXjTGX2cIrT+XltALRkX9nFhB5St6F7EEFV2R3mn GkrAr13KcBO1uGWX2aSuiOcYP879M3SLcbQZ6gfn0Sd7ydEAbzVLQEBUFF9T7P9z wj19IZgz6DhC8HDtvwsuq6vUesARZeMBGy/CYMdeoWlqjbtsqEeOVPLNobhP4q5G XMPGZ3OCycUlsY8Ra0TyvS+Sasu4nWkwT1f67BRhelJxGu3LYxdBBuQMUIhHv8N9 WU74qW4yw5Hvh3s6/MOvYGzgpi8FcKpi9UeVh69iqcPAdaO9UANDoFikoI4sy2XA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrheeigdekkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenog fhohhrsghiugguvghnufhorhhtjfgurhculdehtddtmdenucfjughrpefhvffujghffffk gggtsehmtderredttddtnecuhfhrohhmpefuvggrnhcuhghhihhtthhonhcuoehsphifhh hithhtohhnsehsphifhhhithhtohhnrdhnrghmvgeqnecuggftrfgrthhtvghrnhepieff hfffudfhjefgfeeuleeutdevtdektdehiefgieetleevveekgeduhedtudefnecuhfhorh gsihguuggvnhfuohhrthfjughrpeffhffkuffvgggjtghfsehmtderredttddtnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhpfihhihhtth honhesshhpfihhihhtthhonhdrnhgrmhgv X-ME-Proxy: In-Reply-To: <837dusdstb.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:183564 Archived-At: --=-=-= Content-Type: text/plain Hello, On Sat 25 Jul 2020 at 09:14AM +03, Eli Zaretskii wrote: > This doc string should mention display-buffer, for the same reasons > and with the same surrounding test as how > project-display-buffer-other-frame mentions > display-buffer-other-frame. Thank you, fixed, along with fixing some references to function arguments which were incorrect in the previous series (they were 'buffer-or-name' in one place but 'buffer' in another). -- Sean Whitton --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v3-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 v3 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=v3-0002-Add-project-display-buffer-and-project-display-bu.patch >From 61fc6615a7c438777ca80f71934979dfd029f0de Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 24 Jul 2020 13:54:49 -0700 Subject: [PATCH v3 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 | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 9534eb2ef6..0288635fb8 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -904,7 +904,34 @@ project-switch-to-buffer project instances, as reported by `project-current' in each buffer, are identical." (interactive (list (project--read-project-buffer))) - (switch-to-buffer buffer)) + (switch-to-buffer buffer-or-name)) + +;;;###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. + +This function uses `display-buffer' as a subroutine, which see +for how it is determined where the buffer will be displayed." + (interactive (list (project--read-project-buffer))) + (display-buffer buffer-or-name)) + +;;;###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\\*") -- 2.27.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v3-0003-Add-project-other-place-commands.patch >From 5cc1998dc965d41955ebf8ee2deed7dbcd8e96a8 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 23 Jul 2020 18:55:42 -0700 Subject: [PATCH v3 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 0288635fb8..3efe0c1ce3 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 --=-=-=--