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: Add -other-window variants of project-prefix-map commands Date: Sat, 04 Jul 2020 23:13:58 -0700 Message-ID: <87tuymh4k9.fsf@iris.silentflame.com> References: <87blkw5cd3.fsf@iris.silentflame.com> 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="25852"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dgutov@yandex.ru, juri@linkov.net To: 42210@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 05 08:15:15 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 1jrxvm-0006dL-D6 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Jul 2020 08:15:15 +0200 Original-Received: from localhost ([::1]:56986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrxvl-0001tW-7n for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Jul 2020 02:15:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrxvc-0001s4-4o for bug-gnu-emacs@gnu.org; Sun, 05 Jul 2020 02:15:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48381) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jrxvb-0004j7-Rr for bug-gnu-emacs@gnu.org; Sun, 05 Jul 2020 02:15:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jrxva-00057V-88; Sun, 05 Jul 2020 02:15:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: juri@linkov.net, dgutov@yandex.ru, bug-gnu-emacs@gnu.org Resent-Date: Sun, 05 Jul 2020 06:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 42210 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: juri@linkov.net, dgutov@yandex.ru Original-Received: via spool by submit@debbugs.gnu.org id=B.159392964819597 (code B ref -1); Sun, 05 Jul 2020 06:15:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Jul 2020 06:14:08 +0000 Original-Received: from localhost ([127.0.0.1]:59924 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jrxuh-00055z-Oi for submit@debbugs.gnu.org; Sun, 05 Jul 2020 02:14:08 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:55466) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jrxuf-00055r-EZ for submit@debbugs.gnu.org; Sun, 05 Jul 2020 02:14:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46436) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrxuf-0001kY-9M for bug-gnu-emacs@gnu.org; Sun, 05 Jul 2020 02:14:05 -0400 Original-Received: from wnew1-smtp.messagingengine.com ([64.147.123.26]:60695) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrxud-0004J1-0h for bug-gnu-emacs@gnu.org; Sun, 05 Jul 2020 02:14:04 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.west.internal (Postfix) with ESMTP id C4BBFB61 for ; Sun, 5 Jul 2020 02:13:59 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 05 Jul 2020 02:13:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=from:to:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=fm3; bh=rw8ixvYeHzCGzTjnspoVzJkRIj JWuacy8KiPHdlQH2I=; b=HwzoRh6Izwj+sPhZZAH+Q3eP+8x+okzBBS9DZyWCeP ZV13GHiB7eoQUQg6BhRMLqMbJFInSREXN7W/YfCaNShtDRW+MVJvE6fs48JG7+9m 1cx2XlVrVuYf1FoUZLaCu8q9prIUWmMJi3IMPCKYreF5TDH9tWcHEM7f1RifRrn4 /DiMaek6tUOeHYS/a+yJDjitWwdiXyi0Cvqa98ajw0B/Oro65BPM65uMSy+T2bQT 57v0FZ0XYr3CfMdcJVDp4Sf6hAmk5Vy83DA/kWkt4yNyFlx34ez1I7N4nLTLoGfz XGzoYktARU45auXXHK7ecyVY3PGq1MXbGKfj16pAFKkA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=rw8ixv YeHzCGzTjnspoVzJkRIjJWuacy8KiPHdlQH2I=; b=QTdbREuRn4vRZ7rUk3JfW4 Iuempwcg8uWARWYE2rlvNp19SV0Q65zAD4FRlCyG1oyOMVOUZ1QO0uL3PLLKla+8 MRUmeuGFNmkvIiukwyIWlWZPdH7UxIOMG5xPBdkuejd2rxZTAsBRcoeMDqK8LX2F AtEX+z8XmEXGaFbaHQVKIMAqXZT2dAMcWoT1yuiZABagnsDtYQjOzmXbnAVoFulw ahdmjnM8WgyoRWXEo92u/XMZQ7EG59cj0Teug7jRoR5HD40d/zNWdBnfZ0EqCOuZ jamwCQV6eBN3SD8MaWZpQCApxUi3mTn7faDLE+QoIUXDLV8b8DWCYRgGsAe9/Opw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedruddtgddtkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecuogfhohhrsghiugguvghnufhorhhtjfgurhculdehtd dtmdenucfjughrpefhvffujghffffkgggtsehmtderredttddtnecuhfhrohhmpefuvggr nhcuhghhihhtthhonhcuoehsphifhhhithhtohhnsehsphifhhhithhtohhnrdhnrghmvg eqnecuggftrfgrthhtvghrnhepieffhfffudfhjefgfeeuleeutdevtdektdehiefgieet leevveekgeduhedtudefnecuhfhorhgsihguuggvnhfuohhrthfjughrpeffhffkuffvgg gjtghfsehmtderredttddtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomhepshhpfihhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgv X-ME-Proxy: In-Reply-To: <87blkw5cd3.fsf@iris.silentflame.com> Received-SPF: pass client-ip=64.147.123.26; envelope-from=spwhitton@spwhitton.name; helo=wnew1-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/05 02:14:00 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, 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:182728 Archived-At: --=-=-= Content-Type: text/plain Hello, On Fri 03 Jul 2020 at 05:54PM -07, Sean Whitton wrote: > It seems like it would be a good idea to have > > C-x 4 p f > be like > C-x 4 4 C-x p f > > C-x 5 p e > be like > C-x 5 5 C-x p e > > etc., since many of the commands in project-prefix-map involve switching > to another buffer. Certainly project-switch-project, project-find-file > and project-switch-to-buffer would be wanted. Here is a patch implementing commands under C-x 4 p. If the approach is thought sound I can also prepare patches for C-x 5 p and C-x t p. I have tested the attached change except for the autoload cookies which I am not sure will work with my new macro. And I'm not sure I should be doing this with a macro instead of a function which calls fset -- please advise. If you want me to do copyright assignment before investing time giving me feedback on my patch, I would be happy to. -- Sean Whitton --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-define-other-window-command-and-project-other-wi.patch >From bc52db3611612fc595793fd5f2aebd4a7d9bdb59 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 4 Jul 2020 22:40:36 -0700 Subject: [PATCH] Add define-other-window-command and project-other-window-prefix-map * lisp/progmodes/project.el: Add project-other-window-prefix-map, bind to C-x 4 p, and use define-other-window-command to define the map's commands. * lisp/window.el: Add define-other-window-command. --- lisp/progmodes/project.el | 28 ++++++++++++++++++++++++++++ lisp/window.el | 17 +++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 0a15939d24..3a0034b24a 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -512,6 +512,19 @@ project-prefix-map ;;;###autoload (define-key ctl-x-map "p" project-prefix-map) +;;;###autoload +(defvar project-other-window-prefix-map + (let ((map (make-sparse-keymap))) + (define-key map "f" 'project-find-file-other-window) + (define-key map "b" 'project-switch-to-buffer-other-window) + (define-key map "d" 'project-dired-other-window) + (define-key map "e" 'project-eshell-other-window) + (define-key map "p" 'project-switch-project-other-window) + map) + "Keymap for -other-window project commands.") + +;;;###autoload (define-key ctl-x-4-map "p" project-other-window-prefix-map) + (defun project--value-in-dir (var dir) (with-temp-buffer (setq default-directory dir) @@ -864,6 +877,21 @@ project-kill-buffers (length bufs) (project-root pr))) (mapc #'kill-buffer bufs)))) +;;;###autoload +(define-other-window-command project-find-file) + +;;;###autoload +(define-other-window-command project-switch-to-buffer) + +;;;###autoload +(define-other-window-command project-dired) + +;;;###autoload +(define-other-window-command project-eshell) + +;;;###autoload +(define-other-window-command project-switch-project) + ;;; Project list diff --git a/lisp/window.el b/lisp/window.el index 675aff041b..519e15ac79 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -4042,6 +4042,23 @@ same-window-prefix 'reuse))) (message "Display next command buffer in the same window...")) +(defmacro define-other-window-command (function) + "Define a version of FUNCTION which displays its buffer in another window. + +The new function will be named 'FUNCTION-other-window'." + (let ((other-window-function + (intern (concat (symbol-name function) "-other-window")))) + `(defun ,other-window-function (&rest args) + ,(concat "Like `" (symbol-name function) + "' but prefer to display resultant buffer in another window.") + ,@(if (commandp function) '((interactive)) '()) + (let ((display-buffer-overriding-action + '((display-buffer-pop-up-window) + (inhibit-same-window . t)))) + (if (called-interactively-p) + (call-interactively ',function) + (apply ',function args)))))) + ;; This should probably return non-nil when the selected window is part ;; of an atomic window whose root is the frame's root window. (defun one-window-p (&optional nomini all-frames) -- 2.26.2 --=-=-=--