From xemacs-m  Mon Jul 21 18:26:01 1997
Received: from atreides.eng.mindspring.net (atreides.eng.mindspring.net [207.69.183.11])
	by xemacs.org (8.8.5/8.8.5) with SMTP id SAA22078
	for <xemacs-beta@xemacs.org>; Mon, 21 Jul 1997 18:26:01 -0500 (CDT)
Received: (qmail 23434 invoked by uid 52477); 21 Jul 1997 23:25:34 -0000
To: xemacs-beta@xemacs.org
Subject: Bug when visiting symlinks to version-controlled files.
Mime-Version: 1.0 (generated by tm-edit 7.108)
Content-Type: text/plain; charset=US-ASCII
From: Sudish Joseph <sj@eng.mindspring.net>
Date: 21 Jul 1997 19:25:34 -0400
Message-ID: <yviayb70c7ip.fsf@atreides.eng.mindspring.net>
Lines: 47
X-Mailer: Gnus v5.4.55/XEmacs 20.3(beta14)

XEmacs version: "20.3 \"Vienna\" XEmacs  Lucid (beta14)"

The problem cropped up around or before Oslo.  I noticed it only after 
upgrading to Vienna.  Did we synch vc.el around the time of Oslo?

To reproduce, create a symlink to file under version control (CVS in
my case), say the link is ~/vclink.  
xemacs -q
M-: (setq debug-on-error t)
C-x C-f ~/vclink
yes                  ; to the "follow symlink?" prompt from vc-find-file-hook

Signaling: (error "Selecting deleted or non-existent buffer")
  switch-to-buffer(#<killed buffer>)
  find-file("~/.gnus" nil)
  call-interactively(find-file)

Find-file-noselect assumes that the buffer it created doesn't change
under it.  However, it eventually runs vc-follow-link (via
after-find-file -> find-file-hooks -> vc-find-file-hook ->
vc-follow-link).  Vc-follow-link clobbers the visited buffer (and
also forces the truename buffer on the user unconditionally[1]).
Find-file-noselect then returns the killed buffer and freaks out
switch-to-buffer.

The offending code in vc-follow-link (vc-hooks.el) contains this comment:

    (if (eq true-buffer this-buffer)
	(progn
	  (kill-buffer this-buffer)
	  ;; In principle, we could do something like set-visited-file-name.
	  ;; However, it can't be exactly the same as set-visited-file-name.
	  ;; I'm not going to work out the details right now. -- rms.
	  (set-buffer (find-file-noselect truename)))

IMO, the fault lies with vc-follow-link.  It seems like erasing
this-buffer and doing an insert-file-contents should suffice, but I'm
not sure.

Tx,
-Sudish

Footnotes: 
[1]  My .gnus is a symlink to a vc'ed file.  The unconditional changing
of the visited-filename means that byte-compiling .gnus drops .gnus.el
in the wrong directory.  Switch to hard links, I guess.

