summaryrefslogtreecommitdiff
path: root/lisp/vc-hooks.el
diff options
context:
space:
mode:
authorAndré Spiegel <spiegel@gnu.org>1996-02-22 13:07:58 +0000
committerAndré Spiegel <spiegel@gnu.org>1996-02-22 13:07:58 +0000
commit30518708ac9df47161073ad2185c694f11375644 (patch)
tree6c3f341a674859e7b5d27eb6b63d83fafa036ca3 /lisp/vc-hooks.el
parent4962b447c446fe44b4809f6fb63c759f7cd163f3 (diff)
downloademacs-30518708ac9df47161073ad2185c694f11375644.tar.gz
(vc-follow-link): New function.
(vc-find-file-hook): Use it.
Diffstat (limited to 'lisp/vc-hooks.el')
-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."
(t
(concat ":" locker ":" rev)))))
+(defun vc-follow-link ()
+ ;; If the current buffer visits a symbolic link, this function makes it
+ ;; visit the real file instead. If the real file is already visited in
+ ;; another buffer, make that buffer current, and kill the buffer
+ ;; that visits the link.
+ (let* ((truename (file-truename buffer-file-name))
+ (true-buffer (get-file-buffer truename)))
+ (if true-buffer
+ (set-buffer true-buffer)
+ (kill-buffer (current-buffer))
+ (set-buffer (find-file-noselect truename)))))
+
;;; install a call to the above as a find-file hook
(defun vc-find-file-hook ()
;; Recompute whether file is version controlled,
@@ -943,14 +955,13 @@ control system name."
((eq vc-follow-symlinks 'ask)
(if (yes-or-no-p (format
"Symbolic link to %s-controlled source file; follow link? " link-type))
- (progn (setq buffer-file-name
- (file-truename buffer-file-name))
+ (progn (vc-follow-link)
(message "Followed link to %s" buffer-file-name)
(vc-find-file-hook))
(message
"Warning: editing through the link bypasses version control")
))
- (t (setq buffer-file-name (file-truename buffer-file-name))
+ (t (vc-follow-link)
(message "Followed link to %s" buffer-file-name)
(vc-find-file-hook))))))))))