[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] fix first `save-buffer' with `break-hardlink-on-save' set
From: |
Nix |
Subject: |
[PATCH] fix first `save-buffer' with `break-hardlink-on-save' set |
Date: |
Sun, 15 May 2011 16:48:13 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Currently, on bzr head, if `break-hardlink-on-save' is set, you can only
overwrite existing files: you cannot write new ones: attempts to write
new ones throws a Lisp error. This is because `basic-save-2' calls
`file-nlinks' without consideration of whether the file exists already,
and (> nil 1) is an error.
Fix below. (I'm not sure if, in the Bazaar world, you prefer to have
ChangeLogs incorporated in the diff itself. I'm sticking to pre-Bazaar
conventions for now.)
2011-05-15 Nix <address@hidden>
* files.el (basic-save-buffer-2): Only check `file-nlinks' and
directory writability if the file already exists.
Index: emacs/lisp/files.el
===================================================================
--- emacs.orig/lisp/files.el 2011-05-15 16:36:56.187046000 +0100
+++ emacs/lisp/files.el 2011-05-15 16:41:26.832058984 +0100
@@ -4516,12 +4516,13 @@
(let* ((dir (file-name-directory buffer-file-name))
(dir-writable (file-writable-p dir)))
(if (or (and file-precious-flag dir-writable)
- (and break-hardlink-on-save
- (> (file-nlinks buffer-file-name) 1)
- (or dir-writable
- (error (concat (format
- "Directory %s write-protected; " dir)
- "cannot break hardlink when saving")))))
+ (and break-hardlink-on-save
+ (file-exists-p buffer-file-name)
+ (> (file-nlinks buffer-file-name) 1)
+ (or dir-writable
+ (error (concat (format
+ "Directory %s write-protected; " dir)
+ "cannot break hardlink when saving")))))
;; Write temp name, then rename it.
;; This requires write access to the containing dir,
;; which is why we don't try it if we don't have that access.
- [PATCH] fix first `save-buffer' with `break-hardlink-on-save' set,
Nix <=