Mercurial > emacs
comparison lisp/files.el @ 46450:42a341bf9194
Bind toggle-read-only to C-x C-q.
(toggle-read-only): Display a warning message if the file is under
version control.
author | André Spiegel <spiegel@gnu.org> |
---|---|
date | Tue, 16 Jul 2002 17:40:37 +0000 |
parents | 4ad453c26cf3 |
children | 3ce42e66c023 |
comparison
equal
deleted
inserted
replaced
46449:b554160f3810 | 46450:42a341bf9194 |
---|---|
3055 (defun toggle-read-only (&optional arg) | 3055 (defun toggle-read-only (&optional arg) |
3056 "Change whether this buffer is visiting its file read-only. | 3056 "Change whether this buffer is visiting its file read-only. |
3057 With arg, set read-only iff arg is positive. | 3057 With arg, set read-only iff arg is positive. |
3058 If visiting file read-only and `view-read-only' is non-nil, enter view mode." | 3058 If visiting file read-only and `view-read-only' is non-nil, enter view mode." |
3059 (interactive "P") | 3059 (interactive "P") |
3060 (cond | 3060 (if (and arg |
3061 ((and arg (if (> (prefix-numeric-value arg) 0) buffer-read-only | 3061 (if (> (prefix-numeric-value arg) 0) buffer-read-only |
3062 (not buffer-read-only))) ; If buffer-read-only is set correctly, | 3062 (not buffer-read-only))) ; If buffer-read-only is set correctly, |
3063 nil) ; do nothing. | 3063 nil ; do nothing. |
3064 ;; Toggle. | 3064 ;; Toggle. |
3065 ((and buffer-read-only view-mode) | 3065 (cond |
3066 (View-exit-and-edit) | 3066 ((and buffer-read-only view-mode) |
3067 (make-local-variable 'view-read-only) | 3067 (View-exit-and-edit) |
3068 (setq view-read-only t)) ; Must leave view mode. | 3068 (make-local-variable 'view-read-only) |
3069 ((and (not buffer-read-only) view-read-only | 3069 (setq view-read-only t)) ; Must leave view mode. |
3070 (not (eq (get major-mode 'mode-class) 'special))) | 3070 ((and (not buffer-read-only) view-read-only |
3071 (view-mode-enter)) | 3071 (not (eq (get major-mode 'mode-class) 'special))) |
3072 (t (setq buffer-read-only (not buffer-read-only)) | 3072 (view-mode-enter)) |
3073 (force-mode-line-update)))) | 3073 (t (setq buffer-read-only (not buffer-read-only)) |
3074 (force-mode-line-update))) | |
3075 (if (vc-backend buffer-file-name) | |
3076 (message (substitute-command-keys | |
3077 (concat "File is under version-control, " | |
3078 "consider \\[vc-next-action] to check in/out")))))) | |
3074 | 3079 |
3075 (defun insert-file (filename) | 3080 (defun insert-file (filename) |
3076 "Insert contents of file FILENAME into buffer after point. | 3081 "Insert contents of file FILENAME into buffer after point. |
3077 Set mark after the inserted text. | 3082 Set mark after the inserted text. |
3078 | 3083 |
4142 (define-key ctl-x-map "\C-w" 'write-file) | 4147 (define-key ctl-x-map "\C-w" 'write-file) |
4143 (define-key ctl-x-map "i" 'insert-file) | 4148 (define-key ctl-x-map "i" 'insert-file) |
4144 (define-key esc-map "~" 'not-modified) | 4149 (define-key esc-map "~" 'not-modified) |
4145 (define-key ctl-x-map "\C-d" 'list-directory) | 4150 (define-key ctl-x-map "\C-d" 'list-directory) |
4146 (define-key ctl-x-map "\C-c" 'save-buffers-kill-emacs) | 4151 (define-key ctl-x-map "\C-c" 'save-buffers-kill-emacs) |
4152 (define-key ctl-x-map "\C-q" 'toggle-read-only) | |
4147 | 4153 |
4148 (define-key ctl-x-4-map "f" 'find-file-other-window) | 4154 (define-key ctl-x-4-map "f" 'find-file-other-window) |
4149 (define-key ctl-x-4-map "r" 'find-file-read-only-other-window) | 4155 (define-key ctl-x-4-map "r" 'find-file-read-only-other-window) |
4150 (define-key ctl-x-4-map "\C-f" 'find-file-other-window) | 4156 (define-key ctl-x-4-map "\C-f" 'find-file-other-window) |
4151 (define-key ctl-x-4-map "b" 'switch-to-buffer-other-window) | 4157 (define-key ctl-x-4-map "b" 'switch-to-buffer-other-window) |