unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* find-buffer-visiting: Patch.
@ 2002-08-28  3:02 Luc Teirlinck
  0 siblings, 0 replies; only message in thread
From: Luc Teirlinck @ 2002-08-28  3:02 UTC (permalink / raw)


find-buffer-visiting malfunctions if a symbolic link is made to one of
two hard-linked files.  This is not a really contorted situation.
Hard links seem to be used extensively for operating system files.  If
one makes a symbolic link to such a file, one is in the described
situation.

First, a description of the problem.

Let us create a new file "original".

C-x C-f original.

Type say "a", C-x C-s.

C-x d.

Hard-link "original" to "hardlink", using the dired command H.

Symlink "hardlink" to "symhard", using S.

Visit symhard, using dired and then visit original (using C-x C-f or
using dired, makes no difference).  symhard and original are not
recognized as the same file and we get two different buffers.  Kill
both.  Now visit both files again, but reverse the order, visit
original first and then symhard.  Now they actually are the same file
and we get one single buffer.

This makes no sense: symhard and original are the same file, but
original and symhard are different files.  This is not merely ugly and
nonsensical.  I believe it is important to point out to the user that
symhard and original are (indirectly) linked, because hard links are
tricky and easily broken, especially since Emacs uses backup by
renaming as its default.

The problem lies with the function find-buffer-visiting and is trivial
to fix by adding four letters (replacing one occurrence of
buffer-file-name with buffer-file-truename, so that symbolic links to
hard links are accounted for).

I include a changelog and a diff for the latest CVS version of
emacs21.3.50.

Change log:

         *files.el: (find-buffer-visiting): compare file attributes
          using buffer-file-truename.

Diff:


===File ~/filesdiff=========================================
cd /usr/local/share/emacs/21.3.50/lisp/
diff -c /usr/local/share/emacs/21.3.50/lisp/oldfiles.el /usr/local/share/emacs/21.3.50/lisp/files.el
*** /usr/local/share/emacs/21.3.50/lisp/oldfiles.el	Tue Aug 27 16:42:27 2002
--- /usr/local/share/emacs/21.3.50/lisp/files.el	Tue Aug 27 21:05:52 2002
***************
*** 1076,1082 ****
  			    ;; Verify this buffer's file number
  			    ;; still belongs to its file.
  			    (file-exists-p buffer-file-name)
! 			    (equal (file-attributes buffer-file-name)
  				   attributes))
  		       (setq found (car list))))
  		 (setq list (cdr list))))
--- 1076,1082 ----
  			    ;; Verify this buffer's file number
  			    ;; still belongs to its file.
  			    (file-exists-p buffer-file-name)
! 			    (equal (file-attributes buffer-file-truename)
  				   attributes))
  		       (setq found (car list))))
  		 (setq list (cdr list))))

Diff finished at Tue Aug 27 21:08:08
============================================================

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-08-28  3:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-28  3:02 find-buffer-visiting: Patch Luc Teirlinck

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).