Function: project-change-to-matching-directory

project-change-to-matching-directory is a byte-compiled function defined in project.el.gz.

Signature

(project-change-to-matching-directory CURRENT-PROJECT MIRROR-PROJECT)

Documentation

Change default directory to matching one under 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, it is an error.

This function is intended to be used as the value of project-find-matching-buffer-function.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/project.el.gz
;; Used by `diff-mode' and `log-view-mode'.
;; If the matching directory does not exist it's an error so that we
;; avoid invalidating the relative file names in Diff mode file headers.
(defun project-change-to-matching-directory (current-project mirror-project)
  "Change default directory to matching one under 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, it is an
error.

This function is intended to be used as the value of
`project-find-matching-buffer-function'."
  (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)))
    (if (file-directory-p mirror-name)
        (message "Default directory changed to `%s'"
                 (setq default-directory mirror-name))
      (user-error "`%s' not found in `%s'" relative-name mirror-root))))