Function: vc-dir-find-matching-buffer
vc-dir-find-matching-buffer is a byte-compiled function defined in
vc-dir.el.gz.
Signature
(vc-dir-find-matching-buffer CURRENT-PROJECT MIRROR-PROJECT)
Documentation
Visit VC-Dir buffer for matching directory in another project.
CURRENT-PROJECT is the project instance for the current project. MIRROR-PROJECT is the project instance for the project to visit. A matching directory has the same name relative to the project root. If a matching directory does not exist in the other project, try going up the directory tree until encountering a directory that exists.
This function is intended to be used as the value of
project-find-matching-buffer-function in VC-Dir buffers.
Source Code
;; Defined in /usr/src/emacs/lisp/vc/vc-dir.el.gz
(defun vc-dir-find-matching-buffer (current-project mirror-project)
"Visit VC-Dir buffer for matching directory in another project.
CURRENT-PROJECT is the project instance for the current project.
MIRROR-PROJECT is the project instance for the project to visit.
A matching directory has the same name relative to the project root.
If a matching directory does not exist in the other project, try going
up the directory tree until encountering a directory that exists.
This function is intended to be used as the value of
`project-find-matching-buffer-function' in VC-Dir buffers."
(let* ((mirror-root (project-root mirror-project))
(relative-name (file-relative-name default-directory
(project-root current-project)))
(mirror-name (expand-file-name relative-name mirror-root))
(orig-mirror-name mirror-name))
(while (not (file-directory-p mirror-name))
(setq mirror-name (directory-file-name
(file-name-parent-directory mirror-name)))
(unless (file-in-directory-p mirror-name mirror-root)
(user-error "`%s' not found in `%s'" relative-name mirror-root)))
(vc-dir mirror-name)
(unless (equal mirror-name orig-mirror-name)
(message "`%s' not found; visiting VC-Dir for `%s' instead"
(abbreviate-file-name orig-mirror-name)
(abbreviate-file-name (file-name-as-directory mirror-name))))))