Article View: gnu.emacs.bug
Article #99484New user variable: backup-by-copying-when-symlinked
From: Rob Austein
Date: Wed, 29 Aug 1990 17:18
Date: Wed, 29 Aug 1990 17:18
101 lines
4994 bytes
4994 bytes
In emacs version 18.54:
The behavior of the function backup-buffer (in files.el) with respect
to symbolic links seems odd. With hard links, the user gets to choose
whether backups are performed by renaming or by copying, but with
symbolic links the backup is always by copying. Additionally, some of
us refugees from other operating systems (eg, ITS) think that writing
out a new version of a file accessed via a symbolic link might
reasonably overwrite the link, not the file that is the target of the
link. Clearly, a case can be made for both models, so the obvious
answer is a user variable which selects between these two modes.
Also, while delving into the guts of backup-buffer, I discovered a
piece of code which prevents the user from ever making backups of a
file whose name begins with "/tmp/". While some users may think this
is a reasonable feature, hard-wiring it into backup-buffer seems like
a bad idea. It's commented out in this patch, and I suggest it be
removed entirely in the next release.
--Rob Austein
=== Begin patch ===
*** /tmp/,RCSt1008202 Wed Aug 29 12:34:14 1990
--- files.el Tue Aug 28 22:33:44 1990
***************
*** 39,46 ****
The file's owner and group are unchanged.
The choice of renaming or copying is controlled by the variables
! backup-by-copying, backup-by-copying-when-linked and
! backup-by-copying-when-mismatch.")
(defconst backup-by-copying nil
"*Non-nil means always use copying to create backup files.
--- 39,46 ----
The file's owner and group are unchanged.
The choice of renaming or copying is controlled by the variables
! backup-by-copying, backup-by-copying-when-linked,
! backup-by-copying-when-mismatch, and backup-by-copying-when-symlinked.")
(defconst backup-by-copying nil
"*Non-nil means always use copying to create backup files.
***************
*** 59,64 ****
--- 59,73 ----
the default for a new file created there by you.
This variable is relevant only if backup-by-copying is nil.")
+ (defconst backup-by-copying-when-symlinked t
+ "*Non-nil means create backups by copying for files which are symbolic
+ links. This causes the backup to be written in the directory where the
+ link resides and the new version to be written to file that is the link's
+ target. If this variable is nil, the link will be renamed and the new
+ version will be written in the normal way. This variable is non-nil by
+ default for compatability with older versions of emacs.
+ This variable is relevant only if backup-by-copying is nil.")
+
(defconst buffer-offer-save nil
"*Non-nil in a buffer means offer to save the buffer on exit
even if the buffer is not visiting a file. Automatically local in
***************
*** 496,503 ****
(file-exists-p buffer-file-name)
(memq (aref (elt (file-attributes buffer-file-name) 8) 0)
'(?- ?l))
! (or (< (length buffer-file-name) 5)
! (not (string-equal "/tmp/" (substring buffer-file-name 0 5))))
(condition-case ()
(let* ((backup-info (find-backup-file-name buffer-file-name))
(backupname (car backup-info))
--- 505,512 ----
(file-exists-p buffer-file-name)
(memq (aref (elt (file-attributes buffer-file-name) 8) 0)
'(?- ?l))
! ; (or (< (length buffer-file-name) 5)
! ; (not (string-equal "/tmp/" (substring buffer-file-name 0 5))))
(condition-case ()
(let* ((backup-info (find-backup-file-name buffer-file-name))
(backupname (car backup-info))
***************
*** 507,514 ****
; (error "Cannot save buffer in directory %s" buffer-file-name))
(condition-case ()
(if (or file-precious-flag
- (file-symlink-p buffer-file-name)
backup-by-copying
(and backup-by-copying-when-linked
(> (file-nlinks buffer-file-name) 1))
(and backup-by-copying-when-mismatch
--- 516,524 ----
; (error "Cannot save buffer in directory %s" buffer-file-name))
(condition-case ()
(if (or file-precious-flag
backup-by-copying
+ (and backup-by-copying-when-symlinked
+ (file-symlink-p buffer-file-name))
(and backup-by-copying-when-linked
(> (file-nlinks buffer-file-name) 1))
(and backup-by-copying-when-mismatch
=== End patch ===
Technical Details
Message-ID:
<9008291318.aa08242@yaya.lcs.mit.edu>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!LCS.MIT.EDU!sraShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,1ee30097a3e4affd,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1990-08-29 14:44:03 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!LCS.MIT.EDU!sra From: sra@LCS.MIT.EDU (Rob Austein) Newsgroups: gnu.emacs.bug Subject: New user variable: backup-by-copying-when-symlinked Message-ID: <9008291318.aa08242@yaya.lcs.mit.edu> Date: 29 Aug 90 17:18:15 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 101 Posted: Wed Aug 29 18:18:15 1990