Subject: bug#42210: closed (Re: bug#42210: bug#41890: 28.0.50; [PATCH]: Add bindings for project.el)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 27 Jul 2020 00:02:02 +0000

Your bug report

#42210: Add -other-window variants of project-prefix-map commands

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
42210: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=42210
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#42210: bug#41890: 28.0.50; [PATCH]: Add bindings for project.el
From: Dmitry Gutov <[email-masked]>
To: Sean Whitton <[email-masked]>, Eli Zaretskii <[email-masked]>
Cc: [email-masked], [email-masked], [email-masked], [email-masked], [email-masked]
Date: Mon, 27 Jul 2020 03:01:06 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

On 26.07.2020 08:15, Sean Whitton wrote:

> 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).

Applied and pushed. Thanks all!

With that, I'm closing the associated bug report.

Please file new reports for any follow-up patches.

Subject: Add -other-window variants of project-prefix-map commands
From: Sean Whitton <[email-masked]>
To: [email-masked]
Date: Sat, 04 Jul 2020 23:13:58 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

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
>From bc52db3611612fc595793fd5f2aebd4a7d9bdb59 Mon Sep 17 00:00:00 2001
From: Sean Whitton <[email-masked]>
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