]> git.eshelyaron.com Git - emacs.git/commitdiff
New variable vc-followed-link
authorEshel Yaron <me@eshelyaron.com>
Tue, 8 Apr 2025 05:29:32 +0000 (07:29 +0200)
committerEshel Yaron <me@eshelyaron.com>
Tue, 8 Apr 2025 05:29:32 +0000 (07:29 +0200)
lisp/vc/vc-hooks.el

index f9fa3e1bd7ee7097f0997ed2dc05f1c677941e2f..0b81b5d1866a7aca01c26c794f17b99745dd8e54 100644 (file)
@@ -819,11 +819,15 @@ This function assumes that the file is registered."
                 (concat state-echo " under the " backend-name
                         " version control system"))))
 
+(defvar-local vc-followed-link nil)
+(put 'vc-followed-link 'risky-local-variable t)
+
 (defun vc-follow-link ()
   "If current buffer visits a symbolic link, visit the real file.
 If the real file is already visited in another buffer, make that buffer
 current, and kill the buffer that visits the link."
-  (let* ((true-buffer (find-buffer-visiting buffer-file-truename))
+  (let* ((link-name buffer-file-name)
+         (true-buffer (find-buffer-visiting buffer-file-truename))
         (this-buffer (current-buffer)))
     (if (eq true-buffer this-buffer)
        (let ((truename buffer-file-truename))
@@ -833,7 +837,8 @@ current, and kill the buffer that visits the link."
          ;; I'm not going to work out the details right now. -- rms.
          (set-buffer (find-file-noselect truename)))
       (set-buffer true-buffer)
-      (kill-buffer this-buffer))))
+      (kill-buffer this-buffer))
+    (setq vc-followed-link link-name)))
 
 (defun vc-default-find-file-hook (_backend)
   nil)