From: Michael Heerdegen <michael_heerdegen@web.de>
To: 10419@debbugs.gnu.org
Subject: bug#10419: 23.3; byte-compile-file: Buffer is read-only: #<buffer *Compiler Input*>
Date: Sun, 01 Jan 2012 20:48:07 +0100 [thread overview]
Message-ID: <871urjgq6g.fsf@web.de> (raw)
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)
next reply other threads:[~2012-01-01 19:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-01 19:48 Michael Heerdegen [this message]
2012-01-06 7:39 ` bug#10419: 23.3; byte-compile-file: Buffer is read-only: #<buffer *Compiler Input*> Glenn Morris
[not found] ` <mailman.1260.1325835572.15002.bug-gnu-emacs@gnu.org>
2012-01-08 8:41 ` Michael Heerdegen
2012-01-08 9:23 ` Eli Zaretskii
2012-01-08 9:46 ` Andreas Schwab
[not found] ` <mailman.1445.1326016018.15002.bug-gnu-emacs@gnu.org>
2012-01-08 14:51 ` Michael Heerdegen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871urjgq6g.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=10419@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).