-
Notifications
You must be signed in to change notification settings - Fork 4
/
pjb-page.el
118 lines (105 loc) · 3.6 KB
/
pjb-page.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
;;****************************************************************************
;;FILE: pjb-page.el
;;LANGUAGE: emacs lisp
;;SYSTEM: POSIX
;;USER-INTERFACE: NONE
;;DESCRIPTION
;;
;; View a buffer page by page.
;;
;;AUTHORS
;; <PJB> Pascal Bourguignon <[email protected]>
;;MODIFICATIONS
;; 2005-06-01 <PJB> Created.
;;BUGS
;;LEGAL
;; GPL
;;
;; Copyright Pascal Bourguignon 2005 - 2005
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
;; as published by the Free Software Foundation; either version
;; 2 of the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be
;; useful, but WITHOUT ANY WARRANTY; without even the implied
;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
;; PURPOSE. See the GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public
;; License along with this program; if not, write to the Free
;; Software Foundation, Inc., 59 Temple Place, Suite 330,
;; Boston, MA 02111-1307 USA
;;****************************************************************************
(defvar *saved-scroll-functions* nil)
(make-local-variable '*saved-scroll-functions*)
(defun page-mode (&optional on)
(interactive "p")
(if (if on (plusp on) (not *saved-scroll-functions*))
(progn
(narrow-to-page)
(unless *saved-scroll-functions*
(setf *saved-scroll-functions*
(list (key-binding [prior]) (key-binding [next])
(key-binding [home]) (key-binding [end]))))
(local-set-key [prior] (function pm-backward-page))
(local-set-key [next] (function pm-forward-page))
(local-set-key [home] (function pm-beginning-of-buffer))
(local-set-key [end] (function pm-end-of-buffer)))
(progn
(widen)
(if *saved-scroll-functions*
(progn
(local-set-key [prior] (first *saved-scroll-functions*))
(local-set-key [next] (second *saved-scroll-functions*))
(local-set-key [home] (third *saved-scroll-functions*))
(local-set-key [end] (fourth *saved-scroll-functions*))
(setf *saved-scroll-functions* nil))
(progn
(local-set-key [prior] (function scroll-down))
(local-set-key [next] (function scroll-up))
(local-set-key [home] (function beginning-of-buffer))
(local-set-key [end] (function end-of-buffer)))))))
(defun pm-forward-page (&optional count)
(interactive "p")
(setf count (or count 1))
(widen)
(unless (search-forward "\f" nil 'at-limit count)
(goto-char (point-max)))
(narrow-to-page))
(defun pm-backward-page (&optional count)
(interactive "p")
(setf count (or count 1))
(widen)
(unless (search-backward "\f" nil 'at-limit (1+ count))
(goto-char (point-max)))
(narrow-to-page))
(defun pm-beginning-of-buffer ()
(interactive)
(widen)
(goto-char (point-min))
(narrow-to-page))
(defun pm-end-of-buffer ()
(interactive)
(widen)
(goto-char (point-max))
(narrow-to-page))
(defun pjb-animate (speed)
(interactive "nSpeed: ")
(let ((delay (/ 1.0 speed))
(done nil))
(widen)
(goto-char (point-min))
(message "Animating...")
(while (not done)
(widen)
(if (search-forward "\f" nil 'at-limit)
nil
(goto-char (point-max))
(setq done t))
(narrow-to-page)
(sit-for delay)
(force-mode-line-update t)
) ;;while
(message "Done.")))