diff options
| author | Richard M. Stallman | 1997-06-18 17:24:59 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-06-18 17:24:59 +0000 |
| commit | 2a9fe1e256b2295a5dab41fced60f3397ae846f4 (patch) | |
| tree | 6da2f166672fe1abd5c9b2a871e34527eeae2560 | |
| parent | 089e3cb0acf24f8c182f81192ab52b6c6211f05d (diff) | |
| download | emacs-2a9fe1e256b2295a5dab41fced60f3397ae846f4.tar.gz emacs-2a9fe1e256b2295a5dab41fced60f3397ae846f4.zip | |
(backup, find-file): Make `files' their parent.
(view-read-only): New option variable. If
non-nil then buffers visiting files read-only, do it in view mode.
(find-file-read-only, find-file-read-only-other-window)
(find-file-read-only-other-frame): Call toggle-read-only
instead of setting buffer-read-only explicitly.
(toggle-read-only, after-find-file): Handle view-read-only.
(save-some-buffers): Use second argument of view-buffer
instead of setting view-exit-action.
| -rw-r--r-- | lisp/files.el | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/lisp/files.el b/lisp/files.el index 6e4373911c6..e70d3b75dd2 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -32,11 +32,11 @@ | |||
| 32 | 32 | ||
| 33 | (defgroup backup nil | 33 | (defgroup backup nil |
| 34 | "Backups of edited data files." | 34 | "Backups of edited data files." |
| 35 | :group 'data) | 35 | :group 'files) |
| 36 | 36 | ||
| 37 | (defgroup find-file nil | 37 | (defgroup find-file nil |
| 38 | "Finding and editing files." | 38 | "Finding files." |
| 39 | :group 'data) | 39 | :group 'files) |
| 40 | 40 | ||
| 41 | 41 | ||
| 42 | (defcustom delete-auto-save-files t | 42 | (defcustom delete-auto-save-files t |
| @@ -335,6 +335,9 @@ and ignores this variable." | |||
| 335 | (or (fboundp 'file-locked-p) | 335 | (or (fboundp 'file-locked-p) |
| 336 | (defalias 'file-locked-p 'ignore)) | 336 | (defalias 'file-locked-p 'ignore)) |
| 337 | 337 | ||
| 338 | (defvar view-read-only nil | ||
| 339 | "*Non-nil means buffers visiting files read-only, do it in view mode.") | ||
| 340 | |||
| 338 | ;; This hook function provides support for ange-ftp host name | 341 | ;; This hook function provides support for ange-ftp host name |
| 339 | ;; completion. It runs the usual ange-ftp hook, but only for | 342 | ;; completion. It runs the usual ange-ftp hook, but only for |
| 340 | ;; completion operations. Having this here avoids the need | 343 | ;; completion operations. Having this here avoids the need |
| @@ -600,7 +603,7 @@ Like \\[find-file] but marks buffer as read-only. | |||
| 600 | Use \\[toggle-read-only] to permit editing." | 603 | Use \\[toggle-read-only] to permit editing." |
| 601 | (interactive "fFind file read-only: ") | 604 | (interactive "fFind file read-only: ") |
| 602 | (find-file filename) | 605 | (find-file filename) |
| 603 | (setq buffer-read-only t) | 606 | (toggle-read-only 1) |
| 604 | (current-buffer)) | 607 | (current-buffer)) |
| 605 | 608 | ||
| 606 | (defun find-file-read-only-other-window (filename) | 609 | (defun find-file-read-only-other-window (filename) |
| @@ -609,7 +612,7 @@ Like \\[find-file-other-window] but marks buffer as read-only. | |||
| 609 | Use \\[toggle-read-only] to permit editing." | 612 | Use \\[toggle-read-only] to permit editing." |
| 610 | (interactive "fFind file read-only other window: ") | 613 | (interactive "fFind file read-only other window: ") |
| 611 | (find-file-other-window filename) | 614 | (find-file-other-window filename) |
| 612 | (setq buffer-read-only t) | 615 | (toggle-read-only 1) |
| 613 | (current-buffer)) | 616 | (current-buffer)) |
| 614 | 617 | ||
| 615 | (defun find-file-read-only-other-frame (filename) | 618 | (defun find-file-read-only-other-frame (filename) |
| @@ -618,7 +621,7 @@ Like \\[find-file-other-frame] but marks buffer as read-only. | |||
| 618 | Use \\[toggle-read-only] to permit editing." | 621 | Use \\[toggle-read-only] to permit editing." |
| 619 | (interactive "fFind file read-only other frame: ") | 622 | (interactive "fFind file read-only other frame: ") |
| 620 | (find-file-other-frame filename) | 623 | (find-file-other-frame filename) |
| 621 | (setq buffer-read-only t) | 624 | (toggle-read-only 1) |
| 622 | (current-buffer)) | 625 | (current-buffer)) |
| 623 | 626 | ||
| 624 | (defun find-alternate-file-other-window (filename) | 627 | (defun find-alternate-file-other-window (filename) |
| @@ -993,6 +996,9 @@ unless NOMODES is non-nil." | |||
| 993 | (if nomodes | 996 | (if nomodes |
| 994 | nil | 997 | nil |
| 995 | (normal-mode t) | 998 | (normal-mode t) |
| 999 | (if (and buffer-read-only view-read-only | ||
| 1000 | (not (eq (get major-mode 'mode-class) 'special))) | ||
| 1001 | (view-mode-enter)) | ||
| 996 | (run-hooks 'find-file-hooks))) | 1002 | (run-hooks 'find-file-hooks))) |
| 997 | 1003 | ||
| 998 | (defun normal-mode (&optional find-file) | 1004 | (defun normal-mode (&optional find-file) |
| @@ -2196,10 +2202,10 @@ Optional second argument EXITING means ask about certain non-file buffers | |||
| 2196 | (buffer-list) | 2202 | (buffer-list) |
| 2197 | '("buffer" "buffers" "save") | 2203 | '("buffer" "buffers" "save") |
| 2198 | (list (list ?\C-r (lambda (buf) | 2204 | (list (list ?\C-r (lambda (buf) |
| 2199 | (view-buffer buf) | 2205 | (view-buffer buf |
| 2200 | (setq view-exit-action | 2206 | (function |
| 2201 | '(lambda (ignore) | 2207 | (lambda (ignore) |
| 2202 | (exit-recursive-edit))) | 2208 | (exit-recursive-edit)))) |
| 2203 | (recursive-edit) | 2209 | (recursive-edit) |
| 2204 | ;; Return nil to ask about BUF again. | 2210 | ;; Return nil to ask about BUF again. |
| 2205 | nil) | 2211 | nil) |
| @@ -2230,13 +2236,21 @@ prints a message in the minibuffer. Instead, use `set-buffer-modified-p'." | |||
| 2230 | 2236 | ||
| 2231 | (defun toggle-read-only (&optional arg) | 2237 | (defun toggle-read-only (&optional arg) |
| 2232 | "Change whether this buffer is visiting its file read-only. | 2238 | "Change whether this buffer is visiting its file read-only. |
| 2233 | With arg, set read-only iff arg is positive." | 2239 | With arg, set read-only iff arg is positive. |
| 2240 | If visiting file read-only and `view-read-only' is non-nil, enter view mode." | ||
| 2234 | (interactive "P") | 2241 | (interactive "P") |
| 2235 | (setq buffer-read-only | 2242 | (cond |
| 2236 | (if (null arg) | 2243 | ((and arg (if (> (prefix-numeric-value arg) 0) buffer-read-only |
| 2237 | (not buffer-read-only) | 2244 | (not buffer-read-only))) ; If buffer-read-only is set correctly, |
| 2238 | (> (prefix-numeric-value arg) 0))) | 2245 | nil) ; do nothing. |
| 2239 | (force-mode-line-update)) | 2246 | ;; Toggle. |
| 2247 | ((and buffer-read-only view-mode) | ||
| 2248 | (View-exit-and-edit)) ; Must leave view mode. | ||
| 2249 | ((and (not buffer-read-only) view-read-only | ||
| 2250 | (not (eq (get major-mode 'mode-class) 'special))) | ||
| 2251 | (view-mode-enter)) | ||
| 2252 | (t (setq buffer-read-only (not buffer-read-only)) | ||
| 2253 | (force-mode-line-update)))) | ||
| 2240 | 2254 | ||
| 2241 | (defun insert-file (filename) | 2255 | (defun insert-file (filename) |
| 2242 | "Insert contents of file FILENAME into buffer after point. | 2256 | "Insert contents of file FILENAME into buffer after point. |