diff options
| author | Sean Whitton | 2025-08-08 11:47:00 +0100 |
|---|---|---|
| committer | Sean Whitton | 2025-08-08 11:47:00 +0100 |
| commit | 560aee2fb2403a6c7205798e05725abda2bc5cbc (patch) | |
| tree | b2a7ac72cdb2c53070dc5a6e92b40bade48dec4c | |
| parent | 74cbe6d740ac4987c3835436aa98892c47dbc44c (diff) | |
| download | emacs-560aee2fb2403a6c7205798e05725abda2bc5cbc.tar.gz emacs-560aee2fb2403a6c7205798e05725abda2bc5cbc.zip | |
vc-move-working-tree: Also update VC-Dir buffers
* lisp/vc/vc.el (vc-move-working-tree): Also update VC-Dir
buffers to follow the working tree move.
| -rw-r--r-- | lisp/vc/vc-dir.el | 2 | ||||
| -rw-r--r-- | lisp/vc/vc.el | 29 |
2 files changed, 26 insertions, 5 deletions
diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 93a05412a04..80d6dd3a4ff 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el | |||
| @@ -194,7 +194,7 @@ That is, refreshing the VC-Dir buffer also hides `up-to-date' and | |||
| 194 | (cl-return buffer)))))))) | 194 | (cl-return buffer)))))))) |
| 195 | (or buf | 195 | (or buf |
| 196 | ;; Create a new buffer named BNAME. | 196 | ;; Create a new buffer named BNAME. |
| 197 | ;; We pass a filename to create-file-buffer because it is what | 197 | ;; We pass a filename to `create-file-buffer' because it is what |
| 198 | ;; the function expects, and also what uniquify needs (if active) | 198 | ;; the function expects, and also what uniquify needs (if active) |
| 199 | (with-current-buffer (create-file-buffer (expand-file-name bname dir)) | 199 | (with-current-buffer (create-file-buffer (expand-file-name bname dir)) |
| 200 | (setq default-directory dir) | 200 | (setq default-directory dir) |
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 4fe87d860d1..63a4fafc56c 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el | |||
| @@ -4472,8 +4472,8 @@ BACKEND is the VC backend." | |||
| 4472 | (defun vc-move-working-tree (backend from to) | 4472 | (defun vc-move-working-tree (backend from to) |
| 4473 | "Relocate a working tree from FROM to TO, two directory file names. | 4473 | "Relocate a working tree from FROM to TO, two directory file names. |
| 4474 | Must be called from within an existing VC working tree. | 4474 | Must be called from within an existing VC working tree. |
| 4475 | When called interactively, prompts the directory file names of each of | 4475 | When called interactively, prompts for the directory file names of each |
| 4476 | the other working trees FROM and TO. | 4476 | of the other working trees FROM and TO. |
| 4477 | BACKEND is the VC backend." | 4477 | BACKEND is the VC backend." |
| 4478 | (interactive | 4478 | (interactive |
| 4479 | (let ((backend (vc-responsible-backend default-directory))) | 4479 | (let ((backend (vc-responsible-backend default-directory))) |
| @@ -4486,8 +4486,29 @@ BACKEND is the VC backend." | |||
| 4486 | (vc-call-backend backend 'move-working-tree from to) | 4486 | (vc-call-backend backend 'move-working-tree from to) |
| 4487 | 4487 | ||
| 4488 | ;; Update visited file names for buffers visiting files under FROM. | 4488 | ;; Update visited file names for buffers visiting files under FROM. |
| 4489 | ;; FIXME: Also update VC-Dir buffers. | 4489 | (let ((from (expand-file-name from))) |
| 4490 | (dired-rename-subdir (expand-file-name from) (expand-file-name to)) | 4490 | (dired-rename-subdir from (expand-file-name to)) |
| 4491 | (dolist (buf vc-dir-buffers) | ||
| 4492 | (with-current-buffer buf | ||
| 4493 | (when (string-prefix-p from default-directory) | ||
| 4494 | (setq default-directory | ||
| 4495 | (expand-file-name (file-relative-name default-directory from) | ||
| 4496 | to)) | ||
| 4497 | ;; Obtain an appropriately uniquify'd name for a *vc-dir* | ||
| 4498 | ;; buffer in the new working tree. In particular if this | ||
| 4499 | ;; *vc-dir* buffer already has a uniquify'd name appropriate | ||
| 4500 | ;; for the old working tree, we must replace that. | ||
| 4501 | ;; See also `vc-dir-prepare-status-buffer'. | ||
| 4502 | ;; FIXME: There should be a way to get this information | ||
| 4503 | ;; without creating and killing a buffer. | ||
| 4504 | (let (name) | ||
| 4505 | (unwind-protect | ||
| 4506 | (setq name (buffer-name | ||
| 4507 | (create-file-buffer | ||
| 4508 | (expand-file-name "*vc-dir*" | ||
| 4509 | default-directory)))) | ||
| 4510 | (kill-buffer name)) | ||
| 4511 | (rename-buffer name)))))) | ||
| 4491 | 4512 | ||
| 4492 | (when-let* ((p (project-current nil to))) | 4513 | (when-let* ((p (project-current nil to))) |
| 4493 | (project-remember-project p))) | 4514 | (project-remember-project p))) |