Mercurial > emacs
comparison lisp/view.el @ 354:23984354573b
*** empty log message ***
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Thu, 25 Jul 1991 20:25:57 +0000 |
parents | 5d45fc2b81e9 |
children | 4cd7543be581 |
comparison
equal
deleted
inserted
replaced
353:38d331b3a0b8 | 354:23984354573b |
---|---|
23 | 23 |
24 (defvar view-mode-map nil) | 24 (defvar view-mode-map nil) |
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) |
32 (define-key view-mode-map "-" 'negative-argument) | 32 (define-key view-mode-map "-" 'negative-argument) |
33 (define-key view-mode-map "0" 'digit-argument) | 33 (define-key view-mode-map "0" 'digit-argument) |
108 (view-mode old-buf | 108 (view-mode old-buf |
109 (and (not had-a-buf) (not (buffer-modified-p buf-to-view)) | 109 (and (not had-a-buf) (not (buffer-modified-p buf-to-view)) |
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, |
116 a special set of commands (mostly letters and punctuation) | 136 a special set of commands (mostly letters and punctuation) |
117 are defined for moving around in the buffer. | 137 are defined for moving around in the buffer. |
121 Calls the value of view-hook if that is non-nil." | 141 Calls the value of view-hook if that is non-nil." |
122 (interactive "bView buffer: ") | 142 (interactive "bView buffer: ") |
123 (let ((old-buf (current-buffer))) | 143 (let ((old-buf (current-buffer))) |
124 (switch-to-buffer buffer-name t) | 144 (switch-to-buffer buffer-name t) |
125 (view-mode old-buf nil))) | 145 (view-mode old-buf nil))) |
146 | |
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))) | |
126 | 163 |
127 ;;;###autoload | 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. |
195 (file-name-nondirectory (buffer-file-name)) | 232 (file-name-nondirectory (buffer-file-name)) |
196 (buffer-name)))) | 233 (buffer-name)))) |
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 |
205 (make-local-variable 'view-scroll-size) | 242 (make-local-variable 'view-scroll-size) |
206 (setq view-scroll-size nil) | 243 (setq view-scroll-size nil) |
212 | 249 |
213 (use-local-map view-mode-map) | 250 (use-local-map view-mode-map) |
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. |
220 If you viewed a file that was not present in Emacs, its buffer is killed." | 258 If you viewed a file that was not present in Emacs, its buffer is killed." |
221 (interactive) | 259 (interactive) |
231 | 269 |
232 ;; Now do something to the buffer that we were viewing | 270 ;; Now do something to the buffer that we were viewing |
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 () |
240 (message | 282 (message |
241 (if (and (eq (key-binding "\C-h") 'Helper-help) | 283 (if (and (eq (key-binding "\C-h") 'Helper-help) |
388 (beginning-of-line) | 430 (beginning-of-line) |
389 (recenter (/ (view-window-size) 2))) | 431 (recenter (/ (view-window-size) 2))) |
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) |