GNU bug report logs - #10419
23.3; byte-compile-file: Buffer is read-only: #<buffer *Compiler Input*>

Previous Next

Package: emacs;

Reported by: michael_heerdegen <at> web.de

Date: Sun, 1 Jan 2012 19:51:01 UTC

Severity: minor

Found in version 23.3

Fixed in version 24.0.93

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 10419 in the body.
You can then email your comments to 10419 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#10419; Package emacs. (Sun, 01 Jan 2012 19:51:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to michael_heerdegen <at> web.de:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 01 Jan 2012 19:51:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.3;
	byte-compile-file: Buffer is read-only: #<buffer  *Compiler Input*>
Date: Sun, 01 Jan 2012 20:48:07 +0100
Hi,

this is a simple issue, though some explanation is necessary.

Background: I have a large Emacs init file.  Because I often want to
have a look at function definitions in this file, I added a file local
variable binding of `buffer-read-only' to t.  This way, e.g. links
from *Help* always open it read only.  I have to explicitly toggle the
read-only flag if I want to modify the file.  This works well.

Now, imagine the following scenario: I open my init file and toggle
the read-only flag.  I make some changes.  Then, I compile it with M-x
emacs-lisp-byte-compile.  While compilation is in progress, I
recognize that I made an error while editing.  I cancel compilation by
hitting C-g.  I correct my mistake, and try to compile again with
`emacs-lisp-byte-compile'.  Then I get the following error:

    byte-compile-file: Buffer is read-only: #<buffer  *Compiler Input*>

This is the bug.

Here is why that happens.  This is the problematic piece of code in
`byte-compile-file':

    (with-current-buffer
        (setq input-buffer (get-buffer-create " *Compiler Input*"))
      (erase-buffer)
      (setq buffer-file-coding-system nil)
      ;; Always compile an Emacs Lisp file as multibyte
      ;; unless the file itself forces unibyte with -*-coding: raw-text;-*-
      (set-buffer-multibyte t)
      (insert-file-contents bytecomp-filename)
      ;; Mimic the way after-insert-file-set-coding can make the
      ;; buffer unibyte when visiting this file.
      (when (or (eq last-coding-system-used 'no-conversion)
		(eq (coding-system-type last-coding-system-used) 5))
	;; For coding systems no-conversion and raw-text...,
	;; edit the buffer as unibyte.
	(set-buffer-multibyte nil))
      ;; Run hooks including the uncompression hook.
      ;; If they change the file name, then change it for the output also.
      (letf ((buffer-file-name bytecomp-filename)
             ((default-value 'major-mode) 'emacs-lisp-mode)
             ;; Ignore unsafe local variables.
             ;; We only care about a few of them for our purposes.
             (enable-local-variables :safe)
             (enable-local-eval nil))
	;; Arg of t means don't alter enable-local-variables.
        (normal-mode t)
        (setq bytecomp-filename buffer-file-name))
      ;; Set the default directory, in case an eval-when-compile uses it.
      (setq default-directory (file-name-directory bytecomp-filename)))

In the first compilation run, the buffer " *Compiler Input*" is made
read-only (and left read-only after aborting with C-g) because
`enable-local-variables' is bound to :safe and `normal-mode' is called
and there is the binding of `buffer-read-only' to t.

In the second compilation run, `erase-buffer' is called on the
read-only buffer.  This gives the error.


Thanks,

Michael.



In GNU Emacs 23.3.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2011-10-26 on murphy, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11102902
configured using `configure  '--build' 'i486-linux-gnu' '--build' 'i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.3/site-lisp:/usr/share/emacs/site-lisp' '--with-crt-dir=/usr/lib/i386-linux-gnu' '--with-x=yes' '--with-x-toolkit=lucid' '--with-toolkit-scroll-bars' '--without-gconf' 'build_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2''

Important settings:
  value of $LC_ALL: de_DE.utf8
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: C
  value of $LANG: de_DE.utf8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Org-Agenda Week Ddl Grid

Minor modes in effect:
  TeX-PDF-mode: t
  shell-dirtrack-mode: t
  ml-scale-mode: t
  which-function-mode: t
  display-time-mode: t
  show-paren-mode: t
  auto-image-file-mode: t
  global-undo-tree-mode: t
  Info-breadcrumbs-in-mode-line-mode: t
  icicle-mode: t
  minibuffer-depth-indicate-mode: t
  hl-line-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: (only . t)




Reply sent to Glenn Morris <rgm <at> gnu.org>:
You have taken responsibility. (Fri, 06 Jan 2012 07:43:02 GMT) Full text and rfc822 format available.

Notification sent to michael_heerdegen <at> web.de:
bug acknowledged by developer. (Fri, 06 Jan 2012 07:43:02 GMT) Full text and rfc822 format available.

Message #10 received at 10419-done <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 10419-done <at> debbugs.gnu.org
Subject: Re: bug#10419: 23.3;
	byte-compile-file: Buffer is read-only: #<buffer  *Compiler Input*>
Date: Fri, 06 Jan 2012 02:39:06 -0500
Version: 24.0.93

Michael Heerdegen wrote:

> Background: I have a large Emacs init file.  Because I often want to
> have a look at function definitions in this file, I added a file local
> variable binding of `buffer-read-only' to t.  This way, e.g. links
> from *Help* always open it read only.  I have to explicitly toggle the
> read-only flag if I want to modify the file.  This works well.

I don't know why you don't just make the file read-only on disk.
Anyway, I made the compiler input buffer ignore any file setting of
buffer-read-only.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10419; Package emacs. (Sun, 08 Jan 2012 08:41:01 GMT) Full text and rfc822 format available.

Message #13 received at 10419 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: 10419 <at> debbugs.gnu.org
Cc: rgm <at> gnu.org
Subject: Re: bug#10419: 23.3;
	byte-compile-file: Buffer is read-only: #<buffer  *Compiler Input*>
Date: Sun, 08 Jan 2012 09:41:30 +0100
Glenn Morris <rgm <at> gnu.org> writes:

> I don't know why you don't just make the file read-only on disk.

Of course I could do that.  But then I may forget to make it read-only
again after editing the file.

> Anyway, I made the compiler input buffer ignore any file setting of
> buffer-read-only.

Works for me, thanks.


- Michael




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10419; Package emacs. (Sun, 08 Jan 2012 09:24:01 GMT) Full text and rfc822 format available.

Message #16 received at 10419 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: michael_heerdegen <at> web.de
Cc: 10419 <at> debbugs.gnu.org
Subject: Re: bug#10419: 23.3;
	byte-compile-file: Buffer is read-only: #<buffer  *Compiler Input*>
Date: Sun, 08 Jan 2012 04:23:36 -0500
> From: Michael Heerdegen <michael_heerdegen <at> web.de>
> Date: Sun, 08 Jan 2012 09:41:30 +0100
> Reply-To: michael_heerdegen <at> web.de
> 
> Glenn Morris <rgm <at> gnu.org> writes:
> 
> > I don't know why you don't just make the file read-only on disk.
> 
> Of course I could do that.  But then I may forget to make it read-only
> again after editing the file.

You don't need to: Emacs will make it read-only automatically, when
you save it.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10419; Package emacs. (Sun, 08 Jan 2012 09:47:01 GMT) Full text and rfc822 format available.

Message #19 received at 10419 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: michael_heerdegen <at> web.de
Cc: 10419 <at> debbugs.gnu.org
Subject: Re: bug#10419: 23.3;
	byte-compile-file: Buffer is read-only: #<buffer  *Compiler Input*>
Date: Sun, 08 Jan 2012 10:46:48 +0100
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> Glenn Morris <rgm <at> gnu.org> writes:
>
>> I don't know why you don't just make the file read-only on disk.
>
> Of course I could do that.  But then I may forget to make it read-only
> again after editing the file.

Emacs allows you to edit read-only files, making it writable temporarily
when saving (after confirmation).

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10419; Package emacs. (Sun, 08 Jan 2012 14:51:01 GMT) Full text and rfc822 format available.

Message #22 received at 10419 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 10419 <at> debbugs.gnu.org
Subject: Re: bug#10419: 23.3;
	byte-compile-file: Buffer is read-only: #<buffer  *Compiler Input*>
Date: Sun, 08 Jan 2012 15:51:21 +0100
Andreas Schwab <schwab <at> linux-m68k.org> writes:

> >> I don't know why you don't just make the file read-only on disk.
> >
> > Of course I could do that.  But then I may forget to make it read-only
> > again after editing the file.
>
> Emacs allows you to edit read-only files, making it writable temporarily
> when saving (after confirmation).

Oh yes, right, I forgot.

I guess I chose my solution to get rid of the

  (yes-or-no-p
   (format
    "File %s is write-protected; try to save anyway? "
    (file-name-nondirectory
     buffer-file-name)))

query every time when saving.  With my solution, I have to toggle the
read-only flag only once and avoid the annoying `yes-or-no-p'.


Thanks,

Michael.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 06 Feb 2012 12:24:02 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 87 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.