[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#10419: 23.3; byte-compile-file: Buffer is read-only: #<buffer *Comp

From: Michael Heerdegen
Subject: bug#10419: 23.3; byte-compile-file: Buffer is read-only: #<buffer *Compiler Input*>
Date: Sun, 01 Jan 2012 20:48:07 +0100


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

        (setq input-buffer (get-buffer-create " *Compiler Input*"))
      (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.



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' 
 '--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 via email to

[Prev in Thread] Current Thread [Next in Thread]