emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master b63c5a7 3/4: Add project other place commands


From: Dmitry Gutov
Subject: master b63c5a7 3/4: Add project other place commands
Date: Sun, 26 Jul 2020 19:57:27 -0400 (EDT)

branch: master
commit b63c5a7efc89c23230f53a346e29e72a9b4faafc
Author: Sean Whitton <spwhitton@spwhitton.name>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    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 (bug#42210).
---
 lisp/progmodes/project.el | 67 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index da3ab4d..8363dff 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -592,6 +592,73 @@ DIRS must contain directory names."
 
 ;;;###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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]