emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r109811: * lisp/files.el (read-only-m


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109811: * lisp/files.el (read-only-mode): New minor mode.
Date: Wed, 29 Aug 2012 11:11:51 -0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109811
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Wed 2012-08-29 11:11:51 -0400
message:
  * lisp/files.el (read-only-mode): New minor mode.
  (toggle-read-only): Use it and mark obsolete.
  (find-file--read-only):
  * lisp/vc/vc.el (vc-next-action, vc-checkout):
  * lisp/vc/vc-cvs.el (vc-cvs-checkout):
  * lisp/obsolete/vc-mcvs.el (vc-mcvs-update):
  * lisp/ffap.el (ffap--toggle-read-only): Update callers.
modified:
  etc/NEWS
  lisp/ChangeLog
  lisp/emacs-lisp/gv.el
  lisp/ffap.el
  lisp/files.el
  lisp/ibuffer.el
  lisp/obsolete/vc-mcvs.el
  lisp/vc/vc-cvs.el
  lisp/vc/vc.el
=== modified file 'etc/NEWS'
--- a/etc/NEWS  2012-08-28 16:01:59 +0000
+++ b/etc/NEWS  2012-08-29 15:11:51 +0000
@@ -588,6 +588,8 @@
 
 * Lisp changes in Emacs 24.3
 
+** New minor mode `read-only-mode' to replace toggle-read-only (now obsolete).
+
 ** New functions `autoloadp' and `autoload-do-load'.
 
 ** New function `posnp' to test if an object is a `posn'.

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-08-29 12:49:44 +0000
+++ b/lisp/ChangeLog    2012-08-29 15:11:51 +0000
@@ -1,3 +1,13 @@
+2012-08-29  Stefan Monnier  <address@hidden>
+
+       * files.el (read-only-mode): New minor mode.
+       (toggle-read-only): Use it and mark obsolete.
+       (find-file--read-only):
+       * vc/vc.el (vc-next-action, vc-checkout):
+       * vc/vc-cvs.el (vc-cvs-checkout):
+       * obsolete/vc-mcvs.el (vc-mcvs-update):
+       * ffap.el (ffap--toggle-read-only): Update callers.
+
 2012-08-29  Michael Albinus  <address@hidden>
 
        * eshell/esh-ext.el (eshell-external-command): Do not examine

=== modified file 'lisp/emacs-lisp/gv.el'
--- a/lisp/emacs-lisp/gv.el     2012-07-26 01:27:33 +0000
+++ b/lisp/emacs-lisp/gv.el     2012-08-29 15:11:51 +0000
@@ -191,8 +191,9 @@
 Assignments of VAL to (NAME ARGS...) are expanded by binding the argument
 forms (VAL ARGS...) according to ARGLIST, then executing BODY, which must
 return a Lisp form that does the assignment.
-Actually, ARGLIST may be bound to temporary variables which are introduced
-automatically to preserve proper execution order of the arguments.  Example:
+The first arg in ARLIST (the one that receives VAL) receives an expression
+which can do arbitrary things, whereas the other arguments are all guaranteed
+to be pure and copyable.  Example use:
   (gv-define-setter aref (v a i) `(aset ,a ,i ,v))"
   (declare (indent 2) (debug (&define name sexp body)))
   `(gv-define-expander ,name

=== modified file 'lisp/ffap.el'
--- a/lisp/ffap.el      2012-08-15 16:29:11 +0000
+++ b/lisp/ffap.el      2012-08-29 15:11:51 +0000
@@ -1703,7 +1703,7 @@
                      buffer-or-list
                    (list buffer-or-list)))
     (with-current-buffer buffer
-      (toggle-read-only 1))))
+      (read-only-mode 1))))
 
 (defun ffap-read-only ()
   "Like `ffap', but mark buffer as read-only.

=== modified file 'lisp/files.el'
--- a/lisp/files.el     2012-08-28 16:01:59 +0000
+++ b/lisp/files.el     2012-08-29 15:11:51 +0000
@@ -1456,7 +1456,7 @@
              (file-exists-p filename))
     (error "%s does not exist" filename))
   (let ((value (funcall fun filename wildcards)))
-    (mapc (lambda (b) (with-current-buffer b (toggle-read-only 1)))
+    (mapc (lambda (b) (with-current-buffer b (read-only-mode 1)))
          (if (listp value) value (list value)))
     value))
 
@@ -4818,18 +4818,11 @@
               "Modification-flag cleared"))
   (set-buffer-modified-p arg))
 
-(defun toggle-read-only (&optional arg message)
-  "Toggle the read-only state of the current buffer.
+(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.
-
-When making the buffer read-only, enable View mode if
-`view-read-only' is non-nil.  When making the buffer writable,
-disable View mode if View mode is enabled.
-
-If called interactively, or if called from Lisp with MESSAGE
-non-nil, print a message reporting the buffer's new read-only
-status.
+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
@@ -4839,30 +4832,24 @@
 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."
-  (interactive "P")
+  :variable buffer-read-only
   (cond
-   ;; Do nothing if `buffer-read-only' already matches the state
-   ;; specified by ARG.
-   ((and arg
-        (if (> (prefix-numeric-value arg) 0)
-            buffer-read-only
-          (not buffer-read-only))))
-   ;; If View mode is enabled, exit it.
-   ((and buffer-read-only view-mode)
+   ((and (not buffer-read-only) view-mode)
     (View-exit-and-edit)
-    (set (make-local-variable 'view-read-only) t))
-   ;; If `view-read-only' is non-nil, enable View mode.
-   ((and view-read-only
-        (not buffer-read-only)
-        (not view-mode)
-        (not (eq (get major-mode 'mode-class) 'special)))
-    (view-mode-enter))
-   ;; The usual action: flip `buffer-read-only'.
-   (t (setq buffer-read-only (not buffer-read-only))
-      (force-mode-line-update)))
-  (if (or message (called-interactively-p 'interactive))
-      (message "Read-only %s for this buffer"
-              (if buffer-read-only "enabled" "disabled"))))
+    (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))
+  (if interactive
+      (call-interactively 'read-only-mode)
+    (read-only-mode (or arg 'toggle))))
 
 (defun insert-file (filename)
   "Insert contents of file FILENAME into buffer after point.

=== modified file 'lisp/ibuffer.el'
--- a/lisp/ibuffer.el   2012-08-12 17:29:53 +0000
+++ b/lisp/ibuffer.el   2012-08-29 15:11:51 +0000
@@ -2401,7 +2401,7 @@
           buffer's file as an argument.
   '\\[ibuffer-do-eval]' - Evaluate a form in each of the marked buffers.  This
           is a very flexible command.  For example, if you want to make all
-          of the marked buffers read only, try using (toggle-read-only 1) as
+          of the marked buffers read only, try using (read-only-mode 1) as
           the input form.
   '\\[ibuffer-do-view-and-eval]' - As above, but view each buffer while the 
form
           is evaluated.

=== modified file 'lisp/obsolete/vc-mcvs.el'
--- a/lisp/obsolete/vc-mcvs.el  2012-01-19 07:21:25 +0000
+++ b/lisp/obsolete/vc-mcvs.el  2012-08-29 15:11:51 +0000
@@ -329,7 +329,7 @@
           (if vc-mcvs-use-edit
               (vc-mcvs-command nil 0 file "edit")
             (set-file-modes file (logior (file-modes file) 128))
-            (if (equal file buffer-file-name) (toggle-read-only -1))))
+            (if (equal file buffer-file-name) (read-only-mode -1))))
     ;; Check out a particular revision (or recreate the file).
     (vc-file-setprop file 'vc-working-revision nil)
     (apply 'vc-mcvs-command nil 0 file

=== modified file 'lisp/vc/vc-cvs.el'
--- a/lisp/vc/vc-cvs.el 2012-08-24 04:05:25 +0000
+++ b/lisp/vc/vc-cvs.el 2012-08-29 15:11:51 +0000
@@ -394,7 +394,7 @@
              (if vc-cvs-use-edit
                  (vc-cvs-command nil 0 file "edit")
                (set-file-modes file (logior (file-modes file) 128))
-               (if (equal file buffer-file-name) (toggle-read-only -1))))
+               (if (equal file buffer-file-name) (read-only-mode -1))))
       ;; Check out a particular revision (or recreate the file).
       (vc-file-setprop file 'vc-working-revision nil)
       (apply 'vc-cvs-command nil 0 file

=== modified file 'lisp/vc/vc.el'
--- a/lisp/vc/vc.el     2012-08-15 19:20:26 +0000
+++ b/lisp/vc/vc.el     2012-08-29 15:11:51 +0000
@@ -1133,7 +1133,7 @@
            (let ((visited (get-file-buffer file)))
              (when visited
                (with-current-buffer visited
-                 (toggle-read-only -1))))))
+                 (read-only-mode -1))))))
        ;; Allow user to revert files with no changes
        (save-excursion
           (dolist (file files)
@@ -1344,7 +1344,7 @@
          ;; Maybe the backend is not installed ;-(
          (when writable
            (let ((buf (get-file-buffer file)))
-             (when buf (with-current-buffer buf (toggle-read-only -1)))))
+             (when buf (with-current-buffer buf (read-only-mode -1)))))
          (signal (car err) (cdr err))))
       `((vc-state . ,(if (or (eq (vc-checkout-model backend (list file)) 
'implicit)
                              (not writable))


reply via email to

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