From 99ca65c5cb743a3d925420c788cb93868418838b Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 2 Mar 2022 20:23:04 -0800 Subject: [PATCH] Change the visited file name of the renamed file's buffer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- p4-lowlevel.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/p4-lowlevel.el b/p4-lowlevel.el index dbcd402..8d9fb3f 100644 --- a/p4-lowlevel.el +++ b/p4-lowlevel.el @@ -35,6 +35,8 @@ ;;; Code: +(require 'subr-x) + (defgroup p4-lowlevel nil "Emacs-lisp interface to Perforce operations." :group 'tools) @@ -818,7 +820,10 @@ only on the server and not touch the local files." preview-args server-only-args (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)