Change the visited file name of the renamed file's buffer

If ‘p4-vc-rename-file’ is used and the file that's been renamed is open in a
buffer, change that buffer's visited file name so that when you switch to it and
start editing it, it doesn't save to the original file and your modifications
will have to be moved over.
This commit is contained in:
Tom Willemse 2022-03-02 20:23:04 -08:00
parent 4ecf8cd2bc
commit 99ca65c5cb

View file

@ -35,6 +35,8 @@
;;; Code: ;;; Code:
(require 'subr-x)
(defgroup p4-lowlevel nil (defgroup p4-lowlevel nil
"Emacs-lisp interface to Perforce operations." "Emacs-lisp interface to Perforce operations."
:group 'tools) :group 'tools)
@ -818,7 +820,10 @@ only on the server and not touch the local files."
preview-args preview-args
server-only-args server-only-args
(list from-file to-file)))) (list from-file to-file))))
(p4-lowlevel-command-or-error args))) (p4-lowlevel-command-or-error args)
(when-let* ((buffer (find-buffer-visiting from-file)))
(with-current-buffer buffer
(set-visited-file-name to-file)))))
(provide 'p4-lowlevel) (provide 'p4-lowlevel)