aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndré Spiegel1996-02-22 13:07:58 +0000
committerAndré Spiegel1996-02-22 13:07:58 +0000
commita3a3984834d8ea2c9bf4e47360ef56b454a77d95 (patch)
tree0994731fed75b42a548eee42bfa8c10241499a7d
parent6b5153b18a32e68b87090dec38bf03ef0f70218f (diff)
downloademacs-a3a3984834d8ea2c9bf4e47360ef56b454a77d95.tar.gz
emacs-a3a3984834d8ea2c9bf4e47360ef56b454a77d95.zip
(vc-follow-link): New function.
(vc-find-file-hook): Use it.
-rw-r--r--lisp/vc-hooks.el17
1 files changed, 14 insertions, 3 deletions
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el
index 429a74cd32a..f65a39fc5ec 100644
--- a/lisp/vc-hooks.el
+++ b/lisp/vc-hooks.el
@@ -919,6 +919,18 @@ control system name."
919 (t 919 (t
920 (concat ":" locker ":" rev))))) 920 (concat ":" locker ":" rev)))))
921 921
922(defun vc-follow-link ()
923 ;; If the current buffer visits a symbolic link, this function makes it
924 ;; visit the real file instead. If the real file is already visited in
925 ;; another buffer, make that buffer current, and kill the buffer
926 ;; that visits the link.
927 (let* ((truename (file-truename buffer-file-name))
928 (true-buffer (get-file-buffer truename)))
929 (if true-buffer
930 (set-buffer true-buffer)
931 (kill-buffer (current-buffer))
932 (set-buffer (find-file-noselect truename)))))
933
922;;; install a call to the above as a find-file hook 934;;; install a call to the above as a find-file hook
923(defun vc-find-file-hook () 935(defun vc-find-file-hook ()
924 ;; Recompute whether file is version controlled, 936 ;; Recompute whether file is version controlled,
@@ -943,14 +955,13 @@ control system name."
943 ((eq vc-follow-symlinks 'ask) 955 ((eq vc-follow-symlinks 'ask)
944 (if (yes-or-no-p (format 956 (if (yes-or-no-p (format
945 "Symbolic link to %s-controlled source file; follow link? " link-type)) 957 "Symbolic link to %s-controlled source file; follow link? " link-type))
946 (progn (setq buffer-file-name 958 (progn (vc-follow-link)
947 (file-truename buffer-file-name))
948 (message "Followed link to %s" buffer-file-name) 959 (message "Followed link to %s" buffer-file-name)
949 (vc-find-file-hook)) 960 (vc-find-file-hook))
950 (message 961 (message
951 "Warning: editing through the link bypasses version control") 962 "Warning: editing through the link bypasses version control")
952 )) 963 ))
953 (t (setq buffer-file-name (file-truename buffer-file-name)) 964 (t (vc-follow-link)
954 (message "Followed link to %s" buffer-file-name) 965 (message "Followed link to %s" buffer-file-name)
955 (vc-find-file-hook)))))))))) 966 (vc-find-file-hook))))))))))
956 967