From: Sean Whitton <spwhitton@spwhitton.name>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 41890@debbugs.gnu.org, 42210@debbugs.gnu.org, juri@linkov.net,
contovob@tcd.ie, philip@warpmail.net, dgutov@yandex.ru
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 [thread overview]
Message-ID: <87wo2swqx0.fsf@iris.silentflame.com> (raw)
In-Reply-To: <83ft9gevt4.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 193 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: v2-0001-Factor-out-project-read-project-buffer-from-proje.patch --]
[-- Type: text/x-diff, Size: 2616 bytes --]
From 08394aa143a5e0fc627e259b4deee3a1c3317960 Mon Sep 17 00:00:00 2001
From: Sean Whitton <spwhitton@spwhitton.name>
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: v2-0002-Add-project-display-buffer-and-project-display-bu.patch --]
[-- Type: text/x-diff, Size: 1908 bytes --]
From a86e847607b281643603865c7231e52fb467da9c Mon Sep 17 00:00:00 2001
From: Sean Whitton <spwhitton@spwhitton.name>
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: v2-0003-Add-project-other-place-commands.patch --]
[-- Type: text/x-diff, Size: 3524 bytes --]
From f2b038a73a6868a0b6a3b1396ce670cdeeeb75cc Mon Sep 17 00:00:00 2001
From: Sean Whitton <spwhitton@spwhitton.name>
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
next prev parent reply other threads:[~2020-07-24 21:20 UTC|newest]
Thread overview: 110+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-16 9:49 bug#41890: 28.0.50; [PATCH]: Add bindings for project.el Theodor Thornhill
[not found] ` <83pn9z13xq.fsf@gnu.org>
2020-06-16 16:44 ` Theodor Thornhill
2020-06-16 17:16 ` Eli Zaretskii
2020-06-16 17:30 ` Theodor Thornhill
2020-06-16 18:14 ` Basil L. Contovounesios
2020-06-16 19:07 ` Theodor Thornhill
2020-06-16 19:12 ` Theodor Thornhill
2020-06-16 21:57 ` Juri Linkov
2020-06-16 22:47 ` Dmitry Gutov
2020-06-16 23:24 ` Juri Linkov
2020-06-16 23:42 ` Dmitry Gutov
2020-06-17 21:23 ` Juri Linkov
2020-06-17 22:16 ` Dmitry Gutov
2020-06-17 22:27 ` Juri Linkov
2020-06-17 22:38 ` Dmitry Gutov
2020-06-17 23:23 ` Juri Linkov
2020-06-17 23:36 ` Dmitry Gutov
2020-06-18 22:59 ` Juri Linkov
2020-06-18 23:08 ` Dmitry Gutov
2020-06-20 23:41 ` Juri Linkov
2020-06-21 0:25 ` Dmitry Gutov
2020-06-17 10:51 ` Philip K.
2020-06-16 20:31 ` Basil L. Contovounesios
2020-06-17 19:10 ` Theodor Thornhill
2020-06-17 19:40 ` Basil L. Contovounesios
2020-06-17 23:07 ` Dmitry Gutov
2020-06-16 21:23 ` Dmitry Gutov
2020-06-16 21:35 ` Dmitry Gutov
2020-06-17 14:28 ` Eli Zaretskii
2020-06-17 14:27 ` Eli Zaretskii
2020-06-17 15:49 ` Dmitry Gutov
2020-06-17 16:33 ` Eli Zaretskii
2020-06-17 22:23 ` Dmitry Gutov
2020-06-18 13:38 ` Eli Zaretskii
2020-06-18 15:47 ` Dmitry Gutov
2020-06-18 17:24 ` Eli Zaretskii
2020-06-18 18:18 ` Michael Albinus
2020-06-18 16:25 ` Stefan Monnier
2020-06-18 17:30 ` Eli Zaretskii
2020-06-18 18:22 ` Dmitry Gutov
2020-06-18 18:42 ` Eli Zaretskii
2020-06-18 18:54 ` Dmitry Gutov
2020-06-18 19:04 ` Eli Zaretskii
2020-06-18 21:12 ` Dmitry Gutov
2020-06-19 6:11 ` Eli Zaretskii
[not found] ` <3ad1ecbb-36d6-79c0-7a7b-6ff3a561e512@yandex.ru>
2020-06-18 14:09 ` Philip K.
2020-06-18 17:22 ` Basil L. Contovounesios
2020-06-18 18:50 ` Philip K.
2020-06-18 22:10 ` Juri Linkov
2020-06-18 23:01 ` Dmitry Gutov
2020-06-18 23:24 ` Juri Linkov
2020-06-18 23:31 ` Dmitry Gutov
2020-06-19 10:15 ` Simen Heggestøyl
2020-07-11 17:07 ` Sean Whitton
2020-07-12 15:18 ` Dmitry Gutov
2020-07-12 16:24 ` Sean Whitton
2020-07-12 20:12 ` Dmitry Gutov
2020-07-18 16:06 ` bug#42210: " Sean Whitton
2020-07-19 23:46 ` Dmitry Gutov
2020-07-20 0:30 ` Juri Linkov
2020-07-20 1:04 ` bug#41890: " Dmitry Gutov
2020-07-20 20:47 ` Juri Linkov
2020-07-20 21:00 ` Dmitry Gutov
2020-07-20 16:49 ` Sean Whitton
2020-07-20 20:41 ` bug#41890: " Juri Linkov
2020-07-20 21:02 ` Dmitry Gutov
2020-07-20 21:24 ` bug#41890: " Sean Whitton
2020-07-20 22:00 ` Dmitry Gutov
2020-07-21 0:33 ` Sean Whitton
2020-07-21 23:38 ` Juri Linkov
2020-07-22 0:38 ` Dmitry Gutov
2020-07-22 1:33 ` Sean Whitton
2020-07-22 19:28 ` bug#41890: " Sean Whitton
2020-07-23 23:46 ` Dmitry Gutov
2020-07-24 2:04 ` Sean Whitton
2020-07-24 6:01 ` bug#41890: " Eli Zaretskii
2020-07-24 15:12 ` Sean Whitton
2020-07-24 16:12 ` Eli Zaretskii
2020-07-24 21:20 ` Sean Whitton [this message]
2020-07-24 22:54 ` Dmitry Gutov
2020-07-24 23:13 ` Sean Whitton
2020-07-24 23:45 ` Dmitry Gutov
2020-07-25 6:14 ` Eli Zaretskii
2020-07-26 5:15 ` bug#41890: " Sean Whitton
2020-07-27 0:01 ` Dmitry Gutov
2020-07-22 1:31 ` Sean Whitton
2020-07-23 0:32 ` bug#41890: " Juri Linkov
2020-07-23 15:06 ` Sean Whitton
2020-07-20 10:21 ` Basil L. Contovounesios
2020-07-20 14:45 ` Eli Zaretskii
2020-07-12 23:48 ` Juri Linkov
2020-07-13 0:13 ` Dmitry Gutov
2020-07-13 0:23 ` Juri Linkov
2020-07-13 6:56 ` Philip K.
2020-07-13 10:47 ` Dmitry Gutov
2020-07-13 10:50 ` Dmitry Gutov
2020-07-13 11:02 ` Philip K.
2020-07-18 15:19 ` Sean Whitton
2020-07-13 23:49 ` Juri Linkov
2020-07-14 7:03 ` Philip K.
2020-07-14 22:34 ` Juri Linkov
2020-07-14 23:32 ` Dmitry Gutov
2020-07-15 23:59 ` Juri Linkov
2020-07-16 13:38 ` Dmitry Gutov
2020-07-15 19:21 ` Philip K.
2020-07-15 23:35 ` Dmitry Gutov
[not found] ` <902001d0-ab1c-b697-bfd0-b8ec195dc65f@yandex.ru>
2020-06-19 10:13 ` Simen Heggestøyl
2020-06-19 10:26 ` Philip K.
2020-06-19 10:50 ` Simen Heggestøyl
2020-06-19 12:25 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wo2swqx0.fsf@iris.silentflame.com \
--to=spwhitton@spwhitton.name \
--cc=41890@debbugs.gnu.org \
--cc=42210@debbugs.gnu.org \
--cc=contovob@tcd.ie \
--cc=dgutov@yandex.ru \
--cc=eliz@gnu.org \
--cc=juri@linkov.net \
--cc=philip@warpmail.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.