>From 5a55c6376a5ccec957adee88e03503f651ee7448 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 23 Jul 2020 18:00:59 -0700 Subject: [PATCH 1/2] Add project-display-buffer and project-display-buffer-other-frame * lisp/progmodes/project.el (project-switch-to-buffer): Add optional switching-function argument. * lisp/progmodes/project.el (project-display-buffer, project-display-buffer-other-frame): Add commands. --- lisp/progmodes/project.el | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index a0930553bd..f47e6bcc1c 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -878,12 +878,15 @@ project-compile (compile command comint))) ;;;###autoload -(defun project-switch-to-buffer () +(defun project-switch-to-buffer (&optional switching-function) "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." +as reported by `project-current' in each buffer, are identical. + +Optional argument SWITCHING-FUNCTION is the function used to +switch the buffer. It defaults to `switch-to-buffer'." (interactive) (let* ((pr (project-current t)) (current-buffer (current-buffer)) @@ -896,7 +899,7 @@ project-switch-to-buffer (equal pr (with-current-buffer (cdr buffer) (project-current))))))) - (switch-to-buffer + (funcall (or switching-function #'switch-to-buffer) (read-buffer "Switch to buffer: " (when (funcall predicate (cons other-name other-buffer)) @@ -904,6 +907,24 @@ project-switch-to-buffer nil predicate)))) +;;;###autoload +(defun project-display-buffer () + "Display a buffer of the current project without selecting it. + +See `project-switch-to-buffer' for what it means for a buffer to +belong to the current project." + (interactive) + (project-switch-to-buffer #'display-buffer)) + +;;;###autoload +(defun project-display-buffer-other-frame () + "Display a buffer of the current project, preferably in another frame. + +See `project-switch-to-buffer' for what it means for a buffer to +belong to the current project." + (interactive) + (project-switch-to-buffer #'display-buffer-other-frame)) + (defcustom project-kill-buffers-ignores '("\\*Help\\*") "Conditions for buffers `project-kill-buffers' should not kill. -- 2.27.0