Function: vc-setup-buffer

vc-setup-buffer is a byte-compiled function defined in vc-dispatcher.el.gz.

Signature

(vc-setup-buffer BUF)

Documentation

Prepare BUF for executing a slave command and make it current.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc-dispatcher.el.gz
(defun vc-setup-buffer (buf)
  "Prepare BUF for executing a slave command and make it current."
  (let ((camefrom (current-buffer))
	(olddir default-directory)
        (buf (get-buffer-create buf)))
    (set-buffer buf)
    (let ((oldproc (get-buffer-process (current-buffer))))
      ;; If we wanted to wait for oldproc to finish before doing
      ;; something, we'd have used vc-eval-after.
      ;; Use `delete-process' rather than `kill-process' because we don't
      ;; want any of its output to appear from now on.
      (when oldproc (delete-process oldproc)))
    (kill-all-local-variables)
    ;; Kill also this permanent local var in case the VC command that
    ;; created BUF was invoked from a different directory (bug#44698).
    (kill-local-variable 'file-local-variables-alist)
    ;; If we are refreshing an existing view,
    ;; don't throw away where we really came from (bug#59457).
    (unless (eq camefrom (current-buffer))
      (setq-local vc-parent-buffer camefrom)
      (setq-local vc-parent-buffer-name
                  (concat " from " (buffer-name camefrom))))

    (set-buffer-local-toplevel-value 'default-directory olddir)
    (let ((buffer-undo-list t)
          (inhibit-read-only t))
      (erase-buffer))))