aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2012-07-13 15:06:09 +0800
committerChong Yidong2012-07-13 15:06:09 +0800
commitb68b33375caeb82a4b3418d43c75bc8ccd43633a (patch)
tree2e14569d03369d1de85cfd81bb5a404373ec1245
parent1a95276708930fe579fff152c590df875c29570e (diff)
downloademacs-b68b33375caeb82a4b3418d43c75bc8ccd43633a.tar.gz
emacs-b68b33375caeb82a4b3418d43c75bc8ccd43633a.zip
Don't warn on toggle-read-only calls.
Clarify the documentation of toggle-read-only, and audit the code tree for uses of toggle-read-only; where appropriate, switch to setting the variable buffer-read-only or calling toggle-read-only with a (new) second arg. * lisp/files.el (toggle-read-only): Doc fix and code cleanup. New arg to allow printing the message when called from Lisp. * lisp/emacs-lisp/bytecomp.el (byte-compile-interactive-only-functions): Remove toggle-read-only. * lisp/bindings.el (mode-line-toggle-read-only): * lisp/dired.el (dired-toggle-read-only): * lisp/ibuffer.el (ibuffer-do-toggle-read-only): Call toggle-read-only with non-nil second arg. * lisp/bs.el (bs-toggle-readonly): * lisp/buff-menu.el (Buffer-menu-toggle-read-only): Remove with-no-warnings around toggle-read-only. * lisp/ffap.el (ffap--toggle-read-only): Accept a list of buffers. Remove with-no-warnings around toggle-read-only. (ffap-read-only, ffap-read-only-other-window) (ffap-read-only-other-frame): Callers changed. * lisp/help-mode.el: Don't require view package. (help-mode-finish): Set buffer-read-only instead of calling toggle-read-only. * lisp/emacs-lisp/eieio-custom.el (eieio-customize-object): * lisp/vc/ediff.el (ediff-set-read-only-in-buf-A): Set buffer-read-only directly. * lisp/gnus/smime.el (smime-certificate-info): Set buffer-read-only directly, instead of calling toggle-read-only with a (bogus) argument. * doc/emacs/buffers.texi (Misc Buffer): Document view-read-only. * doc/lispref/buffers.texi (Read Only Buffers): Document toggle-read-only changes. Reword to account for the fact that read-only is currently not supported in overlay properties.
-rw-r--r--doc/emacs/ChangeLog4
-rw-r--r--doc/emacs/buffers.texi5
-rw-r--r--doc/lispref/ChangeLog6
-rw-r--r--doc/lispref/buffers.texi45
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/ChangeLog30
-rw-r--r--lisp/bindings.el2
-rw-r--r--lisp/bs.el2
-rw-r--r--lisp/buff-menu.el5
-rw-r--r--lisp/dired.el11
-rw-r--r--lisp/emacs-lisp/bytecomp.el2
-rw-r--r--lisp/emacs-lisp/eieio-custom.el2
-rw-r--r--lisp/emacs-lisp/eieio.el2
-rw-r--r--lisp/ffap.el17
-rw-r--r--lisp/files.el76
-rw-r--r--lisp/gnus/ChangeLog5
-rw-r--r--lisp/gnus/smime.el2
-rw-r--r--lisp/help-mode.el6
-rw-r--r--lisp/ibuffer.el2
-rw-r--r--lisp/vc/ediff.el2
20 files changed, 148 insertions, 81 deletions
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog
index 311a28a3e39..fc2b7fe073a 100644
--- a/doc/emacs/ChangeLog
+++ b/doc/emacs/ChangeLog
@@ -1,3 +1,7 @@
12012-07-13 Chong Yidong <cyd@gnu.org>
2
3 * buffers.texi (Misc Buffer): Document view-read-only.
4
12012-07-07 Chong Yidong <cyd@gnu.org> 52012-07-07 Chong Yidong <cyd@gnu.org>
2 6
3 * custom.texi (Init File): Index site-lisp (Bug#11435). 7 * custom.texi (Init File): Index site-lisp (Bug#11435).
diff --git a/doc/emacs/buffers.texi b/doc/emacs/buffers.texi
index 159bf894834..24bb0e83778 100644
--- a/doc/emacs/buffers.texi
+++ b/doc/emacs/buffers.texi
@@ -232,11 +232,14 @@ have special commands to operate on the text; also by visiting a file
232whose access control says you cannot write it. 232whose access control says you cannot write it.
233 233
234@findex toggle-read-only 234@findex toggle-read-only
235@vindex view-read-only
235 The command @kbd{C-x C-q} (@code{toggle-read-only}) makes a read-only 236 The command @kbd{C-x C-q} (@code{toggle-read-only}) makes a read-only
236buffer writable, and makes a writable buffer read-only. This works by 237buffer writable, and makes a writable buffer read-only. This works by
237setting the variable @code{buffer-read-only}, which has a local value 238setting the variable @code{buffer-read-only}, which has a local value
238in each buffer and makes the buffer read-only if its value is 239in each buffer and makes the buffer read-only if its value is
239non-@code{nil}. 240non-@code{nil}. If you change the option @code{view-read-only} to a
241non-@code{nil} value, making the buffer read-only with @kbd{C-x C-q}
242also enables View mode in the buffer (@pxref{View Mode}).
240 243
241@findex rename-buffer 244@findex rename-buffer
242 @kbd{M-x rename-buffer} changes the name of the current buffer. You 245 @kbd{M-x rename-buffer} changes the name of the current buffer. You
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 1faf9e04ec1..d7875a7de90 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,9 @@
12012-07-13 Chong Yidong <cyd@gnu.org>
2
3 * buffers.texi (Read Only Buffers): Document toggle-read-only
4 changes. Reword to account for the fact that read-only is
5 currently not supported in overlay properties.
6
12012-07-07 Chong Yidong <cyd@gnu.org> 72012-07-07 Chong Yidong <cyd@gnu.org>
2 8
3 * loading.texi (Library Search): Index site-lisp directories. 9 * loading.texi (Library Search): Index site-lisp directories.
diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi
index 072ffeb4321..6ad329f3a30 100644
--- a/doc/lispref/buffers.texi
+++ b/doc/lispref/buffers.texi
@@ -730,11 +730,9 @@ The buffer is read-only if this variable is non-@code{nil}.
730@defvar inhibit-read-only 730@defvar inhibit-read-only
731If this variable is non-@code{nil}, then read-only buffers and, 731If this variable is non-@code{nil}, then read-only buffers and,
732depending on the actual value, some or all read-only characters may be 732depending on the actual value, some or all read-only characters may be
733modified. Read-only characters in a buffer are those that have 733modified. Read-only characters in a buffer are those that have a
734non-@code{nil} @code{read-only} properties (either text properties or 734non-@code{nil} @code{read-only} text property. @xref{Special
735overlay properties). @xref{Special Properties}, for more information 735Properties}, for more information about text properties.
736about text properties. @xref{Overlays}, for more information about
737overlays and their properties.
738 736
739If @code{inhibit-read-only} is @code{t}, all @code{read-only} character 737If @code{inhibit-read-only} is @code{t}, all @code{read-only} character
740properties have no effect. If @code{inhibit-read-only} is a list, then 738properties have no effect. If @code{inhibit-read-only} is a list, then
@@ -742,18 +740,31 @@ properties have no effect. If @code{inhibit-read-only} is a list, then
742of the list (comparison is done with @code{eq}). 740of the list (comparison is done with @code{eq}).
743@end defvar 741@end defvar
744 742
745@deffn Command toggle-read-only &optional arg 743@deffn Command toggle-read-only &optional arg message
746This command toggles whether the current buffer is read-only. It is 744This command toggles whether the current buffer is read-only, by
747intended for interactive use; do not use it in programs (it may have 745setting the variable @code{buffer-read-only}. If @var{arg} is
748side-effects, such as enabling View mode, and does not affect 746non-@code{nil}, it should be a raw prefix argument; the command then
749read-only text properties). To change the read-only state of a buffer in 747makes the buffer read-only if the numeric value of that prefix
750a program, explicitly set @code{buffer-read-only} to the proper value. 748argument is positive, and makes the buffer writable otherwise.
751To temporarily ignore a read-only state, bind @code{inhibit-read-only}. 749@xref{Prefix Command Arguments}.
752 750
753If @var{arg} is non-@code{nil}, it should be a raw prefix argument. 751If called interactively, or if called from Lisp with @var{message} is
754@code{toggle-read-only} sets @code{buffer-read-only} to @code{t} if 752non-@code{nil}, the command prints a message reporting the buffer's
755the numeric value of that prefix argument is positive and to 753new read-only status.
756@code{nil} otherwise. @xref{Prefix Command Arguments}. 754
755When making the buffer read-only, this command also enables View mode
756if the option @code{view-read-only} is non-@code{nil}. @xref{Misc
757Buffer,,Miscellaneous Buffer Operations, emacs, The GNU Emacs Manual}.
758When making the buffer writable, it disables View mode if View mode
759was enabled.
760
761Lisp programs should only call @code{toggle-read-only} if they really
762intend to do the same thing as the user command, including possibly
763enabling or disabling View mode. Note also that this command works by
764setting @code{buffer-read-only}, so even if you make the buffer
765writable, characters with non-@code{nil} @code{read-only} text
766properties will remain read-only. To temporarily ignore all read-only
767states, bind @code{inhibit-read-only}, as described above.
757@end deffn 768@end deffn
758 769
759@defun barf-if-buffer-read-only 770@defun barf-if-buffer-read-only
diff --git a/etc/NEWS b/etc/NEWS
index 32c738a2aad..0132a3a9ed7 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -476,6 +476,9 @@ still be supported for Emacs 24.x.
476 476
477* Lisp changes in Emacs 24.2 477* Lisp changes in Emacs 24.2
478 478
479** `toggle-read-only' accepts a second argument specifying whether to
480print a message, if called from Lisp.
481
479** CL-style generalized variables are now in core Elisp. 482** CL-style generalized variables are now in core Elisp.
480`setf' is autoloaded and `push' and `pop' accept generalized variables. 483`setf' is autoloaded and `push' and `pop' accept generalized variables.
481 484
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 349cc783bab..d6ce409dc9c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,33 @@
12012-07-13 Chong Yidong <cyd@gnu.org>
2
3 * files.el (toggle-read-only): Doc fix and code cleanup. New arg
4 to allow printing the message when called from Lisp.
5
6 * emacs-lisp/bytecomp.el (byte-compile-interactive-only-functions):
7 Remove toggle-read-only.
8
9 * bs.el (bs-toggle-readonly):
10 * buff-menu.el (Buffer-menu-toggle-read-only): Remove
11 with-no-warnings around toggle-read-only.
12
13 * ffap.el (ffap--toggle-read-only): Accept a list of buffers.
14 Remove with-no-warnings around toggle-read-only.
15 (ffap-read-only, ffap-read-only-other-window)
16 (ffap-read-only-other-frame): Callers changed.
17
18 * help-mode.el: Don't require view package.
19 (help-mode-finish): Set buffer-read-only instead of calling
20 toggle-read-only.
21
22 * bindings.el (mode-line-toggle-read-only):
23 * dired.el (dired-toggle-read-only):
24 * ibuffer.el (ibuffer-do-toggle-read-only): Call toggle-read-only
25 with non-nil second arg.
26
27 * emacs-lisp/eieio-custom.el (eieio-customize-object):
28 * vc/ediff.el (ediff-set-read-only-in-buf-A): Set buffer-read-only
29 directly.
30
12012-07-12 Eli Zaretskii <eliz@gnu.org> 312012-07-12 Eli Zaretskii <eliz@gnu.org>
2 32
3 * emacs-lisp/bytecomp.el (byte-recompile-directory): Use cl-incf, 33 * emacs-lisp/bytecomp.el (byte-recompile-directory): Use cl-incf,
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 109cd8a0d49..e0bea34cd0a 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -40,7 +40,7 @@ corresponding to the mode line clicked."
40 (interactive "e") 40 (interactive "e")
41 (save-selected-window 41 (save-selected-window
42 (select-window (posn-window (event-start event))) 42 (select-window (posn-window (event-start event)))
43 (with-no-warnings (toggle-read-only)) 43 (toggle-read-only nil t)
44 (force-mode-line-update))) 44 (force-mode-line-update)))
45 45
46(defun mode-line-toggle-modified (event) 46(defun mode-line-toggle-modified (event)
diff --git a/lisp/bs.el b/lisp/bs.el
index 09aefee416e..45a7e4d4440 100644
--- a/lisp/bs.el
+++ b/lisp/bs.el
@@ -962,7 +962,7 @@ Default is `bs--current-sort-function'."
962Uses function `toggle-read-only'." 962Uses function `toggle-read-only'."
963 (interactive) 963 (interactive)
964 (with-current-buffer (bs--current-buffer) 964 (with-current-buffer (bs--current-buffer)
965 (call-interactively 'toggle-read-only)) 965 (toggle-read-only))
966 (bs--update-current-line)) 966 (bs--update-current-line))
967 967
968(defun bs-clear-modified () 968(defun bs-clear-modified ()
diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el
index ab1de184ea0..6a65749e0c5 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -515,11 +515,12 @@ The current window remains selected."
515 (bury-buffer menu))) 515 (bury-buffer menu)))
516 516
517(defun Buffer-menu-toggle-read-only () 517(defun Buffer-menu-toggle-read-only ()
518 "Toggle read-only status of buffer on this line." 518 "Toggle read-only status of buffer on this line.
519This behaves like invoking \\[toggle-read-only] in that buffer."
519 (interactive) 520 (interactive)
520 (let (read-only) 521 (let (read-only)
521 (with-current-buffer (Buffer-menu-buffer t) 522 (with-current-buffer (Buffer-menu-buffer t)
522 (with-no-warnings (toggle-read-only)) 523 (toggle-read-only)
523 (setq read-only buffer-read-only)) 524 (setq read-only buffer-read-only))
524 (tabulated-list-set-col 1 (if read-only "%" " ") t))) 525 (tabulated-list-set-col 1 (if read-only "%" " ") t)))
525 526
diff --git a/lisp/dired.el b/lisp/dired.el
index 18480acd968..0e770773197 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1956,15 +1956,14 @@ You can use it to recover marks, killed lines or subdirs."
1956Actual changes in files cannot be undone by Emacs.")) 1956Actual changes in files cannot be undone by Emacs."))
1957 1957
1958(defun dired-toggle-read-only () 1958(defun dired-toggle-read-only ()
1959 "Edit dired buffer with Wdired, or set it read-only. 1959 "Edit Dired buffer with Wdired, or make it read-only.
1960Call `wdired-change-to-wdired-mode' in dired buffers whose editing is 1960If the current buffer can be edited with Wdired, (i.e. the major
1961supported by Wdired (the major mode of the dired buffer is `dired-mode'). 1961mode is `dired-mode'), call `wdired-change-to-wdired-mode'.
1962Otherwise, for buffers inheriting from dired-mode, call `toggle-read-only'." 1962Otherwise, call `toggle-read-only'."
1963 (interactive) 1963 (interactive)
1964 (if (eq major-mode 'dired-mode) 1964 (if (eq major-mode 'dired-mode)
1965 (wdired-change-to-wdired-mode) 1965 (wdired-change-to-wdired-mode)
1966 (with-no-warnings 1966 (toggle-read-only nil t)))
1967 (toggle-read-only))))
1968 1967
1969(defun dired-next-line (arg) 1968(defun dired-next-line (arg)
1970 "Move down lines then position at filename. 1969 "Move down lines then position at filename.
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 755bb4f821b..97d7ab924ed 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -355,7 +355,7 @@ else the global value will be modified."
355(defvar byte-compile-interactive-only-functions 355(defvar byte-compile-interactive-only-functions
356 '(beginning-of-buffer end-of-buffer replace-string replace-regexp 356 '(beginning-of-buffer end-of-buffer replace-string replace-regexp
357 insert-file insert-buffer insert-file-literally previous-line next-line 357 insert-file insert-buffer insert-file-literally previous-line next-line
358 goto-line comint-run delete-backward-char toggle-read-only) 358 goto-line comint-run delete-backward-char)
359 "List of commands that are not meant to be called from Lisp.") 359 "List of commands that are not meant to be called from Lisp.")
360 360
361(defvar byte-compile-not-obsolete-vars nil 361(defvar byte-compile-not-obsolete-vars nil
diff --git a/lisp/emacs-lisp/eieio-custom.el b/lisp/emacs-lisp/eieio-custom.el
index b09f6b6a0e9..59aeb161d8e 100644
--- a/lisp/emacs-lisp/eieio-custom.el
+++ b/lisp/emacs-lisp/eieio-custom.el
@@ -345,7 +345,7 @@ These groups are specified with the `:group' slot flag."
345 (concat "*CUSTOMIZE " 345 (concat "*CUSTOMIZE "
346 (object-name obj) " " 346 (object-name obj) " "
347 (symbol-name g) "*"))) 347 (symbol-name g) "*")))
348 (toggle-read-only -1) 348 (setq buffer-read-only nil)
349 (kill-all-local-variables) 349 (kill-all-local-variables)
350 (erase-buffer) 350 (erase-buffer)
351 (let ((all (overlay-lists))) 351 (let ((all (overlay-lists)))
diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el
index cfba4a84d13..dcd0608ebba 100644
--- a/lisp/emacs-lisp/eieio.el
+++ b/lisp/emacs-lisp/eieio.el
@@ -3040,7 +3040,7 @@ Optional argument NOESCAPE is passed to `prin1-to-string' when appropriate."
3040;;; Start of automatically extracted autoloads. 3040;;; Start of automatically extracted autoloads.
3041 3041
3042;;;### (autoloads (customize-object) "eieio-custom" "eieio-custom.el" 3042;;;### (autoloads (customize-object) "eieio-custom" "eieio-custom.el"
3043;;;;;; "9cf80224540c52045d515a4c2c833543") 3043;;;;;; "928623502e8bf40454822355388542b5")
3044;;; Generated autoloads from eieio-custom.el 3044;;; Generated autoloads from eieio-custom.el
3045 3045
3046(autoload 'customize-object "eieio-custom" "\ 3046(autoload 'customize-object "eieio-custom" "\
diff --git a/lisp/ffap.el b/lisp/ffap.el
index a8455189cb9..3d1f402ab6c 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -1698,9 +1698,11 @@ Only intended for interactive use."
1698 (set-window-dedicated-p win wdp)) 1698 (set-window-dedicated-p win wdp))
1699 value)) 1699 value))
1700 1700
1701(defun ffap--toggle-read-only (buffer) 1701(defun ffap--toggle-read-only (buffer-or-list)
1702 (with-current-buffer buffer 1702 (dolist (buffer (if (listp buffer-or-list)
1703 (with-no-warnings 1703 buffer-or-list
1704 (list buffer-or-list)))
1705 (with-current-buffer buffer
1704 (toggle-read-only 1)))) 1706 (toggle-read-only 1))))
1705 1707
1706(defun ffap-read-only () 1708(defun ffap-read-only ()
@@ -1710,8 +1712,7 @@ Only intended for interactive use."
1710 (let ((value (call-interactively 'ffap))) 1712 (let ((value (call-interactively 'ffap)))
1711 (unless (or (bufferp value) (bufferp (car-safe value))) 1713 (unless (or (bufferp value) (bufferp (car-safe value)))
1712 (setq value (current-buffer))) 1714 (setq value (current-buffer)))
1713 (mapc #'ffap--toggle-read-only 1715 (ffap--toggle-read-only value)
1714 (if (listp value) value (list value)))
1715 value)) 1716 value))
1716 1717
1717(defun ffap-read-only-other-window () 1718(defun ffap-read-only-other-window ()
@@ -1719,8 +1720,7 @@ Only intended for interactive use."
1719Only intended for interactive use." 1720Only intended for interactive use."
1720 (interactive) 1721 (interactive)
1721 (let ((value (ffap-other-window))) 1722 (let ((value (ffap-other-window)))
1722 (mapc #'ffap--toggle-read-only 1723 (ffap--toggle-read-only value)
1723 (if (listp value) value (list value)))
1724 value)) 1724 value))
1725 1725
1726(defun ffap-read-only-other-frame () 1726(defun ffap-read-only-other-frame ()
@@ -1728,8 +1728,7 @@ Only intended for interactive use."
1728Only intended for interactive use." 1728Only intended for interactive use."
1729 (interactive) 1729 (interactive)
1730 (let ((value (ffap-other-frame))) 1730 (let ((value (ffap-other-frame)))
1731 (mapc #'ffap--toggle-read-only 1731 (ffap--toggle-read-only value)
1732 (if (listp value) value (list value)))
1733 value)) 1732 value))
1734 1733
1735(defun ffap-alternate-file () 1734(defun ffap-alternate-file ()
diff --git a/lisp/files.el b/lisp/files.el
index 53b701dbcbe..7fc7ccc8553 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4824,41 +4824,51 @@ prints a message in the minibuffer. Instead, use `set-buffer-modified-p'."
4824 "Modification-flag cleared")) 4824 "Modification-flag cleared"))
4825 (set-buffer-modified-p arg)) 4825 (set-buffer-modified-p arg))
4826 4826
4827(defun toggle-read-only (&optional arg) 4827(defun toggle-read-only (&optional arg message)
4828 "Change whether this buffer is read-only. 4828 "Toggle the read-only state of the current buffer.
4829With prefix argument ARG, make the buffer read-only if ARG is 4829With prefix argument ARG, make the buffer read-only if ARG is
4830positive, otherwise make it writable. If buffer is read-only 4830positive; otherwise make it writable.
4831and `view-read-only' is non-nil, enter view mode. 4831
4832 4832When making the buffer read-only, enable View mode if
4833This function is usually the wrong thing to use in a Lisp program. 4833`view-read-only' is non-nil. When making the buffer writable,
4834It can have side-effects beyond changing the read-only status of a buffer 4834disable View mode if View mode is enabled.
4835\(e.g., enabling view mode), and does not affect read-only regions that 4835
4836are caused by text properties. To make a buffer read-only in Lisp code, 4836If called interactively, or if called from Lisp with MESSAGE
4837set `buffer-read-only'. To ignore read-only status (whether due to text 4837non-nil, print a message reporting the buffer's new read-only
4838properties or buffer state) and make changes, temporarily bind 4838status.
4839`inhibit-read-only'." 4839
4840Do not call this from a Lisp program unless you really intend to
4841do the same thing as the \\[toggle-read-only] command, including
4842possibly enabling or disabling View mode. Also, note that this
4843command works by setting the variable `buffer-read-only', which
4844does not affect read-only regions caused by text properties. To
4845ignore read-only status in a Lisp program (whether due to text
4846properties or buffer state), bind `inhibit-read-only' temporarily
4847to a non-nil value."
4840 (interactive "P") 4848 (interactive "P")
4841 (if (and arg 4849 (cond
4842 (if (> (prefix-numeric-value arg) 0) buffer-read-only 4850 ;; Do nothing if `buffer-read-only' already matches the state
4843 (not buffer-read-only))) ; If buffer-read-only is set correctly, 4851 ;; specified by ARG.
4844 nil ; do nothing. 4852 ((and arg
4845 ;; Toggle. 4853 (if (> (prefix-numeric-value arg) 0)
4846 (progn 4854 buffer-read-only
4847 (cond 4855 (not buffer-read-only))))
4848 ((and buffer-read-only view-mode) 4856 ;; If View mode is enabled, exit it.
4849 (View-exit-and-edit) 4857 ((and buffer-read-only view-mode)
4850 (make-local-variable 'view-read-only) 4858 (View-exit-and-edit)
4851 (setq view-read-only t)) ; Must leave view mode. 4859 (set (make-local-variable 'view-read-only) t))
4852 ((and (not buffer-read-only) view-read-only 4860 ;; If `view-read-only' is non-nil, enable View mode.
4853 ;; If view-mode is already active, `view-mode-enter' is a nop. 4861 ((and view-read-only
4854 (not view-mode) 4862 (not buffer-read-only)
4855 (not (eq (get major-mode 'mode-class) 'special))) 4863 (not view-mode)
4856 (view-mode-enter)) 4864 (not (eq (get major-mode 'mode-class) 'special)))
4857 (t (setq buffer-read-only (not buffer-read-only)) 4865 (view-mode-enter))
4858 (force-mode-line-update)))) 4866 ;; The usual action: flip `buffer-read-only'.
4859 (if (called-interactively-p 'interactive) 4867 (t (setq buffer-read-only (not buffer-read-only))
4860 (message "Read-only %s for this buffer" 4868 (force-mode-line-update)))
4861 (if buffer-read-only "enabled" "disabled"))))) 4869 (if (or message (called-interactively-p 'interactive))
4870 (message "Read-only %s for this buffer"
4871 (if buffer-read-only "enabled" "disabled"))))
4862 4872
4863(defun insert-file (filename) 4873(defun insert-file (filename)
4864 "Insert contents of file FILENAME into buffer after point. 4874 "Insert contents of file FILENAME into buffer after point.
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 5be5dd8cc56..4d40050acac 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,8 @@
12012-07-13 Chong Yidong <cyd@gnu.org>
2
3 * smime.el (smime-certificate-info): Set buffer-read-only directly,
4 instead of calling toggle-read-only with a (bogus) argument.
5
12012-07-09 Tassilo Horn <tassilo@member.fsf.org> 62012-07-09 Tassilo Horn <tassilo@member.fsf.org>
2 7
3 * gnus-sum.el (gnus-summary-limit-to-author): Use default value instead 8 * gnus-sum.el (gnus-summary-limit-to-author): Use default value instead
diff --git a/lisp/gnus/smime.el b/lisp/gnus/smime.el
index 73f4970fcd4..7492142947e 100644
--- a/lisp/gnus/smime.el
+++ b/lisp/gnus/smime.el
@@ -678,7 +678,7 @@ The following commands are available:
678 "x509" "-in" (expand-file-name certfile) "-text") 678 "x509" "-in" (expand-file-name certfile) "-text")
679 (fundamental-mode) 679 (fundamental-mode)
680 (set-buffer-modified-p nil) 680 (set-buffer-modified-p nil)
681 (toggle-read-only t) 681 (setq buffer-read-only t)
682 (goto-char (point-min)))) 682 (goto-char (point-min))))
683 683
684(defun smime-draw-buffer () 684(defun smime-draw-buffer ()
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index fa7d9b325db..7b6490b6b13 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -30,7 +30,6 @@
30;;; Code: 30;;; Code:
31 31
32(require 'button) 32(require 'button)
33(require 'view)
34(eval-when-compile (require 'easymenu)) 33(eval-when-compile (require 'easymenu))
35 34
36(defvar help-mode-map 35(defvar help-mode-map
@@ -288,10 +287,7 @@ Commands:
288;;;###autoload 287;;;###autoload
289(defun help-mode-finish () 288(defun help-mode-finish ()
290 (when (eq major-mode 'help-mode) 289 (when (eq major-mode 'help-mode)
291 ;; View mode's read-only status of existing *Help* buffer is lost 290 (setq buffer-read-only t)
292 ;; by with-output-to-temp-buffer.
293 (toggle-read-only 1)
294
295 (save-excursion 291 (save-excursion
296 (goto-char (point-min)) 292 (goto-char (point-min))
297 (let ((inhibit-read-only t)) 293 (let ((inhibit-read-only t))
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index 33fab8c9948..d29653c41ae 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -1283,7 +1283,7 @@ With optional ARG, make read-only only if ARG is positive."
1283 (:opstring "toggled read only status in" 1283 (:opstring "toggled read only status in"
1284 :interactive "P" 1284 :interactive "P"
1285 :modifier-p t) 1285 :modifier-p t)
1286 (toggle-read-only arg)) 1286 (toggle-read-only arg t))
1287 1287
1288(define-ibuffer-op ibuffer-do-delete () 1288(define-ibuffer-op ibuffer-do-delete ()
1289 "Kill marked buffers as with `kill-this-buffer'." 1289 "Kill marked buffers as with `kill-this-buffer'."
diff --git a/lisp/vc/ediff.el b/lisp/vc/ediff.el
index a1d778beebc..a1f3b72942f 100644
--- a/lisp/vc/ediff.el
+++ b/lisp/vc/ediff.el
@@ -152,7 +152,7 @@
152;; Used as a startup hook to set `_orig' patch file read-only. 152;; Used as a startup hook to set `_orig' patch file read-only.
153(defun ediff-set-read-only-in-buf-A () 153(defun ediff-set-read-only-in-buf-A ()
154 (ediff-with-current-buffer ediff-buffer-A 154 (ediff-with-current-buffer ediff-buffer-A
155 (toggle-read-only 1))) 155 (setq buffer-read-only t)))
156 156
157;; Return a plausible default for ediff's first file: 157;; Return a plausible default for ediff's first file:
158;; In dired, return the file number FILENO (or 0) in the list 158;; In dired, return the file number FILENO (or 0) in the list