From 16b0b3479eff21b64a311dd791e5ea17f845a790 Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Fri, 30 Jul 2010 19:25:06 -0400 Subject: [PATCH] * lisp/eshell/esh-io.el (eshell-get-target): Better detection of read-only file (Bug#6762). --- lisp/ChangeLog | 5 +++++ lisp/eshell/esh-io.el | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f2450f22ea6..2b196d22c72 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2010-07-30 Leo + + * eshell/esh-io.el (eshell-get-target): Better detection of + read-only file (Bug#6762). + 2010-07-30 Juanma Barranquero * align.el (align-default-spacing): Doc fix. diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el index 1bcfe2b46e7..3aa785c7c1b 100644 --- a/lisp/eshell/esh-io.el +++ b/lisp/eshell/esh-io.el @@ -343,8 +343,9 @@ it defaults to `insert'." (let* ((exists (get-file-buffer target)) (buf (find-file-noselect target t))) (with-current-buffer buf - (if buffer-read-only + (if buffer-file-read-only (error "Cannot write to read-only file `%s'" target)) + (setq buffer-read-only nil) (set (make-local-variable 'eshell-output-file-buffer) (if (eq exists buf) 0 t)) (cond ((eq mode 'overwrite) -- 2.39.2