diff options
| author | Richard M. Stallman | 1997-06-14 21:41:42 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-06-14 21:41:42 +0000 |
| commit | e51f616feee6443d7537f108af578db514fac8d2 (patch) | |
| tree | 7e2d71fe9fde9737687dbaf778214eb05b7556f4 | |
| parent | ab7782fc244eee09496764cdcb8db575460cff50 (diff) | |
| download | emacs-e51f616feee6443d7537f108af578db514fac8d2.tar.gz emacs-e51f616feee6443d7537f108af578db514fac8d2.zip | |
Many doc fixes.
(view-mode-enable): New function, split from view-mode-enter.
(view-mode-enter): Use view-mode-enable.
(view-mode-disable): New function, split from view-mode-exit.
(view-mode-exit): Use view-mode-disable.
(view-mode): Use view-mode-enable and view-mode-disable;
don't do all of what view-mode-enter and view-mode-exit do.
(change-major-mode-hook): Use view-mode-disable, not view-mode-exit.
| -rw-r--r-- | lisp/view.el | 193 |
1 files changed, 103 insertions, 90 deletions
diff --git a/lisp/view.el b/lisp/view.el index 89cace0e0ad..8ac8377e476 100644 --- a/lisp/view.el +++ b/lisp/view.el | |||
| @@ -46,11 +46,11 @@ | |||
| 46 | 46 | ||
| 47 | ;;;###autoload | 47 | ;;;###autoload |
| 48 | (defvar view-highlight-face 'highlight | 48 | (defvar view-highlight-face 'highlight |
| 49 | "*The overlay face used for highlighting the match found by View mode search.") | 49 | "*The face used for highlighting the match found by View mode search.") |
| 50 | 50 | ||
| 51 | ;; `view-mode-auto-exit' is replaced by the following global variable which | 51 | ;; `view-mode-auto-exit' is replaced by the following global variable which |
| 52 | ;; only says if scrolling past buffer end should leave view mode or not, it | 52 | ;; only says if scrolling past buffer end should leave view mode or not, it |
| 53 | ;; doesn't say if leaving view mode should restore windows or not. The latter | 53 | ;; doesn't say if leaving view mode should restore windows or not. The latter |
| 54 | ;; is now controlled by the presence of a value in `view-return-to-alist'. | 54 | ;; is now controlled by the presence of a value in `view-return-to-alist'. |
| 55 | ;;;###autoload | 55 | ;;;###autoload |
| 56 | (defvar view-scroll-auto-exit nil | 56 | (defvar view-scroll-auto-exit nil |
| @@ -65,7 +65,7 @@ only rings the bell and gives a message on how to leave.") | |||
| 65 | ;;;###autoload | 65 | ;;;###autoload |
| 66 | (defvar view-remove-frame-by-deleting nil | 66 | (defvar view-remove-frame-by-deleting nil |
| 67 | "*Determine how to remove a not needed frame. | 67 | "*Determine how to remove a not needed frame. |
| 68 | If nil, make an icon of the frame. If non-nil, delete the frame.") | 68 | If nil, make an icon of the frame. If non-nil, delete the frame.") |
| 69 | 69 | ||
| 70 | ;;;###autoload | 70 | ;;;###autoload |
| 71 | (defvar view-exit-all-windows-at-exit nil | 71 | (defvar view-exit-all-windows-at-exit nil |
| @@ -104,7 +104,7 @@ If nil then the local value of this is initially set to half window size.") | |||
| 104 | "What to do with selected window and where to go when leaving View mode. | 104 | "What to do with selected window and where to go when leaving View mode. |
| 105 | Added to by view-mode-enter when entering View mode. | 105 | Added to by view-mode-enter when entering View mode. |
| 106 | See RETURN-TO-ALIST argument of function `view-mode-exit' for format of | 106 | See RETURN-TO-ALIST argument of function `view-mode-exit' for format of |
| 107 | view-return-to-alist.") | 107 | `view-return-to-alist'.") |
| 108 | (make-variable-buffer-local 'view-return-to-alist) | 108 | (make-variable-buffer-local 'view-return-to-alist) |
| 109 | 109 | ||
| 110 | (defvar view-exit-action nil | 110 | (defvar view-exit-action nil |
| @@ -189,7 +189,7 @@ This is local in each buffer, once it is used.") | |||
| 189 | 189 | ||
| 190 | ;; Always leave view mode before changing major mode. | 190 | ;; Always leave view mode before changing major mode. |
| 191 | ;; This is to guarantee that the buffer-read-only variable is restored. | 191 | ;; This is to guarantee that the buffer-read-only variable is restored. |
| 192 | (add-hook 'change-major-mode-hook 'view-mode-exit) | 192 | (add-hook 'change-major-mode-hook 'view-mode-disable) |
| 193 | 193 | ||
| 194 | ;;; Commands that enter or exit view mode. | 194 | ;;; Commands that enter or exit view mode. |
| 195 | 195 | ||
| @@ -253,7 +253,7 @@ For list of all View commands, type H or h while viewing. | |||
| 253 | This command runs the normal hook `view-mode-hook'. | 253 | This command runs the normal hook `view-mode-hook'. |
| 254 | 254 | ||
| 255 | Optional argument EXIT-ACTION is either nil or a function with buffer as | 255 | Optional argument EXIT-ACTION is either nil or a function with buffer as |
| 256 | argument. This function is called when finished viewing buffer. | 256 | argument. This function is called when finished viewing buffer. |
| 257 | Use this argument instead of explicitly setting `view-exit-action'." | 257 | Use this argument instead of explicitly setting `view-exit-action'." |
| 258 | 258 | ||
| 259 | (interactive "bView buffer: ") | 259 | (interactive "bView buffer: ") |
| @@ -276,7 +276,7 @@ For list of all View commands, type H or h while viewing. | |||
| 276 | This command runs the normal hook `view-mode-hook'. | 276 | This command runs the normal hook `view-mode-hook'. |
| 277 | 277 | ||
| 278 | Optional argument EXIT-ACTION is either nil or a function with buffer as | 278 | Optional argument EXIT-ACTION is either nil or a function with buffer as |
| 279 | argument. This function is called when finished viewing buffer. | 279 | argument. This function is called when finished viewing buffer. |
| 280 | Use this argument instead of explicitly setting `view-exit-action'." | 280 | Use this argument instead of explicitly setting `view-exit-action'." |
| 281 | (interactive "bIn other window view buffer:\nP") | 281 | (interactive "bIn other window view buffer:\nP") |
| 282 | (let* ((win ; This window will be selected by | 282 | (let* ((win ; This window will be selected by |
| @@ -308,7 +308,7 @@ For list of all View commands, type H or h while viewing. | |||
| 308 | This command runs the normal hook `view-mode-hook'. | 308 | This command runs the normal hook `view-mode-hook'. |
| 309 | 309 | ||
| 310 | Optional argument EXIT-ACTION is either nil or a function with buffer as | 310 | Optional argument EXIT-ACTION is either nil or a function with buffer as |
| 311 | argument. This function is called when finished viewing buffer. | 311 | argument. This function is called when finished viewing buffer. |
| 312 | Use this argument instead of explicitly setting `view-exit-action'." | 312 | Use this argument instead of explicitly setting `view-exit-action'." |
| 313 | (interactive "bView buffer in other frame: \nP") | 313 | (interactive "bView buffer in other frame: \nP") |
| 314 | (let ((return-to | 314 | (let ((return-to |
| @@ -320,13 +320,13 @@ Use this argument instead of explicitly setting `view-exit-action'." | |||
| 320 | ;;;###autoload | 320 | ;;;###autoload |
| 321 | (defun view-mode (&optional arg) | 321 | (defun view-mode (&optional arg) |
| 322 | ;; In the following documentation string we have to use some explicit key | 322 | ;; In the following documentation string we have to use some explicit key |
| 323 | ;; bindings instead of using the \\[] construction. The reason for this | 323 | ;; bindings instead of using the \\[] construction. The reason for this |
| 324 | ;; is that most commands have more than one key binding. | 324 | ;; is that most commands have more than one key binding. |
| 325 | "Toggle View mode, a minor mode for viewing text but not editing it. | 325 | "Toggle View mode, a minor mode for viewing text but not editing it. |
| 326 | With arg, turn View mode on iff arg is positive. | 326 | With arg, turn View mode on iff arg is positive. |
| 327 | 327 | ||
| 328 | Emacs commands that do not change the buffer contents are available as usual. | 328 | Emacs commands that do not change the buffer contents are available as usual. |
| 329 | Kill commands insert text in kill buffers but do not delete. Other commands | 329 | Kill commands insert text in kill buffers but do not delete. Other commands |
| 330 | \(among them most letters and punctuation) beep and tell that the buffer is | 330 | \(among them most letters and punctuation) beep and tell that the buffer is |
| 331 | read-only. | 331 | read-only. |
| 332 | \\<view-mode-map> | 332 | \\<view-mode-map> |
| @@ -359,31 +359,31 @@ y scroll backward prefix (default one) line(s). | |||
| 359 | x exchanges point and mark. | 359 | x exchanges point and mark. |
| 360 | \\[View-back-to-mark] return to mark and pops mark ring. | 360 | \\[View-back-to-mark] return to mark and pops mark ring. |
| 361 | Mark ring is pushed at start of every successful search and when | 361 | Mark ring is pushed at start of every successful search and when |
| 362 | jump to line occurs. The mark is set on jump to buffer start or end. | 362 | jump to line occurs. The mark is set on jump to buffer start or end. |
| 363 | \\[point-to-register] save current position in character register. | 363 | \\[point-to-register] save current position in character register. |
| 364 | ' go to position saved in character register. | 364 | ' go to position saved in character register. |
| 365 | s do forward incremental search. | 365 | s do forward incremental search. |
| 366 | r do reverse incremental search. | 366 | r do reverse incremental search. |
| 367 | \\[View-search-regexp-forward] searches forward for regular expression, starting after current page. | 367 | \\[View-search-regexp-forward] searches forward for regular expression, starting after current page. |
| 368 | ! and @ have a special meaning at the beginning of the regexp. | 368 | ! and @ have a special meaning at the beginning of the regexp. |
| 369 | ! means search for a line with no match for regexp. @ means start | 369 | ! means search for a line with no match for regexp. @ means start |
| 370 | search at beginning (end for backward search) of buffer. | 370 | search at beginning (end for backward search) of buffer. |
| 371 | \\ searches backward for regular expression, starting before current page. | 371 | \\ searches backward for regular expression, starting before current page. |
| 372 | \\[View-search-last-regexp-forward] searches forward for last regular expression. | 372 | \\[View-search-last-regexp-forward] searches forward for last regular expression. |
| 373 | p searches backward for last regular expression. | 373 | p searches backward for last regular expression. |
| 374 | \\[View-quit] quit View mode, trying to restore window and buffer to previous state. | 374 | \\[View-quit] quit View mode, trying to restore window and buffer to previous state. |
| 375 | \\[View-quit] is the normal way to leave view mode. | 375 | \\[View-quit] is the normal way to leave view mode. |
| 376 | \\[View-exit] exit View mode but stay in current buffer. Use this if you started | 376 | \\[View-exit] exit View mode but stay in current buffer. Use this if you started |
| 377 | viewing a buffer (file) and find out you want to edit it. | 377 | viewing a buffer (file) and find out you want to edit it. |
| 378 | \\[View-exit-and-edit] exit View mode and make the current buffer editable. | 378 | \\[View-exit-and-edit] exit View mode and make the current buffer editable. |
| 379 | \\[View-quit-all] quit View mode, trying to restore windows and buffer to previous state. | 379 | \\[View-quit-all] quit View mode, trying to restore windows and buffer to previous state. |
| 380 | \\[View-leave] quit View mode and maybe switch buffers, but don't kill this buffer. | 380 | \\[View-leave] quit View mode and maybe switch buffers, but don't kill this buffer. |
| 381 | \\[View-kill-and-leave] quit View mode, kill current buffer and go back to other buffer. | 381 | \\[View-kill-and-leave] quit View mode, kill current buffer and go back to other buffer. |
| 382 | 382 | ||
| 383 | The effect of \\[View-leave] , \\[View-quit] and \\[View-kill-and-leave] depends on how view-mode was entered. If it was | 383 | The effect of \\[View-leave] , \\[View-quit] and \\[View-kill-and-leave] depends on how view-mode was entered. If it was |
| 384 | entered by view-file, view-file-other-window or view-file-other-frame (\\[view-file], | 384 | entered by view-file, view-file-other-window or view-file-other-frame (\\[view-file], |
| 385 | \\[view-file-other-window], \\[view-file-other-frame] or the dired mode v command), then \\[View-quit] will try to kill the | 385 | \\[view-file-other-window], \\[view-file-other-frame] or the dired mode v command), then \\[View-quit] will try to kill the |
| 386 | current buffer. If view-mode was entered from another buffer as is done by | 386 | current buffer. If view-mode was entered from another buffer as is done by |
| 387 | View-buffer, View-buffer-other-window, View-buffer-other frame, View-file, | 387 | View-buffer, View-buffer-other-window, View-buffer-other frame, View-file, |
| 388 | View-file-other-window or View-file-other-frame then \\[view-leave] , \\[view-quit] and \\[view-kill-and-leave] will return | 388 | View-file-other-window or View-file-other-frame then \\[view-leave] , \\[view-quit] and \\[view-kill-and-leave] will return |
| 389 | to that buffer. | 389 | to that buffer. |
| @@ -394,49 +394,62 @@ Entry to view-mode runs the normal hook `view-mode-hook'." | |||
| 394 | ((and arg | 394 | ((and arg |
| 395 | (if (> (prefix-numeric-value arg) 0) view-mode (not view-mode))) | 395 | (if (> (prefix-numeric-value arg) 0) view-mode (not view-mode))) |
| 396 | ()) ; Do nothing if already OK. | 396 | ()) ; Do nothing if already OK. |
| 397 | (view-mode (view-mode-exit)) | 397 | (view-mode (view-mode-disable)) |
| 398 | (t (view-mode-enter)))) | 398 | (t (view-mode-enable)))) |
| 399 | |||
| 400 | (defun view-mode-enable () | ||
| 401 | "Turn on View mode." | ||
| 402 | (setq view-mode t | ||
| 403 | view-page-size (view-page-size-default view-page-size) | ||
| 404 | view-half-page-size (or view-half-page-size (/ (view-window-size) 2)) | ||
| 405 | view-old-buffer-read-only buffer-read-only | ||
| 406 | buffer-read-only t | ||
| 407 | view-old-Helper-return-blurb (and (boundp 'Helper-return-blurb) | ||
| 408 | Helper-return-blurb) | ||
| 409 | Helper-return-blurb | ||
| 410 | (format "continue viewing %s" | ||
| 411 | (if (buffer-file-name) | ||
| 412 | (file-name-nondirectory (buffer-file-name)) | ||
| 413 | (buffer-name)))) | ||
| 414 | (run-hooks 'view-mode-hook)) | ||
| 415 | |||
| 416 | (defun view-mode-disable () | ||
| 417 | "Turn off View mode." | ||
| 418 | (and view-overlay (delete-overlay view-overlay)) | ||
| 419 | (setq view-mode nil | ||
| 420 | Helper-return-blurb view-old-Helper-return-blurb | ||
| 421 | buffer-read-only view-old-buffer-read-only)) | ||
| 399 | 422 | ||
| 400 | ;;;###autoload | 423 | ;;;###autoload |
| 401 | (defun view-mode-enter (&optional return-to exit-action) "\ | 424 | (defun view-mode-enter (&optional return-to exit-action) "\ |
| 402 | Enter View mode and set up exit from view mode depending on optional arguments. | 425 | Enter View mode and set up exit from view mode depending on optional arguments. |
| 403 | If RETURN-TO is non-nil it is added as an element to the buffer local alist | 426 | If RETURN-TO is non-nil it is added as an element to the buffer local alist |
| 404 | view-return-to-alist. | 427 | view-return-to-alist. |
| 405 | Save EXIT-ACTION in buffer local variable view-exit-action. | 428 | Save EXIT-ACTION in buffer local variable `view-exit-action'. |
| 429 | It should be either nil or a function that takes a buffer as argument. | ||
| 430 | This function will called by `view-mode-exit'. | ||
| 431 | |||
| 406 | RETURN-TO is either nil, meaning do nothing when exiting view mode, or | 432 | RETURN-TO is either nil, meaning do nothing when exiting view mode, or |
| 407 | \(<window> <old-window> . <old-buf-info>). | 433 | \(WINDOW OLD-WINDOW . OLD-BUF-INFO). |
| 408 | <window> is a window used for viewing. | 434 | WINDOW is a window used for viewing. |
| 409 | <old-window> is nil or the window to select after viewing. | 435 | OLD-WINDOW is nil or the window to select after viewing. |
| 410 | <old-buf-info> tells what to do with <window> when exiting. It is one of: | 436 | OLD-BUF-INFO tells what to do with WINDOW when exiting. It is one of: |
| 411 | 1) nil Do nothing. | 437 | 1) nil Do nothing. |
| 412 | 2) t Delete <window> or, if it is the only window, its frame. | 438 | 2) t Delete WINDOW or, if it is the only window, its frame. |
| 413 | 3) (<old-buff> <start> <point>) Display buffer <old-buff> with displayed text | 439 | 3) (OLD-BUFF START POINT) Display buffer OLD-BUFF with displayed text |
| 414 | starting at <start> and point at <point> in <window>. | 440 | starting at START and point at POINT in WINDOW. |
| 415 | EXIT-ACTION is either nil or a function with buffer as argument. This function | ||
| 416 | is called by view-mode-exit. | ||
| 417 | 441 | ||
| 418 | See the function `view-mode' for details of view mode. | 442 | See the function `view-mode' for the commands of View mode. |
| 419 | 443 | ||
| 420 | This function runs the normal hook `view-mode-hook'." | 444 | This function runs the normal hook `view-mode-hook'." |
| 421 | (if return-to | 445 | (if return-to |
| 422 | (let ((entry (assq (car return-to) view-return-to-alist))) | 446 | (let ((entry (assq (car return-to) view-return-to-alist))) |
| 423 | (if entry (setcdr entry (cdr return-to)) | 447 | (if entry (setcdr entry (cdr return-to)) |
| 424 | (setq view-return-to-alist (cons return-to view-return-to-alist))))) | 448 | (setq view-return-to-alist (cons return-to view-return-to-alist))))) |
| 425 | (if view-mode () ; Do nothing if already in view mode. | 449 | (if view-mode ; Do nothing if already in view mode. |
| 426 | (setq view-mode t | 450 | nil |
| 427 | view-page-size (view-page-size-default view-page-size) | 451 | (setq view-exit-action exit-action) |
| 428 | view-half-page-size (or view-half-page-size (/ (view-window-size) 2)) | 452 | (view-mode-enable) |
| 429 | view-old-buffer-read-only buffer-read-only | ||
| 430 | buffer-read-only t | ||
| 431 | view-old-Helper-return-blurb (and (boundp 'Helper-return-blurb) | ||
| 432 | Helper-return-blurb) | ||
| 433 | Helper-return-blurb | ||
| 434 | (format "continue viewing %s" | ||
| 435 | (if (buffer-file-name) | ||
| 436 | (file-name-nondirectory (buffer-file-name)) | ||
| 437 | (buffer-name))) | ||
| 438 | view-exit-action exit-action) | ||
| 439 | (run-hooks 'view-mode-hook) | ||
| 440 | (force-mode-line-update) | 453 | (force-mode-line-update) |
| 441 | (message "%s" | 454 | (message "%s" |
| 442 | (substitute-command-keys "\ | 455 | (substitute-command-keys "\ |
| @@ -449,18 +462,18 @@ exit. | |||
| 449 | EXIT-ACTION is nil or a function that is called with current buffer as | 462 | EXIT-ACTION is nil or a function that is called with current buffer as |
| 450 | argument. | 463 | argument. |
| 451 | RETURN-TO-ALIST is an alist that for some of the windows displaying the current | 464 | RETURN-TO-ALIST is an alist that for some of the windows displaying the current |
| 452 | buffer, associate information on what to do with those windows. If ALL-WIN is | 465 | buffer, associate information on what to do with those windows. If ALL-WIN is |
| 453 | non-nil, then all windows on RETURN-TO-ALIST are restored to their old state. | 466 | non-nil, then all windows on RETURN-TO-ALIST are restored to their old state. |
| 454 | If ALL-WIN is nil, then only the selected window is affected (if it is on | 467 | If ALL-WIN is nil, then only the selected window is affected (if it is on |
| 455 | ALL-WIN). Each element has the format (<window> <old-window> . <old-buf-info>) | 468 | ALL-WIN). Each element has the format (WINDOW OLD-WINDOW . OLD-BUF-INFO) |
| 456 | where <window> is a window displaying the current buffer and <old-buf-info> is | 469 | where WINDOW is a window displaying the current buffer and OLD-BUF-INFO is |
| 457 | information on what to do with <window>. <old-buf-info> is one of: | 470 | information on what to do with WINDOW. OLD-BUF-INFO is one of: |
| 458 | 1) nil Do nothing. | 471 | 1) nil Do nothing. |
| 459 | 2) t Delete <window> or, if it is the only window, its frame. | 472 | 2) t Delete WINDOW or, if it is the only window, its frame. |
| 460 | 3) (<old-buf> <start> <point>) Display buffer <old-buf> with displayed text | 473 | 3) (OLD-BUF START POINT) Display buffer OLD-BUF with displayed text |
| 461 | starting at <start> and point at <point> in <window>. | 474 | starting at START and point at POINT in WINDOW. |
| 462 | If one of the <window> in RETURN-TO-ALIST is the selected window and the | 475 | If one of the WINDOW in RETURN-TO-ALIST is the selected window and the |
| 463 | corresponding <old-window> is a live window, then select <old-window>." | 476 | corresponding OLD-WINDOW is a live window, then select OLD-WINDOW." |
| 464 | (if view-mode ; Only do something if in view mode. | 477 | (if view-mode ; Only do something if in view mode. |
| 465 | (let* ((buffer (current-buffer)) | 478 | (let* ((buffer (current-buffer)) |
| 466 | window | 479 | window |
| @@ -471,12 +484,9 @@ corresponding <old-window> is a live window, then select <old-window>." | |||
| 471 | (or all-win view-exit-all-windows-at-exit)) | 484 | (or all-win view-exit-all-windows-at-exit)) |
| 472 | return-to-alist ; Try to restore all windows. | 485 | return-to-alist ; Try to restore all windows. |
| 473 | (and sel-old (list sel-old))))) ; Only selected window. | 486 | (and sel-old (list sel-old))))) ; Only selected window. |
| 474 | (and view-overlay (delete-overlay view-overlay)) | 487 | (view-mode-disable) |
| 475 | (setq view-mode nil | 488 | (setq view-exit-action nil |
| 476 | view-exit-action nil | 489 | view-return-to-alist nil) |
| 477 | view-return-to-alist nil | ||
| 478 | Helper-return-blurb view-old-Helper-return-blurb | ||
| 479 | buffer-read-only view-old-buffer-read-only) | ||
| 480 | (while alist ; Restore windows with info. | 490 | (while alist ; Restore windows with info. |
| 481 | (if (and (window-live-p (setq window (car (car alist)))) | 491 | (if (and (window-live-p (setq window (car (car alist)))) |
| 482 | (eq buffer (window-buffer window))) | 492 | (eq buffer (window-buffer window))) |
| @@ -521,14 +531,14 @@ corresponding <old-window> is a live window, then select <old-window>." | |||
| 521 | 531 | ||
| 522 | (defun View-quit () | 532 | (defun View-quit () |
| 523 | "Quit View mode, trying to restore window and buffer to previous state. | 533 | "Quit View mode, trying to restore window and buffer to previous state. |
| 524 | Maybe kill current buffer. Try to restore selected window to previous state | 534 | Maybe kill this buffer. Try to restore selected window to previous state |
| 525 | and go to previous buffer or window." | 535 | and go to previous buffer or window." |
| 526 | (interactive) | 536 | (interactive) |
| 527 | (view-mode-exit view-return-to-alist view-exit-action)) | 537 | (view-mode-exit view-return-to-alist view-exit-action)) |
| 528 | 538 | ||
| 529 | (defun View-quit-all () | 539 | (defun View-quit-all () |
| 530 | "Quit View mode, trying to restore all windows and buffer to previous state. | 540 | "Quit View mode, trying to restore windows and buffers to previous state. |
| 531 | Maybe kill current buffer. Try to restore all windows viewing buffer to | 541 | Maybe kill current buffer. Try to restore all windows viewing buffer to |
| 532 | previous state and go to previous buffer or window." | 542 | previous state and go to previous buffer or window." |
| 533 | (interactive) | 543 | (interactive) |
| 534 | (view-mode-exit view-return-to-alist view-exit-action t)) | 544 | (view-mode-exit view-return-to-alist view-exit-action t)) |
| @@ -583,7 +593,7 @@ previous state and go to previous buffer or window." | |||
| 583 | (defun View-goto-percent (&optional percent) | 593 | (defun View-goto-percent (&optional percent) |
| 584 | "Move to end (or prefix PERCENT) of buffer in View mode. | 594 | "Move to end (or prefix PERCENT) of buffer in View mode. |
| 585 | Display is centered at point. | 595 | Display is centered at point. |
| 586 | Sets mark at starting position and pushes mark ring." | 596 | Also set the mark at the position where point was." |
| 587 | (interactive "P") | 597 | (interactive "P") |
| 588 | (push-mark) | 598 | (push-mark) |
| 589 | (goto-char | 599 | (goto-char |
| @@ -608,7 +618,7 @@ Sets mark at starting position and pushes mark ring." | |||
| 608 | (defun View-goto-line (&optional line) | 618 | (defun View-goto-line (&optional line) |
| 609 | "Move to first (or prefix LINE) line in View mode. | 619 | "Move to first (or prefix LINE) line in View mode. |
| 610 | Display is centered at LINE. | 620 | Display is centered at LINE. |
| 611 | Sets mark at starting position and pushes mark ring." | 621 | Also set the mark at the position where point was." |
| 612 | (interactive "p") | 622 | (interactive "p") |
| 613 | (push-mark) | 623 | (push-mark) |
| 614 | (goto-line line) | 624 | (goto-line line) |
| @@ -624,9 +634,9 @@ Sets mark at starting position and pushes mark ring." | |||
| 624 | 634 | ||
| 625 | (defun view-scroll-lines (lines backward default maxdefault) | 635 | (defun view-scroll-lines (lines backward default maxdefault) |
| 626 | ;; This function does the job for all the scrolling commands. | 636 | ;; This function does the job for all the scrolling commands. |
| 627 | ;; Scroll forward LINES lines. If BACKWARD is true scroll backwards. | 637 | ;; Scroll forward LINES lines. If BACKWARD is true scroll backwards. |
| 628 | ;; If LINES is negative scroll in the other direction. If LINES is 0 or nil, | 638 | ;; If LINES is negative scroll in the other direction. If LINES is 0 or nil, |
| 629 | ;; scroll DEFAULT lines. If MAXDEFAULT is true then scroll no more than a | 639 | ;; scroll DEFAULT lines. If MAXDEFAULT is true then scroll no more than a |
| 630 | ;; window full. | 640 | ;; window full. |
| 631 | (if (or (null lines) (zerop (setq lines (prefix-numeric-value lines)))) | 641 | (if (or (null lines) (zerop (setq lines (prefix-numeric-value lines)))) |
| 632 | (setq lines default)) | 642 | (setq lines default)) |
| @@ -650,7 +660,7 @@ Sets mark at starting position and pushes mark ring." | |||
| 650 | (beginning-of-line)))) | 660 | (beginning-of-line)))) |
| 651 | 661 | ||
| 652 | (defun view-really-at-end () | 662 | (defun view-really-at-end () |
| 653 | ;; Return true if buffer end visible. Maybe revert buffer and test. | 663 | ;; Return true if buffer end visible. Maybe revert buffer and test. |
| 654 | (and (pos-visible-in-window-p (point-max)) | 664 | (and (pos-visible-in-window-p (point-max)) |
| 655 | (let ((buf (current-buffer)) | 665 | (let ((buf (current-buffer)) |
| 656 | (bufname (buffer-name)) | 666 | (bufname (buffer-name)) |
| @@ -680,7 +690,7 @@ Sets mark at starting position and pushes mark ring." | |||
| 680 | 690 | ||
| 681 | (defun View-scroll-page-forward (&optional lines) | 691 | (defun View-scroll-page-forward (&optional lines) |
| 682 | "Scroll \"page size\" or prefix LINES lines forward in View mode. | 692 | "Scroll \"page size\" or prefix LINES lines forward in View mode. |
| 683 | This will exit if end of text is visible and view-scroll-auto-exit is non-nil. | 693 | Exit if end of text is visible and `view-scroll-auto-exit' is non-nil. |
| 684 | \"page size\" is whole window full, or number of lines set by | 694 | \"page size\" is whole window full, or number of lines set by |
| 685 | \\[View-scroll-page-forward-set-page-size] or | 695 | \\[View-scroll-page-forward-set-page-size] or |
| 686 | \\[View-scroll-page-backward-set-page-size]. | 696 | \\[View-scroll-page-backward-set-page-size]. |
| @@ -690,18 +700,18 @@ If LINES is more than a window-full, only the last window-full is shown." | |||
| 690 | 700 | ||
| 691 | (defun View-scroll-page-backward (&optional lines) | 701 | (defun View-scroll-page-backward (&optional lines) |
| 692 | "Scroll \"page size\" or prefix LINES lines backward in View mode. | 702 | "Scroll \"page size\" or prefix LINES lines backward in View mode. |
| 693 | See further View-scroll-page-forward." | 703 | See also `View-scroll-page-forward'." |
| 694 | (interactive "P") | 704 | (interactive "P") |
| 695 | (view-scroll-lines lines t view-page-size nil)) | 705 | (view-scroll-lines lines t view-page-size nil)) |
| 696 | 706 | ||
| 697 | (defun View-scroll-page-forward-set-page-size (&optional lines) | 707 | (defun View-scroll-page-forward-set-page-size (&optional lines) |
| 698 | "Scroll forward prefix LINES lines in View mode, setting the \"page size\". | 708 | "Scroll forward LINES lines in View mode, setting the \"page size\". |
| 699 | This is the number of lines which \\[View-scroll-page-forward] and | 709 | This is the number of lines which \\[View-scroll-page-forward] and |
| 700 | \\[View-scroll-page-backward] scroll by default. If LINES is omitted or = 0, | 710 | \\[View-scroll-page-backward] scroll by default. If LINES is omitted or = 0, |
| 701 | sets \"page size\" to window height and scrolls forward that much, otherwise | 711 | sets \"page size\" to window height and scrolls forward that much, otherwise |
| 702 | scrolls forward LINES lines and sets \"page size\" to the minimum of window | 712 | scrolls forward LINES lines and sets \"page size\" to the minimum of window |
| 703 | height and the absolute value of LINES. | 713 | height and the absolute value of LINES. |
| 704 | See further View-scroll-page-forward." | 714 | See also `View-scroll-page-forward'." |
| 705 | (interactive "P") | 715 | (interactive "P") |
| 706 | (view-scroll-lines lines nil | 716 | (view-scroll-lines lines nil |
| 707 | (setq view-page-size (view-page-size-default lines)) | 717 | (setq view-page-size (view-page-size-default lines)) |
| @@ -709,7 +719,7 @@ See further View-scroll-page-forward." | |||
| 709 | 719 | ||
| 710 | (defun View-scroll-page-backward-set-page-size (&optional lines) | 720 | (defun View-scroll-page-backward-set-page-size (&optional lines) |
| 711 | "Scroll backward prefix LINES lines in View mode, setting the \"page size\". | 721 | "Scroll backward prefix LINES lines in View mode, setting the \"page size\". |
| 712 | See further View-scroll-page-forward-set-page-size." | 722 | See also `View-scroll-page-forward-set-page-size'." |
| 713 | (interactive "P") | 723 | (interactive "P") |
| 714 | (view-scroll-lines lines t | 724 | (view-scroll-lines lines t |
| 715 | (setq view-page-size (view-page-size-default lines)) | 725 | (setq view-page-size (view-page-size-default lines)) |
| @@ -717,19 +727,19 @@ See further View-scroll-page-forward-set-page-size." | |||
| 717 | 727 | ||
| 718 | (defun View-scroll-line-forward (&optional lines) | 728 | (defun View-scroll-line-forward (&optional lines) |
| 719 | "Scroll forward one line (or prefix LINES lines) in View mode. | 729 | "Scroll forward one line (or prefix LINES lines) in View mode. |
| 720 | See further View-scroll-page-forward, but note that scrolling is limited | 730 | See also `View-scroll-page-forward,' but note that scrolling is limited |
| 721 | to minimum of LINES and one window-full." | 731 | to minimum of LINES and one window-full." |
| 722 | (interactive "P") | 732 | (interactive "P") |
| 723 | (view-scroll-lines lines nil 1 t)) | 733 | (view-scroll-lines lines nil 1 t)) |
| 724 | 734 | ||
| 725 | (defun View-scroll-line-backward (&optional lines) | 735 | (defun View-scroll-line-backward (&optional lines) |
| 726 | "Scroll backward one line (or prefix LINES lines) in View mode. | 736 | "Scroll backward one line (or prefix LINES lines) in View mode. |
| 727 | See further View-scroll-line-forward." | 737 | See also `View-scroll-line-forward'." |
| 728 | (interactive "P") | 738 | (interactive "P") |
| 729 | (view-scroll-lines lines t 1 t)) | 739 | (view-scroll-lines lines t 1 t)) |
| 730 | 740 | ||
| 731 | (defun View-scroll-half-page-forward (&optional lines) | 741 | (defun View-scroll-half-page-forward (&optional lines) |
| 732 | "Scroll forward \"half page size\" (or prefix LINES) lines in View mode. | 742 | "Scroll forward a \"half page\" (or prefix LINES) lines in View mode. |
| 733 | If LINES is not omitted, the \"half page size\" is set to the minimum of | 743 | If LINES is not omitted, the \"half page size\" is set to the minimum of |
| 734 | window height and the absolute value of LINES. | 744 | window height and the absolute value of LINES. |
| 735 | LINES=0 resets \"half page size\" to half window height." | 745 | LINES=0 resets \"half page size\" to half window height." |
| @@ -737,17 +747,19 @@ LINES=0 resets \"half page size\" to half window height." | |||
| 737 | (view-scroll-lines lines nil (view-set-half-page-size-default lines) t)) | 747 | (view-scroll-lines lines nil (view-set-half-page-size-default lines) t)) |
| 738 | 748 | ||
| 739 | (defun View-scroll-half-page-backward (&optional lines) | 749 | (defun View-scroll-half-page-backward (&optional lines) |
| 740 | "Scroll backward \"half page size\" (or prefix LINES) lines in View mode. | 750 | "Scroll backward a \"half page\" (or prefix LINES) lines in View mode. |
| 741 | See further View-scroll-half-page-forward." | 751 | See also `View-scroll-half-page-forward'." |
| 742 | (interactive "P") | 752 | (interactive "P") |
| 743 | (view-scroll-lines lines t (view-set-half-page-size-default lines) t)) | 753 | (view-scroll-lines lines t (view-set-half-page-size-default lines) t)) |
| 744 | 754 | ||
| 745 | (defun View-revert-buffer-scroll-page-forward (&optional lines) "\ | 755 | (defun View-revert-buffer-scroll-page-forward (&optional lines) |
| 746 | Scroll \"page size\" or prefix LINES lines forward reverting buffer if needed. | 756 | "Scroll forward, reverting buffer if needed, in View mode. |
| 747 | If buffer has not been changed and the corresponding file is newer, first | 757 | If buffer has not been changed and the corresponding file is newer, first |
| 748 | revert the buffer, then scroll. | 758 | revert the buffer, then scroll. |
| 749 | This command is useful if you are viewing a changing file. | 759 | This command is useful if you are viewing a changing file. |
| 750 | \"page size\" is whole window full, or number of lines set by | 760 | |
| 761 | The prefix argument LINES says how many lines to scroll. | ||
| 762 | If you don't specify a prefix argument, it uses the number of lines set by | ||
| 751 | \\[View-scroll-page-forward-set-page-size] or | 763 | \\[View-scroll-page-forward-set-page-size] or |
| 752 | \\[View-scroll-page-backward-set-page-size]. | 764 | \\[View-scroll-page-backward-set-page-size]. |
| 753 | If LINES is more than a window-full, only the last window-full is shown." | 765 | If LINES is more than a window-full, only the last window-full is shown." |
| @@ -758,7 +770,8 @@ If LINES is more than a window-full, only the last window-full is shown." | |||
| 758 | 770 | ||
| 759 | (defun View-back-to-mark (&optional ignore) | 771 | (defun View-back-to-mark (&optional ignore) |
| 760 | "Return to last mark set in View mode, else beginning of file. | 772 | "Return to last mark set in View mode, else beginning of file. |
| 761 | Displays line at center of window. Pops mark ring so successive | 773 | Display that line at the center of the window. |
| 774 | This command pops the mark ring, so that successive | ||
| 762 | invocations return to earlier marks." | 775 | invocations return to earlier marks." |
| 763 | (interactive) | 776 | (interactive) |
| 764 | (goto-char (or (mark t) (point-min))) | 777 | (goto-char (or (mark t) (point-min))) |
| @@ -768,11 +781,11 @@ invocations return to earlier marks." | |||
| 768 | (defun View-search-regexp-forward (n regexp) | 781 | (defun View-search-regexp-forward (n regexp) |
| 769 | "Search forward for first (or prefix Nth) occurrence of REGEXP in View mode. | 782 | "Search forward for first (or prefix Nth) occurrence of REGEXP in View mode. |
| 770 | Displays line found at center of window. REGEXP is remembered for searching | 783 | Displays line found at center of window. REGEXP is remembered for searching |
| 771 | with \\[View-search-last-regexp-forward] and \\[View-search-last-regexp-backward]. Sets mark at starting position and pushes mark ring. | 784 | with \\[View-search-last-regexp-forward] and \\[View-search-last-regexp-backward]. Sets mark at starting position and pushes mark ring. |
| 772 | Characters @ or ! or combined as @! or !@ are special if entered at the | 785 | Characters @ or ! or combined as @! or !@ are special if entered at the |
| 773 | beginning of REGEXP. They modify the search rather than become part of pattern | 786 | beginning of REGEXP. They modify the search rather than become part of pattern |
| 774 | searched for. @ means start search at the beginning of buffer. ! means search | 787 | searched for. @ means start search at the beginning of buffer. ! means search |
| 775 | for line that not contains match for pattern. If REGEXP only consist of these | 788 | for line that not contains match for pattern. If REGEXP only consist of these |
| 776 | control characters, then an earlier remembered REGEXP is used. | 789 | control characters, then an earlier remembered REGEXP is used. |
| 777 | 790 | ||
| 778 | The variable `view-highlight-face' controls the face that is used | 791 | The variable `view-highlight-face' controls the face that is used |
| @@ -783,11 +796,11 @@ for highlighting the match that is found." | |||
| 783 | (defun View-search-regexp-backward (n regexp) | 796 | (defun View-search-regexp-backward (n regexp) |
| 784 | "Search backward for first (or prefix Nth) occurrence of REGEXP in View mode. | 797 | "Search backward for first (or prefix Nth) occurrence of REGEXP in View mode. |
| 785 | Displays line found at center of window. REGEXP is remembered for searching | 798 | Displays line found at center of window. REGEXP is remembered for searching |
| 786 | with \\[View-search-last-regexp-forward] and \\[View-search-last-regexp-backward]. Sets mark at starting position and pushes mark ring. | 799 | with \\[View-search-last-regexp-forward] and \\[View-search-last-regexp-backward]. Sets mark at starting position and pushes mark ring. |
| 787 | Characters @ or ! or combined as @! or !@ are special if entered at the | 800 | Characters @ or ! or combined as @! or !@ are special if entered at the |
| 788 | beginning of REGEXP. They modify the search rather than become part of pattern | 801 | beginning of REGEXP. They modify the search rather than become part of pattern |
| 789 | searched for. @ means start search at the end of buffer. ! means search | 802 | searched for. @ means start search at the end of buffer. ! means search |
| 790 | for line that not contains match for pattern. If REGEXP only consist of these | 803 | for line that not contains match for pattern. If REGEXP only consist of these |
| 791 | control characters, then an earlier remembered REGEXP is used. | 804 | control characters, then an earlier remembered REGEXP is used. |
| 792 | 805 | ||
| 793 | The variable `view-highlight-face' controls the face that is used | 806 | The variable `view-highlight-face' controls the face that is used |