Mercurial > emacs
annotate lisp/view.el @ 1717:aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
`has_vertical_scrollbars'.
(FRAME_CAN_HAVE_SCROLLBARS, FRAME_HAS_VERTICAL_SCROLLBARS): New
accessors, for both the MULTI_FRAME and non-MULTI_FRAME.
(VERTICAL_SCROLLBAR_WIDTH, WINDOW_VERTICAL_SCROLLBAR,
WINDOW_VERTICAL_SCROLLBAR_COLUMN,
WINDOW_VERTICAL_SCROLLBAR_HEIGHT): New macros.
* window.h (struct window): New field `vertical_scrollbar'.
* xterm.h (struct x_display): vertical_scrollbars,
judge_timestamp, vertical_scrollbar_extra: New fields.
(struct scrollbar): New struct.
(VERTICAL_SCROLLBAR_PIXEL_WIDTH, VERTICAL_SCROLLBAR_PIXEL_HEIGHT,
VERTICAL_SCROLLBAR_LEFT_BORDER, VERTICAL_SCROLLBAR_RIGHT_BORDER,
VERTICAL_SCROLLBAR_TOP_BORDER, VERTICAL_SCROLLBAR_BOTTOM_BORDER,
CHAR_TO_PIXEL_WIDTH, CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_WIDTH,
PIXEL_TO_CHAR_HEIGHT): New accessors and macros.
* frame.c (make_frame): Initialize the `can_have_scrollbars' and
`has_vertical_scrollbars' fields of the frame.
* term.c (term_init): Note that TERMCAP terminals don't support
scrollbars.
(mouse_position_hook): Document new args.
(set_vertical_scrollbar_hook, condemn_scrollbars_hook,
redeem_scrollbar_hook, judge_scrollbars_hook): New hooks.
* termhooks.h: Declare and document them.
(enum scrollbar_part): New type.
(struct input_event): Describe the new form of the scrollbar_click
event type. Change `part' from a Lisp_Object to an enum
scrollbar_part. Add a new field `scrollbar'.
* keyboard.c (kbd_buffer_get_event): Pass appropriate new
parameters to *mouse_position_hook, and make_lispy_movement.
* xfns.c (x_set_vertical_scrollbar): New function.
(x_figure_window_size): Use new macros to calculate frame size.
(Fx_create_frame): Note that X Windows frames do support scroll
bars. Default to "yes".
* xterm.c: #include <X11/cursorfont.h> and "window.h".
(x_vertical_scrollbar_cursor): New variable.
(x_term_init): Initialize it.
(last_mouse_bar, last_mouse_bar_frame, last_mouse_part,
last_mouse_scroll_range_start, last_mouse_scroll_range_end): New
variables.
(XTmouse_position): Use them to return scrollbar movement events.
Take new arguments, for that purpose.
(x_window_to_scrollbar, x_scrollbar_create,
x_scrollbar_set_handle, x_scrollbar_remove, x_scrollbar_move,
XTset_scrollbar, XTcondemn_scrollbars, XTredeem_scrollbar,
XTjudge_scrollbars, x_scrollbar_expose,
x_scrollbar_background_expose, x_scrollbar_handle_click,
x_scrollbar_handle_motion): New functions to implement scrollbars.
(x_term_init): Set the termhooks.h hooks to point to them.
(x_set_window_size): Use new macros to calculate frame size. Set
vertical_scrollbar_extra field.
(x_make_frame_visible): Use the frame accessor
FRAME_HAS_VERTICAL_SCROLLBARS to decide if we need to map the
frame's subwindows as well.
(XTread_socket): Use new size-calculation macros from xterm.h when
processing ConfigureNotify events.
(x_wm_set_size_hint): Use PIXEL_TO_CHAR_WIDTH and
PIXEL_TO_CHAR_HEIGHT macros.
* ymakefile (xdisp.o): This now depends on termhooks.h.
(xterm.o): This now depends on window.h.
| author | Jim Blandy <jimb@redhat.com> |
|---|---|
| date | Thu, 24 Dec 1992 06:17:18 +0000 |
| parents | f23882d7315a |
| children | d98c49df2acd |
| rev | line source |
|---|---|
|
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1 ;;; view.el --- peruse file or buffer without editing. |
|
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2 |
|
840
113281b361ec
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
3 ;; Copyright (C) 1985, 1989 Free Software Foundation, Inc. |
|
113281b361ec
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
4 |
|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
5 ;; Author: K. Shane Hartman |
|
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
6 ;; Maintainer: FSF |
| 44 | 7 |
| 8 ;; This file is part of GNU Emacs. | |
| 9 | |
| 10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
| 11 ;; it under the terms of the GNU General Public License as published by | |
|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
| 44 | 13 ;; any later version. |
| 14 | |
| 15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
| 16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 ;; GNU General Public License for more details. | |
| 19 | |
| 20 ;; You should have received a copy of the GNU General Public License | |
| 21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
| 22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 23 | |
|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
24 ;;; Code: |
| 44 | 25 |
| 26 (defvar view-mode-map nil) | |
| 27 (if view-mode-map | |
| 28 nil | |
| 29 (setq view-mode-map (make-keymap)) | |
| 354 | 30 (fillarray (nth 1 view-mode-map) 'View-undefined) |
| 44 | 31 (define-key view-mode-map "\C-c" 'view-exit) |
| 32 (define-key view-mode-map "\C-z" 'suspend-emacs) | |
| 33 (define-key view-mode-map "q" 'view-exit) | |
| 34 (define-key view-mode-map "-" 'negative-argument) | |
| 35 (define-key view-mode-map "0" 'digit-argument) | |
| 36 (define-key view-mode-map "1" 'digit-argument) | |
| 37 (define-key view-mode-map "2" 'digit-argument) | |
| 38 (define-key view-mode-map "3" 'digit-argument) | |
| 39 (define-key view-mode-map "4" 'digit-argument) | |
| 40 (define-key view-mode-map "5" 'digit-argument) | |
| 41 (define-key view-mode-map "6" 'digit-argument) | |
| 42 (define-key view-mode-map "7" 'digit-argument) | |
| 43 (define-key view-mode-map "8" 'digit-argument) | |
| 44 (define-key view-mode-map "9" 'digit-argument) | |
| 45 (define-key view-mode-map "\C-u" 'universal-argument) | |
| 46 (define-key view-mode-map "\e" nil) | |
| 47 (define-key view-mode-map "\C-x" 'Control-X-prefix) | |
| 48 (define-key view-mode-map "\e-" 'negative-argument) | |
| 49 (define-key view-mode-map "\e0" 'digit-argument) | |
| 50 (define-key view-mode-map "\e1" 'digit-argument) | |
| 51 (define-key view-mode-map "\e2" 'digit-argument) | |
| 52 (define-key view-mode-map "\e3" 'digit-argument) | |
| 53 (define-key view-mode-map "\e4" 'digit-argument) | |
| 54 (define-key view-mode-map "\e5" 'digit-argument) | |
| 55 (define-key view-mode-map "\e6" 'digit-argument) | |
| 56 (define-key view-mode-map "\e7" 'digit-argument) | |
| 57 (define-key view-mode-map "\e8" 'digit-argument) | |
| 58 (define-key view-mode-map "\e9" 'digit-argument) | |
| 59 (define-key view-mode-map "<" 'beginning-of-buffer) | |
| 60 (define-key view-mode-map ">" 'end-of-buffer) | |
| 61 (define-key view-mode-map "\ev" 'View-scroll-lines-backward) | |
| 62 (define-key view-mode-map "\C-v" 'View-scroll-lines-forward) | |
| 63 (define-key view-mode-map " " 'View-scroll-lines-forward) | |
| 64 (define-key view-mode-map "\177" 'View-scroll-lines-backward) | |
| 65 (define-key view-mode-map "\n" 'View-scroll-one-more-line) | |
| 66 (define-key view-mode-map "\r" 'View-scroll-one-more-line) | |
| 67 (define-key view-mode-map "\C-l" 'recenter) | |
| 68 (define-key view-mode-map "z" 'View-scroll-lines-forward-set-scroll-size) | |
| 69 (define-key view-mode-map "g" 'View-goto-line) | |
| 70 (define-key view-mode-map "=" 'what-line) | |
| 71 (define-key view-mode-map "." 'set-mark-command) | |
| 72 (define-key view-mode-map "\C-@" 'set-mark-command) | |
| 73 (define-key view-mode-map "'" 'View-back-to-mark) | |
| 74 (define-key view-mode-map "@" 'View-back-to-mark) | |
| 75 (define-key view-mode-map "x" 'exchange-point-and-mark) | |
| 76 (define-key view-mode-map "h" 'Helper-describe-bindings) | |
| 77 (define-key view-mode-map "?" 'Helper-describe-bindings) | |
|
930
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
909
diff
changeset
|
78 (define-key view-mode-map (char-to-string help-char) 'Helper-help) |
| 44 | 79 (define-key view-mode-map "\C-n" 'next-line) |
| 80 (define-key view-mode-map "\C-p" 'previous-line) | |
| 81 (define-key view-mode-map "\C-s" 'isearch-forward) | |
| 82 (define-key view-mode-map "\C-r" 'isearch-backward) | |
| 83 (define-key view-mode-map "s" 'isearch-forward) | |
| 84 (define-key view-mode-map "r" 'isearch-backward) | |
| 85 (define-key view-mode-map "/" 'View-search-regexp-forward) | |
| 86 (define-key view-mode-map "\\" 'View-search-regexp-backward) | |
| 87 ;; This conflicts with the standard binding of isearch-regexp-forward | |
| 88 (define-key view-mode-map "\e\C-s" 'View-search-regexp-forward) | |
| 89 (define-key view-mode-map "\e\C-r" 'View-search-regexp-backward) | |
| 90 (define-key view-mode-map "n" 'View-search-last-regexp-forward) | |
| 91 (define-key view-mode-map "p" 'View-search-last-regexp-backward) | |
| 92 ) | |
| 93 | |
| 94 | |
| 256 | 95 ;;;###autoload |
| 44 | 96 (defun view-file (file-name) |
| 97 "View FILE in View mode, returning to previous buffer when done. | |
| 98 The usual Emacs commands are not available; instead, | |
| 99 a special set of commands (mostly letters and punctuation) | |
| 100 are defined for moving around in the buffer. | |
| 101 Space scrolls forward, Delete scrolls backward. | |
| 102 For list of all View commands, type ? or h while viewing. | |
| 103 | |
| 104 Calls the value of view-hook if that is non-nil." | |
| 105 (interactive "fView file: ") | |
| 106 (let ((old-buf (current-buffer)) | |
| 107 (had-a-buf (get-file-buffer file-name)) | |
| 108 (buf-to-view (find-file-noselect file-name))) | |
| 109 (switch-to-buffer buf-to-view t) | |
| 110 (view-mode old-buf | |
| 111 (and (not had-a-buf) (not (buffer-modified-p buf-to-view)) | |
| 112 'kill-buffer)))) | |
| 113 | |
| 256 | 114 ;;;###autoload |
| 354 | 115 (defun view-file-other-window (file-name) |
| 116 "View FILE in View mode in other window. | |
| 117 Return to previous buffer when done. | |
| 118 The usual Emacs commands are not available; instead, | |
| 119 a special set of commands (mostly letters and punctuation) | |
| 120 are defined for moving around in the buffer. | |
| 121 Space scrolls forward, Delete scrolls backward. | |
| 122 For list of all View commands, type ? or h while viewing. | |
| 123 | |
| 124 Calls the value of view-hook if that is non-nil." | |
| 125 (interactive "fView file: ") | |
| 126 (let ((old-arrangement (current-window-configuration)) | |
| 127 (had-a-buf (get-file-buffer file-name)) | |
| 128 (buf-to-view (find-file-noselect file-name))) | |
| 129 (switch-to-buffer-other-window buf-to-view) | |
| 130 (view-mode old-arrangement | |
| 131 (and (not had-a-buf) (not (buffer-modified-p buf-to-view)) | |
| 132 'kill-buffer)))) | |
| 133 | |
| 134 ;;;###autoload | |
| 44 | 135 (defun view-buffer (buffer-name) |
| 136 "View BUFFER in View mode, returning to previous buffer when done. | |
| 137 The usual Emacs commands are not available; instead, | |
| 138 a special set of commands (mostly letters and punctuation) | |
| 139 are defined for moving around in the buffer. | |
| 140 Space scrolls forward, Delete scrolls backward. | |
| 141 For list of all View commands, type ? or h while viewing. | |
| 142 | |
| 143 Calls the value of view-hook if that is non-nil." | |
| 144 (interactive "bView buffer: ") | |
| 145 (let ((old-buf (current-buffer))) | |
| 146 (switch-to-buffer buffer-name t) | |
| 147 (view-mode old-buf nil))) | |
| 148 | |
| 256 | 149 ;;;###autoload |
| 354 | 150 (defun view-buffer-other-window (buffer-name not-return) |
| 151 "View BUFFER in View mode in another window, | |
| 152 returning to original buffer when done ONLY if | |
| 153 prefix argument not-return is nil (as by default). | |
| 154 The usual Emacs commands are not available; instead, | |
| 155 a special set of commands (mostly letters and punctuation) | |
| 156 are defined for moving around in the buffer. | |
| 157 Space scrolls forward, Delete scrolls backward. | |
| 158 For list of all View commands, type ? or h while viewing. | |
| 159 | |
| 160 Calls the value of view-hook if that is non-nil." | |
| 161 (interactive \"bView buffer:\\nP\") | |
| 162 (let ((return-to (and not-return (current-window-configuration)))) | |
| 163 (switch-to-buffer-other-window buffer-name) | |
| 164 (view-mode return-to))) | |
| 165 | |
| 166 ;;;###autoload | |
| 44 | 167 (defun view-mode (&optional prev-buffer action) |
| 168 "Major mode for viewing text but not editing it. | |
| 169 Letters do not insert themselves. Instead these commands are provided. | |
| 170 Most commands take prefix arguments. Commands dealing with lines | |
| 171 default to \"scroll size\" lines (initially size of window). | |
| 172 Search commands default to a repeat count of one. | |
| 173 M-< or < move to beginning of buffer. | |
| 174 M-> or > move to end of buffer. | |
| 175 C-v or Space scroll forward lines. | |
| 176 M-v or DEL scroll backward lines. | |
| 177 CR or LF scroll forward one line (backward with prefix argument). | |
| 178 z like Space except set number of lines for further | |
| 179 scrolling commands to scroll by. | |
| 180 C-u and Digits provide prefix arguments. `-' denotes negative argument. | |
| 181 = prints the current line number. | |
| 182 g goes to line given by prefix argument. | |
| 183 / or M-C-s searches forward for regular expression | |
| 184 \\ or M-C-r searches backward for regular expression. | |
| 185 n searches forward for last regular expression. | |
| 186 p searches backward for last regular expression. | |
| 187 C-@ or . set the mark. | |
| 188 x exchanges point and mark. | |
| 189 C-s or s do forward incremental search. | |
| 190 C-r or r do reverse incremental search. | |
| 191 @ or ' return to mark and pops mark ring. | |
| 192 Mark ring is pushed at start of every | |
| 193 successful search and when jump to line to occurs. | |
| 194 The mark is set on jump to buffer start or end. | |
| 195 ? or h provide help message (list of commands). | |
|
930
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
909
diff
changeset
|
196 \\[Helper-help] provides help (list of commands or description of a command). |
| 44 | 197 C-n moves down lines vertically. |
| 198 C-p moves upward lines vertically. | |
| 199 C-l recenters the screen. | |
| 200 q or C-c exit view-mode and return to previous buffer. | |
| 201 | |
| 202 Entry to this mode calls the value of view-hook if non-nil. | |
| 203 \\{view-mode-map}" | |
| 204 ; Not interactive because dangerous things happen | |
| 205 ; if you call it without passing a buffer as argument | |
| 206 ; and they are not easy to fix. | |
| 207 ; (interactive) | |
| 208 (make-local-variable 'view-old-mode-line-buffer-identification) | |
| 209 (setq view-old-mode-line-buffer-identification | |
| 210 mode-line-buffer-identification) | |
| 211 (make-local-variable 'view-old-buffer-read-only) | |
| 212 (setq view-old-buffer-read-only buffer-read-only) | |
| 213 (make-local-variable 'view-old-mode-name) | |
| 214 (setq view-old-mode-name mode-name) | |
| 215 (make-local-variable 'view-old-major-mode) | |
| 216 (setq view-old-major-mode major-mode) | |
| 217 (make-local-variable 'view-old-local-map) | |
| 218 (setq view-old-local-map (current-local-map)) | |
| 219 (make-local-variable 'view-old-Helper-return-blurb) | |
| 220 (setq view-old-Helper-return-blurb | |
| 221 (and (boundp 'Helper-return-blurb) Helper-return-blurb)) | |
| 222 | |
| 223 (setq buffer-read-only t) | |
| 224 (setq mode-line-buffer-identification | |
| 225 (list | |
| 226 (if (buffer-file-name) | |
| 227 "Viewing %f" | |
| 228 "Viewing %b"))) | |
| 229 (setq mode-name "View") | |
| 230 (setq major-mode 'view-mode) | |
| 231 (setq Helper-return-blurb | |
| 232 (format "continue viewing %s" | |
| 233 (if (buffer-file-name) | |
| 234 (file-name-nondirectory (buffer-file-name)) | |
| 235 (buffer-name)))) | |
| 236 | |
| 237 (make-local-variable 'view-exit-action) | |
| 238 (setq view-exit-action action) | |
| 354 | 239 (make-local-variable 'view-return-here) |
| 240 (setq view-return-here prev-buffer) | |
| 44 | 241 (make-local-variable 'view-exit-position) |
| 242 (setq view-exit-position (point-marker)) | |
| 243 | |
| 244 (make-local-variable 'view-scroll-size) | |
| 245 (setq view-scroll-size nil) | |
| 246 (make-local-variable 'view-last-regexp) | |
| 247 (setq view-last-regexp nil) | |
| 248 | |
| 249 (beginning-of-line) | |
| 250 (setq goal-column nil) | |
| 251 | |
| 252 (use-local-map view-mode-map) | |
| 253 (run-hooks 'view-hook) | |
| 254 (view-helpful-message)) | |
| 255 | |
| 354 | 256 |
| 44 | 257 (defun view-exit () |
| 258 "Exit from view-mode. | |
| 259 If you viewed an existing buffer, that buffer returns to its previous mode. | |
| 260 If you viewed a file that was not present in Emacs, its buffer is killed." | |
| 261 (interactive) | |
| 262 (setq mode-line-buffer-identification | |
| 263 view-old-mode-line-buffer-identification) | |
| 264 (setq major-mode view-old-major-mode) | |
| 265 (setq mode-name view-old-mode-name) | |
| 266 (use-local-map (current-local-map)) | |
| 267 (setq buffer-read-only view-old-buffer-read-only) | |
| 268 | |
| 269 (goto-char view-exit-position) | |
| 270 (set-marker view-exit-position nil) | |
| 271 | |
| 272 ;; Now do something to the buffer that we were viewing | |
| 273 ;; (such as kill it). | |
| 274 (let ((viewed-buffer (current-buffer)) | |
| 275 (action view-exit-action)) | |
| 354 | 276 (cond |
| 277 ((bufferp view-return-here) | |
| 278 (switch-to-buffer view-return-here)) | |
| 279 ((window-configuration-p view-return-here) | |
| 280 (set-window-configuration view-return-here))) | |
| 44 | 281 (if action (funcall action viewed-buffer)))) |
| 282 | |
| 283 (defun view-helpful-message () | |
| 284 (message | |
| 285 (substitute-command-keys | |
| 931 | 286 "Type \\[Helper-help] for help, \\[Helper-describe-bindings] for commands, \\[view-exit] to quit."))) |
| 44 | 287 |
| 288 (defun View-undefined () | |
| 289 (interactive) | |
| 290 (ding) | |
| 291 (view-helpful-message)) | |
| 292 | |
| 293 (defun view-window-size () (1- (window-height))) | |
| 294 | |
| 295 (defun view-scroll-size () | |
| 296 (min (view-window-size) (or view-scroll-size (view-window-size)))) | |
| 297 | |
| 298 (defvar view-hook nil | |
| 299 "If non-nil, its value is called when viewing buffer or file.") | |
| 300 | |
| 301 ;(defun view-last-command (&optional who what) | |
| 302 ; (setq view-last-command-entry this-command) | |
| 303 ; (setq view-last-command who) | |
| 304 ; (setq view-last-command-argument what)) | |
| 305 | |
| 306 ;(defun View-repeat-last-command () | |
| 307 ; "Repeat last command issued in View mode." | |
| 308 ; (interactive) | |
| 309 ; (if (and view-last-command | |
| 310 ; (eq view-last-command-entry last-command)) | |
| 311 ; (funcall view-last-command view-last-command-argument)) | |
| 312 ; (setq this-command view-last-command-entry)) | |
| 313 | |
| 314 (defun View-goto-line (&optional line) | |
| 315 "Move to LINE in View mode. | |
| 316 Display is centered at LINE. Sets mark at starting position and pushes | |
| 317 mark ring." | |
| 318 (interactive "p") | |
| 319 (push-mark) | |
| 320 (goto-line (or line 1)) | |
| 321 (recenter (/ (view-window-size) 2))) | |
| 322 | |
| 323 (defun View-scroll-lines-forward (&optional lines) | |
| 324 "Scroll forward in View mode, or exit if end of text is visible. | |
| 325 No arg means whole window full, or number of lines set by \\[View-scroll-lines-forward-set-scroll-size]. | |
| 326 Arg is number of lines to scroll." | |
| 327 (interactive "P") | |
| 328 (if (pos-visible-in-window-p (point-max)) | |
|
909
4c6cdb66c74c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
840
diff
changeset
|
329 (view-exit)) |
| 44 | 330 (setq lines |
| 331 (if lines (prefix-numeric-value lines) | |
| 332 (view-scroll-size))) | |
| 333 ; (view-last-command 'View-scroll-lines-forward lines) | |
| 334 (if (>= lines (view-window-size)) | |
| 335 (scroll-up nil) | |
| 336 (if (>= (- lines) (view-window-size)) | |
| 337 (scroll-down nil) | |
| 338 (scroll-up lines))) | |
| 339 (cond ((pos-visible-in-window-p (point-max)) | |
| 340 (goto-char (point-max)) | |
| 341 (recenter -1) | |
| 342 (message (substitute-command-keys | |
|
909
4c6cdb66c74c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
840
diff
changeset
|
343 "End. Type \\[view-exit] to quit viewing.")))) |
| 44 | 344 (move-to-window-line -1) |
| 345 (beginning-of-line)) | |
| 346 | |
| 347 (defun View-scroll-lines-forward-set-scroll-size (&optional lines) | |
| 348 "Scroll forward LINES lines in View mode, setting the \"scroll size\". | |
| 349 This is the number of lines which \\[View-scroll-lines-forward] and \\[View-scroll-lines-backward] scroll by default. | |
| 350 The absolute value of LINES is used, so this command can be used to scroll | |
| 351 backwards (but \"scroll size\" is always positive). If LINES is greater than | |
| 352 window height or omitted, then window height is assumed. If LINES is less | |
| 353 than window height then scrolling context is provided from previous screen." | |
| 354 (interactive "P") | |
| 355 (if (not lines) | |
| 356 (setq view-scroll-size (view-window-size)) | |
| 357 (setq lines (prefix-numeric-value lines)) | |
| 358 (setq view-scroll-size | |
| 359 (min (if (> lines 0) lines (- lines)) (view-window-size)))) | |
| 360 (View-scroll-lines-forward lines)) | |
| 361 | |
| 362 (defun View-scroll-one-more-line (&optional arg) | |
| 363 "Scroll one more line up in View mode. | |
| 364 With ARG scroll one line down." | |
| 365 (interactive "P") | |
| 366 (View-scroll-lines-forward (if (not arg) 1 -1))) | |
| 367 | |
| 368 (defun View-scroll-lines-backward (&optional lines) | |
| 369 "Scroll backward in View mode. | |
| 370 No arg means whole window full, or number of lines set by \\[View-scroll-lines-forward-set-scroll-size]. | |
| 371 Arg is number of lines to scroll." | |
| 372 (interactive "P") | |
| 373 (View-scroll-lines-forward (if lines | |
| 374 (- (prefix-numeric-value lines)) | |
| 375 (- (view-scroll-size))))) | |
| 376 | |
| 377 (defun View-search-regexp-forward (times regexp) | |
| 378 "Search forward for NTH occurrence of REGEXP in View mode. | |
| 379 Displays line found at center of window. REGEXP is remembered for | |
| 380 searching with \\[View-search-last-regexp-forward] and \\[View-search-last-regexp-backward]. Sets mark at starting position and pushes mark ring." | |
| 381 (interactive "p\nsSearch forward (regexp): ") | |
| 382 (if (> (length regexp) 0) | |
| 383 (progn | |
| 384 ;(view-last-command 'View-search-last-regexp-forward times) | |
| 385 (view-search times regexp)))) | |
| 386 | |
| 387 (defun View-search-regexp-backward (times regexp) | |
| 388 "Search backward from window start for NTH instance of REGEXP in View mode. | |
| 389 Displays line found at center of window. REGEXP is remembered for | |
| 390 searching with \\[View-search-last-regexp-forward] and \\[View-search-last-regexp-backward]. Sets mark at starting position and pushes mark ring." | |
| 391 (interactive "p\nsSearch backward (regexp): ") | |
| 392 (View-search-regexp-forward (- times) regexp)) | |
| 393 | |
| 394 (defun View-search-last-regexp-forward (times) | |
| 395 "Search forward from window end for NTH instance of last regexp in View mode. | |
| 396 Displays line found at center of window. Sets mark at starting position | |
| 397 and pushes mark ring." | |
| 398 (interactive "p") | |
| 399 (View-search-regexp-forward times view-last-regexp)) | |
| 400 | |
| 401 (defun View-search-last-regexp-backward (times) | |
| 402 "Search backward from window start for NTH instance of last regexp in View mode. | |
| 403 Displays line found at center of window. Sets mark at starting position and | |
| 404 pushes mark ring." | |
| 405 (interactive "p") | |
| 406 (View-search-regexp-backward times view-last-regexp)) | |
| 407 | |
| 408 (defun View-back-to-mark (&optional ignore) | |
| 409 "Return to last mark set in View mode, else beginning of file. | |
| 410 Displays line at center of window. Pops mark ring so successive | |
| 411 invocations return to earlier marks." | |
| 412 (interactive) | |
| 413 (goto-char (or (mark) (point-min))) | |
| 414 (pop-mark) | |
| 415 (recenter (/ (view-window-size) 2))) | |
| 416 | |
| 417 (defun view-search (times regexp) | |
| 418 (setq view-last-regexp regexp) | |
| 419 (let (where) | |
| 420 (save-excursion | |
| 421 (move-to-window-line (if (< times 0) 0 -1)) | |
| 422 (if (re-search-forward regexp nil t times) | |
| 423 (setq where (point)))) | |
| 424 (if where | |
| 425 (progn | |
| 426 (push-mark) | |
| 427 (goto-char where) | |
| 428 (beginning-of-line) | |
| 429 (recenter (/ (view-window-size) 2))) | |
| 430 (message "Can't find occurrence %d of %s" times regexp) | |
| 431 (sit-for 4)))) | |
| 432 | |
| 354 | 433 |
| 584 | 434 (provide 'view) |
| 435 | |
|
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
436 ;;; view.el ends here |
