aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris <[email protected]>2011-11-09 21:17:45 -0500
committerGlenn Morris <[email protected]>2011-11-09 21:17:45 -0500
commitb2621720c318257be0d4100d695b62986db88b4f (patch)
treeea4147a75f38b69ff7abb4ee550433e562ecaac3
parentc4e7c63af11781a1c79c119ef4a2b8c2b74637d6 (diff)
toggle-read-only fixes for bugs#7292, 10006.
* doc/lispref/buffers.texi (Read Only Buffers): Expand a bit on why toggle-read-only should only be used interactively. * lisp/files.el (toggle-read-only): Mention that it should only be used interactively. * lisp/emacs-lisp/bytecomp.el (byte-compile-interactive-only-functions): Add toggle-read-only.
-rw-r--r--doc/lispref/ChangeLog5
-rw-r--r--doc/lispref/buffers.texi9
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/emacs-lisp/bytecomp.el2
-rw-r--r--lisp/files.el10
5 files changed, 27 insertions, 6 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 238ce9838b..2abed9f870 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,8 @@
+2011-11-10 Glenn Morris <[email protected]>
+
+ * buffers.texi (Read Only Buffers): Expand a bit on why
+ toggle-read-only should only be used interactively. (Bug#7292)
+
2011-11-09 Chong Yidong <[email protected]>
* windows.texi (Window Sizes): Document window-pixel-edges,
diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi
index 816d0f9faa..ee2ce2e200 100644
--- a/doc/lispref/buffers.texi
+++ b/doc/lispref/buffers.texi
@@ -748,10 +748,11 @@ of the list (comparison is done with @code{eq}).
@deffn Command toggle-read-only &optional arg
This command toggles whether the current buffer is read-only. It is
-intended for interactive use; do not use it in programs. At any given
-point in a program, you should know whether you want the read-only flag
-on or off; so you can set @code{buffer-read-only} explicitly to the
-proper value, @code{t} or @code{nil}.
+intended for interactive use; do not use it in programs (it may have
+side-effects, such as enabling View mode, and does not affect
+read-only text properties). To change the read-only state of a buffer in
+a program, explicitly set @code{buffer-read-only} to the proper value.
+To temporarily ignore a read-only state, bind @code{inhibit-read-only}.
If @var{arg} is non-@code{nil}, it should be a raw prefix argument.
@code{toggle-read-only} sets @code{buffer-read-only} to @code{t} if
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 795d0e8702..1617736593 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
+2011-11-10 Glenn Morris <[email protected]>
+
+ * emacs-lisp/bytecomp.el (byte-compile-interactive-only-functions):
+ Add toggle-read-only. (Bug#7292)
+ * files.el (toggle-read-only): Mention that it should only
+ be used interactively. (Bug#10006)
+
2011-11-09 Stefan Monnier <[email protected]>
* progmodes/compile.el (compilation-error-regexp-alist-alist):
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index fae402d421..84aaf8718e 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -355,7 +355,7 @@ else the global value will be modified."
(defvar byte-compile-interactive-only-functions
'(beginning-of-buffer end-of-buffer replace-string replace-regexp
insert-file insert-buffer insert-file-literally previous-line next-line
- goto-line comint-run delete-backward-char)
+ goto-line comint-run delete-backward-char toggle-read-only)
"List of commands that are not meant to be called from Lisp.")
(defvar byte-compile-not-obsolete-vars nil
diff --git a/lisp/files.el b/lisp/files.el
index acff339501..aac415c1a9 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4686,7 +4686,15 @@ prints a message in the minibuffer. Instead, use `set-buffer-modified-p'."
"Change whether this buffer is read-only.
With prefix argument ARG, make the buffer read-only if ARG is
positive, otherwise make it writable. If buffer is read-only
-and `view-read-only' is non-nil, enter view mode."
+and `view-read-only' is non-nil, enter view mode.
+
+This function is usually the wrong thing to use in a Lisp program.
+It can have side-effects beyond changing the read-only status of a buffer
+\(e.g., enabling view mode), and does not affect read-only regions that
+are caused by text properties. To make a buffer read-only in Lisp code,
+set `buffer-read-only'. To ignore read-only status (whether due to text
+properties or buffer state) and make changes, temporarily bind
+`inhibit-read-only'."
(interactive "P")
(if (and arg
(if (> (prefix-numeric-value arg) 0) buffer-read-only