diff options
| author | Richard M. Stallman | 2003-05-03 13:52:17 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2003-05-03 13:52:17 +0000 |
| commit | 0d63ba8cd934e29d3df01dcfd863b9018556486f (patch) | |
| tree | 2c5effc596510310cf49e5ccbffcdfb2e4747870 | |
| parent | 1f9d00ca8a3bb4f5fb5bab79da30f91c844c39e2 (diff) | |
| download | emacs-0d63ba8cd934e29d3df01dcfd863b9018556486f.tar.gz emacs-0d63ba8cd934e29d3df01dcfd863b9018556486f.zip | |
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
| -rw-r--r-- | lisp/view.el | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/lisp/view.el b/lisp/view.el index ce5c1df702b..cf9db529339 100644 --- a/lisp/view.el +++ b/lisp/view.el | |||
| @@ -43,7 +43,7 @@ | |||
| 43 | ;; | 43 | ;; |
| 44 | ;; You could also bind view-file, view-buffer, view-buffer-other-window and | 44 | ;; You could also bind view-file, view-buffer, view-buffer-other-window and |
| 45 | ;; view-buffer-other-frame to keys. | 45 | ;; view-buffer-other-frame to keys. |
| 46 | 46 | ||
| 47 | ;;; Code: | 47 | ;;; Code: |
| 48 | 48 | ||
| 49 | (defgroup view nil | 49 | (defgroup view nil |
| @@ -105,13 +105,16 @@ functions that enable or disable view mode.") | |||
| 105 | "Normal hook run when starting to view a buffer or file." | 105 | "Normal hook run when starting to view a buffer or file." |
| 106 | :type 'hook | 106 | :type 'hook |
| 107 | :group 'view) | 107 | :group 'view) |
| 108 | 108 | ||
| 109 | (defvar view-old-buffer-read-only nil) | 109 | (defvar view-old-buffer-read-only nil) |
| 110 | (make-variable-buffer-local 'view-old-buffer-read-only) | 110 | (make-variable-buffer-local 'view-old-buffer-read-only) |
| 111 | 111 | ||
| 112 | (defvar view-old-Helper-return-blurb) | 112 | (defvar view-old-Helper-return-blurb) |
| 113 | (make-variable-buffer-local 'view-old-Helper-return-blurb) | 113 | (make-variable-buffer-local 'view-old-Helper-return-blurb) |
| 114 | 114 | ||
| 115 | ;; Just to avoid warnings. | ||
| 116 | (defvar Helper-return-blurb) | ||
| 117 | |||
| 115 | (defvar view-page-size nil | 118 | (defvar view-page-size nil |
| 116 | "Default number of lines to scroll by View page commands. | 119 | "Default number of lines to scroll by View page commands. |
| 117 | If nil then the local value of this is initially set to window size.") | 120 | If nil then the local value of this is initially set to window size.") |
| @@ -160,7 +163,7 @@ This is local in each buffer, once it is used.") | |||
| 160 | 'local-map mode-line-minor-mode-keymap | 163 | 'local-map mode-line-minor-mode-keymap |
| 161 | 'help-echo "mouse-3: minor mode menu")) | 164 | 'help-echo "mouse-3: minor mode menu")) |
| 162 | minor-mode-alist))) | 165 | minor-mode-alist))) |
| 163 | 166 | ||
| 164 | ;; Define keymap inside defvar to make it easier to load changes. | 167 | ;; Define keymap inside defvar to make it easier to load changes. |
| 165 | ;; Some redundant "less"-like key bindings below have been commented out. | 168 | ;; Some redundant "less"-like key bindings below have been commented out. |
| 166 | (defvar view-mode-map | 169 | (defvar view-mode-map |
| @@ -225,7 +228,7 @@ This is local in each buffer, once it is used.") | |||
| 225 | (or (assq 'view-mode minor-mode-map-alist) | 228 | (or (assq 'view-mode minor-mode-map-alist) |
| 226 | (setq minor-mode-map-alist | 229 | (setq minor-mode-map-alist |
| 227 | (cons (cons 'view-mode view-mode-map) minor-mode-map-alist))) | 230 | (cons (cons 'view-mode view-mode-map) minor-mode-map-alist))) |
| 228 | 231 | ||
| 229 | ;;; Commands that enter or exit view mode. | 232 | ;;; Commands that enter or exit view mode. |
| 230 | 233 | ||
| 231 | ;;;###autoload | 234 | ;;;###autoload |
| @@ -349,7 +352,7 @@ Use this argument instead of explicitly setting `view-exit-action'." | |||
| 349 | (switch-to-buffer-other-frame buffer) | 352 | (switch-to-buffer-other-frame buffer) |
| 350 | (view-mode-enter (and return-to (cons (selected-window) return-to)) | 353 | (view-mode-enter (and return-to (cons (selected-window) return-to)) |
| 351 | exit-action))) | 354 | exit-action))) |
| 352 | 355 | ||
| 353 | ;;;###autoload | 356 | ;;;###autoload |
| 354 | (defun view-mode (&optional arg) | 357 | (defun view-mode (&optional arg) |
| 355 | ;; In the following documentation string we have to use some explicit key | 358 | ;; In the following documentation string we have to use some explicit key |
| @@ -433,7 +436,7 @@ Entry to view-mode runs the normal hook `view-mode-hook'." | |||
| 433 | (if (> (prefix-numeric-value arg) 0) view-mode (not view-mode))) | 436 | (if (> (prefix-numeric-value arg) 0) view-mode (not view-mode))) |
| 434 | (if view-mode (view-mode-disable) | 437 | (if view-mode (view-mode-disable) |
| 435 | (view-mode-enable)))) | 438 | (view-mode-enable)))) |
| 436 | 439 | ||
| 437 | (defun view-mode-enable () | 440 | (defun view-mode-enable () |
| 438 | "Turn on View mode." | 441 | "Turn on View mode." |
| 439 | ;; Always leave view mode before changing major mode. | 442 | ;; Always leave view mode before changing major mode. |
| @@ -506,7 +509,7 @@ This function runs the normal hook `view-mode-hook'." | |||
| 506 | (message "%s" | 509 | (message "%s" |
| 507 | (substitute-command-keys "\ | 510 | (substitute-command-keys "\ |
| 508 | View mode: type \\[help-command] for help, \\[describe-mode] for commands, \\[View-quit] to quit.")))) | 511 | View mode: type \\[help-command] for help, \\[describe-mode] for commands, \\[View-quit] to quit.")))) |
| 509 | 512 | ||
| 510 | (defun view-mode-exit (&optional return-to-alist exit-action all-win) | 513 | (defun view-mode-exit (&optional return-to-alist exit-action all-win) |
| 511 | "Exit View mode in various ways, depending on optional arguments. | 514 | "Exit View mode in various ways, depending on optional arguments. |
| 512 | RETURN-TO-ALIST, EXIT-ACTION and ALL-WIN determine what to do after exit. | 515 | RETURN-TO-ALIST, EXIT-ACTION and ALL-WIN determine what to do after exit. |
| @@ -591,7 +594,7 @@ corresponding OLD-WINDOW is a live window, then select OLD-WINDOW." | |||
| 591 | (setq view-exit-action nil) | 594 | (setq view-exit-action nil) |
| 592 | (funcall exit-action buffer)) | 595 | (funcall exit-action buffer)) |
| 593 | (force-mode-line-update)))) | 596 | (force-mode-line-update)))) |
| 594 | 597 | ||
| 595 | (defun View-exit () | 598 | (defun View-exit () |
| 596 | "Exit View mode but stay in current buffer." | 599 | "Exit View mode but stay in current buffer." |
| 597 | (interactive) | 600 | (interactive) |
| @@ -628,7 +631,7 @@ previous state and go to previous buffer or window." | |||
| 628 | "Quit View mode, kill current buffer and return to previous buffer." | 631 | "Quit View mode, kill current buffer and return to previous buffer." |
| 629 | (interactive) | 632 | (interactive) |
| 630 | (view-mode-exit view-return-to-alist (or view-exit-action 'kill-buffer) t)) | 633 | (view-mode-exit view-return-to-alist (or view-exit-action 'kill-buffer) t)) |
| 631 | 634 | ||
| 632 | 635 | ||
| 633 | ;;; Some help routines. | 636 | ;;; Some help routines. |
| 634 | 637 | ||
| @@ -705,14 +708,16 @@ Also set the mark at the position where point was." | |||
| 705 | (goto-line line) | 708 | (goto-line line) |
| 706 | (view-recenter)) | 709 | (view-recenter)) |
| 707 | 710 | ||
| 708 | (defun View-scroll-to-buffer-end () | 711 | (defun View-back-to-mark (&optional ignore) |
| 709 | "Scroll backward or forward so that buffer end is at last line of window." | 712 | "Return to last mark set in View mode, else beginning of file. |
| 713 | Display that line at the center of the window. | ||
| 714 | This command pops the mark ring, so that successive | ||
| 715 | invocations return to earlier marks." | ||
| 710 | (interactive) | 716 | (interactive) |
| 711 | (let ((p (if (pos-visible-in-window-p (point-max)) (point)))) | 717 | (goto-char (or (mark t) (point-min))) |
| 712 | (goto-char (point-max)) | 718 | (pop-mark) |
| 713 | (recenter -1) | 719 | (view-recenter)) |
| 714 | (and p (goto-char p)))) | 720 | |
| 715 | |||
| 716 | (defun view-scroll-lines (lines backward default maxdefault) | 721 | (defun view-scroll-lines (lines backward default maxdefault) |
| 717 | ;; This function does the job for all the scrolling commands. | 722 | ;; This function does the job for all the scrolling commands. |
| 718 | ;; Scroll forward LINES lines. If BACKWARD is true scroll backwards. | 723 | ;; Scroll forward LINES lines. If BACKWARD is true scroll backwards. |
| @@ -771,6 +776,14 @@ Also set the mark at the position where point was." | |||
| 771 | (if view-scroll-auto-exit "\\[View-scroll-page-forward]" | 776 | (if view-scroll-auto-exit "\\[View-scroll-page-forward]" |
| 772 | "\\[View-quit]"))) | 777 | "\\[View-quit]"))) |
| 773 | (message "End of buffer"))) | 778 | (message "End of buffer"))) |
| 779 | |||
| 780 | (defun View-scroll-to-buffer-end () | ||
| 781 | "Scroll backward or forward so that buffer end is at last line of window." | ||
| 782 | (interactive) | ||
| 783 | (let ((p (if (pos-visible-in-window-p (point-max)) (point)))) | ||
| 784 | (goto-char (point-max)) | ||
| 785 | (recenter -1) | ||
| 786 | (and p (goto-char p)))) | ||
| 774 | 787 | ||
| 775 | (defun View-scroll-page-forward (&optional lines) | 788 | (defun View-scroll-page-forward (&optional lines) |
| 776 | "Scroll \"page size\" or prefix LINES lines forward in View mode. | 789 | "Scroll \"page size\" or prefix LINES lines forward in View mode. |
| @@ -851,17 +864,7 @@ If LINES is more than a window-full, only the last window-full is shown." | |||
| 851 | (let ((view-scroll-auto-exit nil) | 864 | (let ((view-scroll-auto-exit nil) |
| 852 | (view-try-extend-at-buffer-end t)) | 865 | (view-try-extend-at-buffer-end t)) |
| 853 | (view-scroll-lines lines nil view-page-size nil))) | 866 | (view-scroll-lines lines nil view-page-size nil))) |
| 854 | 867 | ||
| 855 | (defun View-back-to-mark (&optional ignore) | ||
| 856 | "Return to last mark set in View mode, else beginning of file. | ||
| 857 | Display that line at the center of the window. | ||
| 858 | This command pops the mark ring, so that successive | ||
| 859 | invocations return to earlier marks." | ||
| 860 | (interactive) | ||
| 861 | (goto-char (or (mark t) (point-min))) | ||
| 862 | (pop-mark) | ||
| 863 | (view-recenter)) | ||
| 864 | |||
| 865 | (defun View-search-regexp-forward (n regexp) | 868 | (defun View-search-regexp-forward (n regexp) |
| 866 | "Search forward for first (or prefix Nth) occurrence of REGEXP in View mode. | 869 | "Search forward for first (or prefix Nth) occurrence of REGEXP in View mode. |
| 867 | 870 | ||