unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#10419: 23.3; byte-compile-file: Buffer is read-only: #<buffer  *Compiler Input*>
@ 2012-01-01 19:48 Michael Heerdegen
  2012-01-06  7:39 ` Glenn Morris
       [not found] ` <mailman.1260.1325835572.15002.bug-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 6+ messages in thread
From: Michael Heerdegen @ 2012-01-01 19:48 UTC (permalink / raw)
  To: 10419

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)





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#10419: 23.3; byte-compile-file: Buffer is read-only: #<buffer  *Compiler Input*>
  2012-01-01 19:48 bug#10419: 23.3; byte-compile-file: Buffer is read-only: #<buffer *Compiler Input*> Michael Heerdegen
@ 2012-01-06  7:39 ` Glenn Morris
       [not found] ` <mailman.1260.1325835572.15002.bug-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 6+ messages in thread
From: Glenn Morris @ 2012-01-06  7:39 UTC (permalink / raw)
  To: 10419-done

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.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#10419: 23.3; byte-compile-file: Buffer is read-only: #<buffer  *Compiler Input*>
       [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
                       ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Michael Heerdegen @ 2012-01-08  8:41 UTC (permalink / raw)
  To: 10419

Glenn Morris <rgm@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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#10419: 23.3; byte-compile-file: Buffer is read-only: #<buffer  *Compiler Input*>
  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>
  2 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2012-01-08  9:23 UTC (permalink / raw)
  To: michael_heerdegen; +Cc: 10419

> From: Michael Heerdegen <michael_heerdegen@web.de>
> Date: Sun, 08 Jan 2012 09:41:30 +0100
> Reply-To: michael_heerdegen@web.de
> 
> Glenn Morris <rgm@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.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#10419: 23.3; byte-compile-file: Buffer is read-only: #<buffer  *Compiler Input*>
  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>
  2 siblings, 0 replies; 6+ messages in thread
From: Andreas Schwab @ 2012-01-08  9:46 UTC (permalink / raw)
  To: michael_heerdegen; +Cc: 10419

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Glenn Morris <rgm@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@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#10419: 23.3; byte-compile-file: Buffer is read-only: #<buffer  *Compiler Input*>
       [not found]     ` <mailman.1445.1326016018.15002.bug-gnu-emacs@gnu.org>
@ 2012-01-08 14:51       ` Michael Heerdegen
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Heerdegen @ 2012-01-08 14:51 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 10419

Andreas Schwab <schwab@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.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-01-08 14:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-01 19:48 bug#10419: 23.3; byte-compile-file: Buffer is read-only: #<buffer *Compiler Input*> Michael Heerdegen
2012-01-06  7:39 ` 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

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).