Function: vc--prompt-other-working-tree

vc--prompt-other-working-tree is a byte-compiled function defined in vc.el.gz.

Signature

(vc--prompt-other-working-tree BACKEND PROMPT &optional ALLOW-CURRENT)

Documentation

Invoke project-prompter to choose another working tree.

BACKEND is the VC backend. PROMPT is the prompt string for project-prompter. If ALLOW-CURRENT is non-nil, allow selecting the current working tree.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc.el.gz
(defun vc--prompt-other-working-tree (backend prompt &optional allow-current)
  "Invoke `project-prompter' to choose another working tree.
BACKEND is the VC backend.
PROMPT is the prompt string for `project-prompter'.
If ALLOW-CURRENT is non-nil, allow selecting the current working tree."
  ;; If there are no other working trees and ALLOW-CURRENT is non-nil we
  ;; still invoke the `project-prompter' and require the user to type
  ;; \\`RET', even though it's redundant.  Doing it this way means that
  ;; invoking the command on the current working tree works the same
  ;; whether or not there exist any other working trees.  In particular,
  ;; the number of keys you have to type is always the same.  It's more
  ;; ergonomic not to require the user to think about whether there are
  ;; other working trees when what they care about is doing something
  ;; with the current working tree: they can just type \\`RET' without
  ;; stopping to look at the echo area.
  (let ((trees (vc-call-backend backend 'known-other-working-trees))
        res)
    (require 'project)
    (cond* ((bind-and* (_ allow-current)
                       (p (project-current)))
            (push (project-root p) trees))
           ((null trees)
            (user-error
             (substitute-command-keys
              "No other working trees.  Use \\[vc-add-working-tree] to add one"))))
    (dolist (tree trees)
      (when-let* ((p (project-current nil tree)))
        (project-remember-project p nil t)))
    (setq res
          (funcall project-prompter
                   (if allow-current
                       (concat prompt " (default current working tree)")
                     prompt)
                   (lambda (k &optional _v)
                     (member (or (car-safe k) k) trees))
                   'require-known))
    (if (string-empty-p res) (vc-root-dir) res)))