Function: project-find-matching-buffer

project-find-matching-buffer is an autoloaded, interactive and byte-compiled function defined in project.el.gz.

Signature

(project-find-matching-buffer)

Documentation

Switch to a matching buffer in another project.

For most file-visiting buffers, the matching buffer is one visiting a file in the other project which has the same file name relative to the project root. See project-find-matching-file for details. Non-file-visiting major modes may configure a different notion of matching buffer; see project-find-matching-buffer-function.

When called during switching to another project, this command will detect that, and use the override. Otherwise, it prompts for the project to use from the list of known projects. When calling from Lisp, bind project-current-directory-override to a directory under the target project to preempt this prompting.

Probably introduced at or before Emacs version 31.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/project.el.gz
;;;###autoload
(defun project-find-matching-buffer ()
  "Switch to a matching buffer in another project.
For most file-visiting buffers, the matching buffer is one visiting a
file in the other project which has the same file name relative to the
project root.  See `project-find-matching-file' for details.
Non-file-visiting major modes may configure a different notion of
matching buffer; see `project-find-matching-buffer-function'.

When called during switching to another project, this command will
detect that, and use the override.  Otherwise, it prompts for the
project to use from the list of known projects.
When calling from Lisp, bind `project-current-directory-override' to a
directory under the target project to preempt this prompting."
  (interactive)
  (let ((pr (project-current)))
    (apply project-find-matching-buffer-function
           (if project-current-directory-override
               (let (project-current-directory-override)
                 (list (project-current t) pr))
             (list pr (project-read-project))))))