bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#11726: closed (Re: bug#11726: 24.1; `C-x C-q' should say that the bu


From: Stefan Monnier
Subject: bug#11726: closed (Re: bug#11726: 24.1; `C-x C-q' should say that the buffer is now read only or writable)
Date: Wed, 27 Jun 2012 10:06:51 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

>> I added a message after `C-x C-q' -- thanks.
> This is an annoyance.
> emacs -Q
> M-x custom TAB
> -> "Read-only enabled for this buffer" in the echo area

define-minor-mode only outputs such messages when the function is
called interactively, so we should do the same for toggle-read-only.
Or rather we should probably use something like the patch below.

But it's also the case that toggle-read-only should not be called from
Elisp, so another bug is to call toggle-read-only rather than to set
buffer-read-only.


        Stefan


=== modified file 'lisp/files.el'
--- lisp/files.el       2012-06-26 16:23:01 +0000
+++ lisp/files.el       2012-06-27 14:02:59 +0000
@@ -4842,7 +4842,7 @@
               "Modification-flag cleared"))
   (set-buffer-modified-p arg))
 
-(defun toggle-read-only (&optional arg)
+(define-minor-mode toggle-read-only
   "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
@@ -4855,27 +4855,17 @@
 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
-             (not buffer-read-only)))  ; If buffer-read-only is set correctly,
-      nil                             ; do nothing.
-    ;; Toggle.
-    (progn
+  :variable buffer-read-only
       (cond
-       ((and buffer-read-only view-mode)
+   ((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 (not buffer-read-only) view-read-only
+   ((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))
-       (t (setq buffer-read-only (not buffer-read-only))
-         (force-mode-line-update))))
-    (message "Read-only %s for this buffer"
-            (if buffer-read-only "enabled" "disabled"))))
+    (view-mode-enter))))
 
 (defun insert-file (filename)
   "Insert contents of file FILENAME into buffer after point.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]