From af070a1c6a6373b0c854ffb94ab67aaef9582bab Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 29 Aug 2012 13:36:49 -0400 Subject: [PATCH] * lisp/simple.el (read-only-mode): Move from lisp/files.el for bootstrapping. * files.el (read-only-mode): Move to simple.el. --- lisp/ChangeLog | 3 +++ lisp/files.el | 26 -------------------------- lisp/simple.el | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 48403c7f046..64ccde6705e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2012-08-29 Stefan Monnier + * simple.el (read-only-mode): Move from files.el for bootstrapping. + * files.el (read-only-mode): Move to simple.el. + * files.el (read-only-mode): New minor mode. (toggle-read-only): Use it and mark obsolete. (find-file--read-only): diff --git a/lisp/files.el b/lisp/files.el index 5c8e1ef396b..ef7f8e43a41 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -4818,32 +4818,6 @@ prints a message in the minibuffer. Instead, use `set-buffer-modified-p'." "Modification-flag cleared")) (set-buffer-modified-p arg)) -(define-minor-mode read-only-mode - "Change whether the current 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. - -Do not call this from a Lisp program unless you really intend to -do the same thing as the \\[toggle-read-only] command, including -possibly enabling or disabling View mode. Also, note that this -command works by setting the variable `buffer-read-only', which -does not affect read-only regions caused by text properties. To -ignore read-only status in a Lisp program (whether due to text -properties or buffer state), bind `inhibit-read-only' temporarily -to a non-nil value." - :variable buffer-read-only - (cond - ((and (not buffer-read-only) view-mode) - (View-exit-and-edit) - (make-local-variable 'view-read-only) - (setq view-read-only t)) ; Must leave view mode. - ((and buffer-read-only view-read-only - ;; If view-mode is already active, `view-mode-enter' is a nop. - (not view-mode) - (not (eq (get major-mode 'mode-class) 'special))) - (view-mode-enter)))) - (defun toggle-read-only (&optional arg interactive) (declare (obsolete read-only-mode "24.3")) (interactive (list current-prefix-arg t)) diff --git a/lisp/simple.el b/lisp/simple.el index 1080757f7d2..7673e4c5d6e 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -6961,6 +6961,32 @@ See also `normal-erase-is-backspace'." (defvar vis-mode-saved-buffer-invisibility-spec nil "Saved value of `buffer-invisibility-spec' when Visible mode is on.") +(define-minor-mode read-only-mode + "Change whether the current 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. + +Do not call this from a Lisp program unless you really intend to +do the same thing as the \\[toggle-read-only] command, including +possibly enabling or disabling View mode. Also, note that this +command works by setting the variable `buffer-read-only', which +does not affect read-only regions caused by text properties. To +ignore read-only status in a Lisp program (whether due to text +properties or buffer state), bind `inhibit-read-only' temporarily +to a non-nil value." + :variable buffer-read-only + (cond + ((and (not buffer-read-only) view-mode) + (View-exit-and-edit) + (make-local-variable 'view-read-only) + (setq view-read-only t)) ; Must leave view mode. + ((and buffer-read-only view-read-only + ;; If view-mode is already active, `view-mode-enter' is a nop. + (not view-mode) + (not (eq (get major-mode 'mode-class) 'special))) + (view-mode-enter)))) + (define-minor-mode visible-mode "Toggle making all invisible text temporarily visible (Visible mode). With a prefix argument ARG, enable Visible mode if ARG is -- 2.39.2