diff options
| author | Stefan Monnier | 2012-08-29 11:11:51 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2012-08-29 11:11:51 -0400 |
| commit | 35e62fc984b108f717c5525ffecf60586eb0737e (patch) | |
| tree | fd00c70fbf024b7e5290086bcbc8a9f226a30a03 | |
| parent | c2c43c2382db292bfe3cccbccad4386f81f9c8a4 (diff) | |
| download | emacs-35e62fc984b108f717c5525ffecf60586eb0737e.tar.gz emacs-35e62fc984b108f717c5525ffecf60586eb0737e.zip | |
* 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.
| -rw-r--r-- | etc/NEWS | 2 | ||||
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/emacs-lisp/gv.el | 5 | ||||
| -rw-r--r-- | lisp/ffap.el | 2 | ||||
| -rw-r--r-- | lisp/files.el | 55 | ||||
| -rw-r--r-- | lisp/ibuffer.el | 2 | ||||
| -rw-r--r-- | lisp/obsolete/vc-mcvs.el | 2 | ||||
| -rw-r--r-- | lisp/vc/vc-cvs.el | 2 | ||||
| -rw-r--r-- | lisp/vc/vc.el | 4 |
9 files changed, 42 insertions, 42 deletions
| @@ -588,6 +588,8 @@ are deprecated and will be removed eventually. | |||
| 588 | 588 | ||
| 589 | * Lisp changes in Emacs 24.3 | 589 | * Lisp changes in Emacs 24.3 |
| 590 | 590 | ||
| 591 | ** New minor mode `read-only-mode' to replace toggle-read-only (now obsolete). | ||
| 592 | |||
| 591 | ** New functions `autoloadp' and `autoload-do-load'. | 593 | ** New functions `autoloadp' and `autoload-do-load'. |
| 592 | 594 | ||
| 593 | ** New function `posnp' to test if an object is a `posn'. | 595 | ** New function `posnp' to test if an object is a `posn'. |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bfca3f073f2..48403c7f046 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2012-08-29 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * files.el (read-only-mode): New minor mode. | ||
| 4 | (toggle-read-only): Use it and mark obsolete. | ||
| 5 | (find-file--read-only): | ||
| 6 | * vc/vc.el (vc-next-action, vc-checkout): | ||
| 7 | * vc/vc-cvs.el (vc-cvs-checkout): | ||
| 8 | * obsolete/vc-mcvs.el (vc-mcvs-update): | ||
| 9 | * ffap.el (ffap--toggle-read-only): Update callers. | ||
| 10 | |||
| 1 | 2012-08-29 Michael Albinus <michael.albinus@gmx.de> | 11 | 2012-08-29 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 12 | ||
| 3 | * eshell/esh-ext.el (eshell-external-command): Do not examine | 13 | * eshell/esh-ext.el (eshell-external-command): Do not examine |
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index d1f997c99c4..4caa0a73866 100644 --- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el | |||
| @@ -191,8 +191,9 @@ well for simple place forms. | |||
| 191 | Assignments of VAL to (NAME ARGS...) are expanded by binding the argument | 191 | Assignments of VAL to (NAME ARGS...) are expanded by binding the argument |
| 192 | forms (VAL ARGS...) according to ARGLIST, then executing BODY, which must | 192 | forms (VAL ARGS...) according to ARGLIST, then executing BODY, which must |
| 193 | return a Lisp form that does the assignment. | 193 | return a Lisp form that does the assignment. |
| 194 | Actually, ARGLIST may be bound to temporary variables which are introduced | 194 | The first arg in ARLIST (the one that receives VAL) receives an expression |
| 195 | automatically to preserve proper execution order of the arguments. Example: | 195 | which can do arbitrary things, whereas the other arguments are all guaranteed |
| 196 | to be pure and copyable. Example use: | ||
| 196 | (gv-define-setter aref (v a i) `(aset ,a ,i ,v))" | 197 | (gv-define-setter aref (v a i) `(aset ,a ,i ,v))" |
| 197 | (declare (indent 2) (debug (&define name sexp body))) | 198 | (declare (indent 2) (debug (&define name sexp body))) |
| 198 | `(gv-define-expander ,name | 199 | `(gv-define-expander ,name |
diff --git a/lisp/ffap.el b/lisp/ffap.el index d0f3b639cf2..ebe8b6dee94 100644 --- a/lisp/ffap.el +++ b/lisp/ffap.el | |||
| @@ -1703,7 +1703,7 @@ Only intended for interactive use." | |||
| 1703 | buffer-or-list | 1703 | buffer-or-list |
| 1704 | (list buffer-or-list))) | 1704 | (list buffer-or-list))) |
| 1705 | (with-current-buffer buffer | 1705 | (with-current-buffer buffer |
| 1706 | (toggle-read-only 1)))) | 1706 | (read-only-mode 1)))) |
| 1707 | 1707 | ||
| 1708 | (defun ffap-read-only () | 1708 | (defun ffap-read-only () |
| 1709 | "Like `ffap', but mark buffer as read-only. | 1709 | "Like `ffap', but mark buffer as read-only. |
diff --git a/lisp/files.el b/lisp/files.el index fecb02020e6..5c8e1ef396b 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -1456,7 +1456,7 @@ file names with wildcards." | |||
| 1456 | (file-exists-p filename)) | 1456 | (file-exists-p filename)) |
| 1457 | (error "%s does not exist" filename)) | 1457 | (error "%s does not exist" filename)) |
| 1458 | (let ((value (funcall fun filename wildcards))) | 1458 | (let ((value (funcall fun filename wildcards))) |
| 1459 | (mapc (lambda (b) (with-current-buffer b (toggle-read-only 1))) | 1459 | (mapc (lambda (b) (with-current-buffer b (read-only-mode 1))) |
| 1460 | (if (listp value) value (list value))) | 1460 | (if (listp value) value (list value))) |
| 1461 | value)) | 1461 | value)) |
| 1462 | 1462 | ||
| @@ -4818,18 +4818,11 @@ prints a message in the minibuffer. Instead, use `set-buffer-modified-p'." | |||
| 4818 | "Modification-flag cleared")) | 4818 | "Modification-flag cleared")) |
| 4819 | (set-buffer-modified-p arg)) | 4819 | (set-buffer-modified-p arg)) |
| 4820 | 4820 | ||
| 4821 | (defun toggle-read-only (&optional arg message) | 4821 | (define-minor-mode read-only-mode |
| 4822 | "Toggle the read-only state of the current buffer. | 4822 | "Change whether the current buffer is read-only. |
| 4823 | With prefix argument ARG, make the buffer read-only if ARG is | 4823 | With prefix argument ARG, make the buffer read-only if ARG is |
| 4824 | positive; otherwise make it writable. | 4824 | positive, otherwise make it writable. If buffer is read-only |
| 4825 | 4825 | and `view-read-only' is non-nil, enter view mode. | |
| 4826 | When making the buffer read-only, enable View mode if | ||
| 4827 | `view-read-only' is non-nil. When making the buffer writable, | ||
| 4828 | disable View mode if View mode is enabled. | ||
| 4829 | |||
| 4830 | If called interactively, or if called from Lisp with MESSAGE | ||
| 4831 | non-nil, print a message reporting the buffer's new read-only | ||
| 4832 | status. | ||
| 4833 | 4826 | ||
| 4834 | Do not call this from a Lisp program unless you really intend to | 4827 | Do not call this from a Lisp program unless you really intend to |
| 4835 | do the same thing as the \\[toggle-read-only] command, including | 4828 | do the same thing as the \\[toggle-read-only] command, including |
| @@ -4839,30 +4832,24 @@ does not affect read-only regions caused by text properties. To | |||
| 4839 | ignore read-only status in a Lisp program (whether due to text | 4832 | ignore read-only status in a Lisp program (whether due to text |
| 4840 | properties or buffer state), bind `inhibit-read-only' temporarily | 4833 | properties or buffer state), bind `inhibit-read-only' temporarily |
| 4841 | to a non-nil value." | 4834 | to a non-nil value." |
| 4842 | (interactive "P") | 4835 | :variable buffer-read-only |
| 4843 | (cond | 4836 | (cond |
| 4844 | ;; Do nothing if `buffer-read-only' already matches the state | 4837 | ((and (not buffer-read-only) view-mode) |
| 4845 | ;; specified by ARG. | ||
| 4846 | ((and arg | ||
| 4847 | (if (> (prefix-numeric-value arg) 0) | ||
| 4848 | buffer-read-only | ||
| 4849 | (not buffer-read-only)))) | ||
| 4850 | ;; If View mode is enabled, exit it. | ||
| 4851 | ((and buffer-read-only view-mode) | ||
| 4852 | (View-exit-and-edit) | 4838 | (View-exit-and-edit) |
| 4853 | (set (make-local-variable 'view-read-only) t)) | 4839 | (make-local-variable 'view-read-only) |
| 4854 | ;; If `view-read-only' is non-nil, enable View mode. | 4840 | (setq view-read-only t)) ; Must leave view mode. |
| 4855 | ((and view-read-only | 4841 | ((and buffer-read-only view-read-only |
| 4856 | (not buffer-read-only) | 4842 | ;; If view-mode is already active, `view-mode-enter' is a nop. |
| 4857 | (not view-mode) | 4843 | (not view-mode) |
| 4858 | (not (eq (get major-mode 'mode-class) 'special))) | 4844 | (not (eq (get major-mode 'mode-class) 'special))) |
| 4859 | (view-mode-enter)) | 4845 | (view-mode-enter)))) |
| 4860 | ;; The usual action: flip `buffer-read-only'. | 4846 | |
| 4861 | (t (setq buffer-read-only (not buffer-read-only)) | 4847 | (defun toggle-read-only (&optional arg interactive) |
| 4862 | (force-mode-line-update))) | 4848 | (declare (obsolete read-only-mode "24.3")) |
| 4863 | (if (or message (called-interactively-p 'interactive)) | 4849 | (interactive (list current-prefix-arg t)) |
| 4864 | (message "Read-only %s for this buffer" | 4850 | (if interactive |
| 4865 | (if buffer-read-only "enabled" "disabled")))) | 4851 | (call-interactively 'read-only-mode) |
| 4852 | (read-only-mode (or arg 'toggle)))) | ||
| 4866 | 4853 | ||
| 4867 | (defun insert-file (filename) | 4854 | (defun insert-file (filename) |
| 4868 | "Insert contents of file FILENAME into buffer after point. | 4855 | "Insert contents of file FILENAME into buffer after point. |
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el index 648c4c3b0af..c6e799252a2 100644 --- a/lisp/ibuffer.el +++ b/lisp/ibuffer.el | |||
| @@ -2401,7 +2401,7 @@ Operations on marked buffers: | |||
| 2401 | buffer's file as an argument. | 2401 | buffer's file as an argument. |
| 2402 | '\\[ibuffer-do-eval]' - Evaluate a form in each of the marked buffers. This | 2402 | '\\[ibuffer-do-eval]' - Evaluate a form in each of the marked buffers. This |
| 2403 | is a very flexible command. For example, if you want to make all | 2403 | is a very flexible command. For example, if you want to make all |
| 2404 | of the marked buffers read only, try using (toggle-read-only 1) as | 2404 | of the marked buffers read only, try using (read-only-mode 1) as |
| 2405 | the input form. | 2405 | the input form. |
| 2406 | '\\[ibuffer-do-view-and-eval]' - As above, but view each buffer while the form | 2406 | '\\[ibuffer-do-view-and-eval]' - As above, but view each buffer while the form |
| 2407 | is evaluated. | 2407 | is evaluated. |
diff --git a/lisp/obsolete/vc-mcvs.el b/lisp/obsolete/vc-mcvs.el index 94db90f1d6a..78221945073 100644 --- a/lisp/obsolete/vc-mcvs.el +++ b/lisp/obsolete/vc-mcvs.el | |||
| @@ -329,7 +329,7 @@ This is only possible if Meta-CVS is responsible for FILE's directory.") | |||
| 329 | (if vc-mcvs-use-edit | 329 | (if vc-mcvs-use-edit |
| 330 | (vc-mcvs-command nil 0 file "edit") | 330 | (vc-mcvs-command nil 0 file "edit") |
| 331 | (set-file-modes file (logior (file-modes file) 128)) | 331 | (set-file-modes file (logior (file-modes file) 128)) |
| 332 | (if (equal file buffer-file-name) (toggle-read-only -1)))) | 332 | (if (equal file buffer-file-name) (read-only-mode -1)))) |
| 333 | ;; Check out a particular revision (or recreate the file). | 333 | ;; Check out a particular revision (or recreate the file). |
| 334 | (vc-file-setprop file 'vc-working-revision nil) | 334 | (vc-file-setprop file 'vc-working-revision nil) |
| 335 | (apply 'vc-mcvs-command nil 0 file | 335 | (apply 'vc-mcvs-command nil 0 file |
diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el index c1c4b750267..ae1a3cf92f8 100644 --- a/lisp/vc/vc-cvs.el +++ b/lisp/vc/vc-cvs.el | |||
| @@ -394,7 +394,7 @@ REV is the revision to check out." | |||
| 394 | (if vc-cvs-use-edit | 394 | (if vc-cvs-use-edit |
| 395 | (vc-cvs-command nil 0 file "edit") | 395 | (vc-cvs-command nil 0 file "edit") |
| 396 | (set-file-modes file (logior (file-modes file) 128)) | 396 | (set-file-modes file (logior (file-modes file) 128)) |
| 397 | (if (equal file buffer-file-name) (toggle-read-only -1)))) | 397 | (if (equal file buffer-file-name) (read-only-mode -1)))) |
| 398 | ;; Check out a particular revision (or recreate the file). | 398 | ;; Check out a particular revision (or recreate the file). |
| 399 | (vc-file-setprop file 'vc-working-revision nil) | 399 | (vc-file-setprop file 'vc-working-revision nil) |
| 400 | (apply 'vc-cvs-command nil 0 file | 400 | (apply 'vc-cvs-command nil 0 file |
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index ddb9565544d..1ef4faaa008 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el | |||
| @@ -1133,7 +1133,7 @@ For old-style locking-based version control systems, like RCS: | |||
| 1133 | (let ((visited (get-file-buffer file))) | 1133 | (let ((visited (get-file-buffer file))) |
| 1134 | (when visited | 1134 | (when visited |
| 1135 | (with-current-buffer visited | 1135 | (with-current-buffer visited |
| 1136 | (toggle-read-only -1)))))) | 1136 | (read-only-mode -1)))))) |
| 1137 | ;; Allow user to revert files with no changes | 1137 | ;; Allow user to revert files with no changes |
| 1138 | (save-excursion | 1138 | (save-excursion |
| 1139 | (dolist (file files) | 1139 | (dolist (file files) |
| @@ -1344,7 +1344,7 @@ After check-out, runs the normal hook `vc-checkout-hook'." | |||
| 1344 | ;; Maybe the backend is not installed ;-( | 1344 | ;; Maybe the backend is not installed ;-( |
| 1345 | (when writable | 1345 | (when writable |
| 1346 | (let ((buf (get-file-buffer file))) | 1346 | (let ((buf (get-file-buffer file))) |
| 1347 | (when buf (with-current-buffer buf (toggle-read-only -1))))) | 1347 | (when buf (with-current-buffer buf (read-only-mode -1))))) |
| 1348 | (signal (car err) (cdr err)))) | 1348 | (signal (car err) (cdr err)))) |
| 1349 | `((vc-state . ,(if (or (eq (vc-checkout-model backend (list file)) 'implicit) | 1349 | `((vc-state . ,(if (or (eq (vc-checkout-model backend (list file)) 'implicit) |
| 1350 | (not writable)) | 1350 | (not writable)) |