From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Newsgroups: gmane.emacs.bugs Subject: bug#6762: 23.2; Eshell bug in detecting read-only file (patch included) Date: Fri, 30 Jul 2010 11:13:58 +0100 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1280486334 4570 80.91.229.12 (30 Jul 2010 10:38:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 30 Jul 2010 10:38:54 +0000 (UTC) Cc: John Wiegley To: 6762@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 30 12:38:50 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OemzA-0006Kf-7p for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Jul 2010 12:38:49 +0200 Original-Received: from localhost ([127.0.0.1]:51032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oemz5-0005v2-GN for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Jul 2010 06:38:35 -0400 Original-Received: from [140.186.70.92] (port=48802 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OemyT-0005cU-Dx for bug-gnu-emacs@gnu.org; Fri, 30 Jul 2010 06:38:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OemyK-0001SL-QJ for bug-gnu-emacs@gnu.org; Fri, 30 Jul 2010 06:37:49 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60550) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OemyK-0001SG-MJ for bug-gnu-emacs@gnu.org; Fri, 30 Jul 2010 06:37:48 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1OembK-0004S2-0h; Fri, 30 Jul 2010 06:14:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Leo Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 30 Jul 2010 10:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 6762 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.128048483317102 (code B ref -1); Fri, 30 Jul 2010 10:14:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Jul 2010 10:13:53 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OembB-0004Rn-G6 for submit@debbugs.gnu.org; Fri, 30 Jul 2010 06:13:53 -0400 Original-Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oemb9-0004Ri-4z for submit@debbugs.gnu.org; Fri, 30 Jul 2010 06:13:51 -0400 Original-Received: from lists.gnu.org ([199.232.76.165]:57975) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1OembO-0006zy-Et for submit@debbugs.gnu.org; Fri, 30 Jul 2010 06:14:06 -0400 Original-Received: from [140.186.70.92] (port=46102 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OembM-0003vO-Gr for bug-gnu-emacs@gnu.org; Fri, 30 Jul 2010 06:14:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OembI-0005h4-C2 for bug-gnu-emacs@gnu.org; Fri, 30 Jul 2010 06:14:04 -0400 Original-Received: from ppsw-32.csi.cam.ac.uk ([131.111.8.132]:44732) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OembI-0005gs-86 for bug-gnu-emacs@gnu.org; Fri, 30 Jul 2010 06:14:00 -0400 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Original-Received: from cpc1-cmbg13-0-0-cust596.cmbg.cable.ntl.com ([86.9.122.85]:59267 helo=Victoria.local) by ppsw-32.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.158]:587) with esmtpsa (PLAIN:sl392) (TLSv1:DHE-RSA-AES128-SHA:128) id 1OembH-0001PA-12 (Exim 4.72) (return-path ); Fri, 30 Jul 2010 11:13:59 +0100 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 30 Jul 2010 06:14:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:39075 Archived-At: I have diff-default-read-only set to t and this prevents eshell from writing to diff files i.e. ESHELL$ git diff x..y > file.diff fails due to its use of buffer-read-only, which doesn't necessary reflects the read-only state of a file. The following patch tries to fix this. Leo commit b1dc6a427e43470981d4700b0c98aa21ecb03052 Author: sdl.web@gmail.com Date: Sat May 1 17:50:21 2010 +0100 Better detection of read-only file in eshell-get-target Modified lisp/eshell/esh-io.el diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el index 1bcfe2b..3aa785c 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)