diff options
| author | Jim Blandy | 1991-07-25 20:25:57 +0000 |
|---|---|---|
| committer | Jim Blandy | 1991-07-25 20:25:57 +0000 |
| commit | b82fef5c42a043ffb63e2b84222adf5bf573402d (patch) | |
| tree | 77bf8e6e41952557905383d8f86679f7c10a53ef | |
| parent | 6f236da80e6b249cade403a5c8f31fa0771ce83f (diff) | |
| download | emacs-b82fef5c42a043ffb63e2b84222adf5bf573402d.tar.gz emacs-b82fef5c42a043ffb63e2b84222adf5bf573402d.zip | |
*** empty log message ***
| -rw-r--r-- | lisp/view.el | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/lisp/view.el b/lisp/view.el index 29d55588351..f8e13959813 100644 --- a/lisp/view.el +++ b/lisp/view.el | |||
| @@ -25,7 +25,7 @@ | |||
| 25 | (if view-mode-map | 25 | (if view-mode-map |
| 26 | nil | 26 | nil |
| 27 | (setq view-mode-map (make-keymap)) | 27 | (setq view-mode-map (make-keymap)) |
| 28 | (fillarray (car (cdr view-mode-map)) 'View-undefined) | 28 | (fillarray (nth 1 view-mode-map) 'View-undefined) |
| 29 | (define-key view-mode-map "\C-c" 'view-exit) | 29 | (define-key view-mode-map "\C-c" 'view-exit) |
| 30 | (define-key view-mode-map "\C-z" 'suspend-emacs) | 30 | (define-key view-mode-map "\C-z" 'suspend-emacs) |
| 31 | (define-key view-mode-map "q" 'view-exit) | 31 | (define-key view-mode-map "q" 'view-exit) |
| @@ -110,6 +110,26 @@ Calls the value of view-hook if that is non-nil." | |||
| 110 | 'kill-buffer)))) | 110 | 'kill-buffer)))) |
| 111 | 111 | ||
| 112 | ;;;###autoload | 112 | ;;;###autoload |
| 113 | (defun view-file-other-window (file-name) | ||
| 114 | "View FILE in View mode in other window. | ||
| 115 | Return to previous buffer when done. | ||
| 116 | The usual Emacs commands are not available; instead, | ||
| 117 | a special set of commands (mostly letters and punctuation) | ||
| 118 | are defined for moving around in the buffer. | ||
| 119 | Space scrolls forward, Delete scrolls backward. | ||
| 120 | For list of all View commands, type ? or h while viewing. | ||
| 121 | |||
| 122 | Calls the value of view-hook if that is non-nil." | ||
| 123 | (interactive "fView file: ") | ||
| 124 | (let ((old-arrangement (current-window-configuration)) | ||
| 125 | (had-a-buf (get-file-buffer file-name)) | ||
| 126 | (buf-to-view (find-file-noselect file-name))) | ||
| 127 | (switch-to-buffer-other-window buf-to-view) | ||
| 128 | (view-mode old-arrangement | ||
| 129 | (and (not had-a-buf) (not (buffer-modified-p buf-to-view)) | ||
| 130 | 'kill-buffer)))) | ||
| 131 | |||
| 132 | ;;;###autoload | ||
| 113 | (defun view-buffer (buffer-name) | 133 | (defun view-buffer (buffer-name) |
| 114 | "View BUFFER in View mode, returning to previous buffer when done. | 134 | "View BUFFER in View mode, returning to previous buffer when done. |
| 115 | The usual Emacs commands are not available; instead, | 135 | The usual Emacs commands are not available; instead, |
| @@ -125,6 +145,23 @@ Calls the value of view-hook if that is non-nil." | |||
| 125 | (view-mode old-buf nil))) | 145 | (view-mode old-buf nil))) |
| 126 | 146 | ||
| 127 | ;;;###autoload | 147 | ;;;###autoload |
| 148 | (defun view-buffer-other-window (buffer-name not-return) | ||
| 149 | "View BUFFER in View mode in another window, | ||
| 150 | returning to original buffer when done ONLY if | ||
| 151 | prefix argument not-return is nil (as by default). | ||
| 152 | The usual Emacs commands are not available; instead, | ||
| 153 | a special set of commands (mostly letters and punctuation) | ||
| 154 | are defined for moving around in the buffer. | ||
| 155 | Space scrolls forward, Delete scrolls backward. | ||
| 156 | For list of all View commands, type ? or h while viewing. | ||
| 157 | |||
| 158 | Calls the value of view-hook if that is non-nil." | ||
| 159 | (interactive \"bView buffer:\\nP\") | ||
| 160 | (let ((return-to (and not-return (current-window-configuration)))) | ||
| 161 | (switch-to-buffer-other-window buffer-name) | ||
| 162 | (view-mode return-to))) | ||
| 163 | |||
| 164 | ;;;###autoload | ||
| 128 | (defun view-mode (&optional prev-buffer action) | 165 | (defun view-mode (&optional prev-buffer action) |
| 129 | "Major mode for viewing text but not editing it. | 166 | "Major mode for viewing text but not editing it. |
| 130 | Letters do not insert themselves. Instead these commands are provided. | 167 | Letters do not insert themselves. Instead these commands are provided. |
| @@ -197,8 +234,8 @@ Entry to this mode calls the value of view-hook if non-nil. | |||
| 197 | 234 | ||
| 198 | (make-local-variable 'view-exit-action) | 235 | (make-local-variable 'view-exit-action) |
| 199 | (setq view-exit-action action) | 236 | (setq view-exit-action action) |
| 200 | (make-local-variable 'view-prev-buffer) | 237 | (make-local-variable 'view-return-here) |
| 201 | (setq view-prev-buffer prev-buffer) | 238 | (setq view-return-here prev-buffer) |
| 202 | (make-local-variable 'view-exit-position) | 239 | (make-local-variable 'view-exit-position) |
| 203 | (setq view-exit-position (point-marker)) | 240 | (setq view-exit-position (point-marker)) |
| 204 | 241 | ||
| @@ -214,6 +251,7 @@ Entry to this mode calls the value of view-hook if non-nil. | |||
| 214 | (run-hooks 'view-hook) | 251 | (run-hooks 'view-hook) |
| 215 | (view-helpful-message)) | 252 | (view-helpful-message)) |
| 216 | 253 | ||
| 254 | |||
| 217 | (defun view-exit () | 255 | (defun view-exit () |
| 218 | "Exit from view-mode. | 256 | "Exit from view-mode. |
| 219 | If you viewed an existing buffer, that buffer returns to its previous mode. | 257 | If you viewed an existing buffer, that buffer returns to its previous mode. |
| @@ -233,7 +271,11 @@ If you viewed a file that was not present in Emacs, its buffer is killed." | |||
| 233 | ;; (such as kill it). | 271 | ;; (such as kill it). |
| 234 | (let ((viewed-buffer (current-buffer)) | 272 | (let ((viewed-buffer (current-buffer)) |
| 235 | (action view-exit-action)) | 273 | (action view-exit-action)) |
| 236 | (switch-to-buffer view-prev-buffer) | 274 | (cond |
| 275 | ((bufferp view-return-here) | ||
| 276 | (switch-to-buffer view-return-here)) | ||
| 277 | ((window-configuration-p view-return-here) | ||
| 278 | (set-window-configuration view-return-here))) | ||
| 237 | (if action (funcall action viewed-buffer)))) | 279 | (if action (funcall action viewed-buffer)))) |
| 238 | 280 | ||
| 239 | (defun view-helpful-message () | 281 | (defun view-helpful-message () |
| @@ -390,3 +432,9 @@ invocations return to earlier marks." | |||
| 390 | (message "Can't find occurrence %d of %s" times regexp) | 432 | (message "Can't find occurrence %d of %s" times regexp) |
| 391 | (sit-for 4)))) | 433 | (sit-for 4)))) |
| 392 | 434 | ||
| 435 | |||
| 436 | ;;;###autoload | ||
| 437 | (define-key ctl-x-map "v" 'view-file) | ||
| 438 | |||
| 439 | ;;;###autoload | ||
| 440 | (define-key ctl-x-4-map "v" 'view-file-other-window) | ||