diff options
| author | Karl Fogel | 2008-11-29 19:04:14 +0000 |
|---|---|---|
| committer | Karl Fogel | 2008-11-29 19:04:14 +0000 |
| commit | 1d367309a195393da7ae84f58e8a9927460d9f2e (patch) | |
| tree | aa026525d4332a29620089b7a257ba8066ba966c | |
| parent | b23077df66f0b60e9ca9b0435f32326eadad9161 (diff) | |
| download | emacs-1d367309a195393da7ae84f58e8a9927460d9f2e.tar.gz emacs-1d367309a195393da7ae84f58e8a9927460d9f2e.zip | |
* emacs-cvs/lisp/files.el
(break-hardlink-on-save): New variable.
(basic-save-buffer-2): Honor new variable break-hardlink-on-save.
(file-precious-flag): Mention it in doc string.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/files.el | 35 |
2 files changed, 36 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 40d8cda4d2f..9d6089d8b1d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2008-11-27 Karl Fogel <kfogel@red-bean.com> | ||
| 2 | |||
| 3 | * files.el (break-hardlink-on-save): New variable. | ||
| 4 | (basic-save-buffer-2): Honor new variable break-hardlink-on-save. | ||
| 5 | (file-precious-flag): Mention it in doc string. | ||
| 6 | |||
| 1 | 2008-11-29 Miles Bader <miles@gnu.org> | 7 | 2008-11-29 Miles Bader <miles@gnu.org> |
| 2 | 8 | ||
| 3 | * minibuffer.el (minibuffer-confirm-exit-commands): New variable. | 9 | * minibuffer.el (minibuffer-confirm-exit-commands): New variable. |
diff --git a/lisp/files.el b/lisp/files.el index a071e2bb435..bbda5cf3b46 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -243,10 +243,29 @@ breaks any hard links between it and other files. | |||
| 243 | 243 | ||
| 244 | This feature is advisory: for example, if the directory in which the | 244 | This feature is advisory: for example, if the directory in which the |
| 245 | file is being saved is not writeable, Emacs may ignore a non-nil value | 245 | file is being saved is not writeable, Emacs may ignore a non-nil value |
| 246 | of `file-precious-flag' and write directly into the file." | 246 | of `file-precious-flag' and write directly into the file. |
| 247 | |||
| 248 | See also: `break-hardlink-on-save'." | ||
| 247 | :type 'boolean | 249 | :type 'boolean |
| 248 | :group 'backup) | 250 | :group 'backup) |
| 249 | 251 | ||
| 252 | (defcustom break-hardlink-on-save nil | ||
| 253 | "Non-nil means when saving a file that exists under several names | ||
| 254 | (i.e., has multiple hardlinks), break the hardlink associated with | ||
| 255 | `buffer-file-name' and write to a new file, so that the other | ||
| 256 | instances of the file are not affected by the save. | ||
| 257 | |||
| 258 | If `buffer-file-name' refers to a symlink, do not break the symlink. | ||
| 259 | |||
| 260 | Unlike `file-precious-flag', `break-hardlink-on-save' is not advisory. | ||
| 261 | For example, if the directory in which a file is being saved is not | ||
| 262 | itself writeable, then error instead of saving in some | ||
| 263 | hardlink-nonbreaking way. | ||
| 264 | |||
| 265 | See also `backup-by-copying' and `backup-by-copying-when-linked'." | ||
| 266 | :type 'boolean | ||
| 267 | :group 'files) | ||
| 268 | |||
| 250 | (defcustom version-control nil | 269 | (defcustom version-control nil |
| 251 | "Control use of version numbers for backup files. | 270 | "Control use of version numbers for backup files. |
| 252 | When t, make numeric backup versions unconditionally. | 271 | When t, make numeric backup versions unconditionally. |
| @@ -4164,10 +4183,16 @@ Before and after saving the buffer, this function runs | |||
| 4164 | (error "Attempt to save to a file which you aren't allowed to write")))))) | 4183 | (error "Attempt to save to a file which you aren't allowed to write")))))) |
| 4165 | (or buffer-backed-up | 4184 | (or buffer-backed-up |
| 4166 | (setq setmodes (backup-buffer))) | 4185 | (setq setmodes (backup-buffer))) |
| 4167 | (let ((dir (file-name-directory buffer-file-name))) | 4186 | (let* ((dir (file-name-directory buffer-file-name)) |
| 4168 | (if (and file-precious-flag | 4187 | (dir-writable (file-writable-p dir))) |
| 4169 | (file-writable-p dir)) | 4188 | (if (or (and file-precious-flag dir-writable) |
| 4170 | ;; If file is precious, write temp name, then rename it. | 4189 | (and break-hardlink-on-save |
| 4190 | (> (file-nlinks buffer-file-name) 1) | ||
| 4191 | (or dir-writable | ||
| 4192 | (error (concat (format | ||
| 4193 | "Directory %s write-protected; " dir) | ||
| 4194 | "cannot break hardlink when saving"))))) | ||
| 4195 | ;; Write temp name, then rename it. | ||
| 4171 | ;; This requires write access to the containing dir, | 4196 | ;; This requires write access to the containing dir, |
| 4172 | ;; which is why we don't try it if we don't have that access. | 4197 | ;; which is why we don't try it if we don't have that access. |
| 4173 | (let ((realname buffer-file-name) | 4198 | (let ((realname buffer-file-name) |