Mercurial > hg > xemacs-beta
comparison lisp/prim/page.el @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | b82b59fe008d |
children | b9518feda344 |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | 15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 ;; General Public License for more details. | 17 ;; General Public License for more details. |
18 | 18 |
19 ;; You should have received a copy of the GNU General Public License | 19 ;; You should have received a copy of the GNU General Public License |
20 ;; along with XEmacs; see the file COPYING. If not, write to the Free | 20 ;; along with XEmacs; see the file COPYING. If not, write to the |
21 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | 21 ;; Free Software Foundation, 59 Temple Place - Suite 330, |
22 ;; 02111-1307, USA. | 22 ;; Boston, MA 02111-1307, USA. |
23 | 23 |
24 ;;; Synched up with: FSF 19.34. | 24 ;;; Synched up with: FSF 19.30. |
25 | 25 |
26 ;;; Commentary: | 26 ;;; Commentary: |
27 | 27 |
28 ;; This code provides the page-oriented movement and selection commands | 28 ;; This code provides the page-oriented movement and selection commands |
29 ;; documented in the XEmacs Reference Manual. | 29 ;; documented in the XEmacs Reference Manual. |
32 | 32 |
33 (defun forward-page (&optional count) | 33 (defun forward-page (&optional count) |
34 "Move forward to page boundary. With arg, repeat, or go back if negative. | 34 "Move forward to page boundary. With arg, repeat, or go back if negative. |
35 A page boundary is any line whose beginning matches the regexp | 35 A page boundary is any line whose beginning matches the regexp |
36 `page-delimiter'." | 36 `page-delimiter'." |
37 (interactive "_p") ; XEmacs | 37 (interactive "_p") |
38 (or count (setq count 1)) | 38 (or count (setq count 1)) |
39 (while (and (> count 0) (not (eobp))) | 39 (while (and (> count 0) (not (eobp))) |
40 ;; In case the page-delimiter matches the null string, | 40 ;; In case the page-delimiter matches the null string, |
41 ;; don't find a match without moving. | 41 ;; don't find a match without moving. |
42 (if (bolp) (forward-char 1)) | 42 (if (bolp) (forward-char 1)) |
43 (if (re-search-forward page-delimiter nil t) | 43 (if (re-search-forward page-delimiter nil t) |
44 nil | 44 nil |
45 (goto-char (point-max))) | 45 (goto-char (point-max))) |
46 (setq count (1- count))) | 46 (setq count (1- count))) |
47 (while (and (< count 0) (not (bobp))) | 47 (while (and (< count 0) (not (bobp))) |
48 ;; In case the page-delimiter matches the null string, | |
49 ;; don't find a match without moving. | |
50 (and (save-excursion (re-search-backward page-delimiter nil t)) | |
51 (= (match-end 0) (point)) | |
52 (goto-char (match-beginning 0))) | |
53 (forward-char -1) | 48 (forward-char -1) |
54 (if (re-search-backward page-delimiter nil t) | 49 (let (result (end (point))) |
55 ;; We found one--move to the end of it. | 50 ;; If we find a match that ends where we started searching, |
56 (goto-char (match-end 0)) | 51 ;; look for another one. |
57 ;; We found nothing--go to beg of buffer. | 52 (while (and (setq result (re-search-backward page-delimiter nil t)) |
58 (goto-char (point-min))) | 53 (= (match-end 0) end)) |
54 ;; Just search again. | |
55 ) | |
56 (if result | |
57 ;; We found one--move to the end of it. | |
58 (goto-char (match-end 0)) | |
59 ;; We found nothing--go to beg of buffer. | |
60 (goto-char (point-min)))) | |
59 (setq count (1+ count)))) | 61 (setq count (1+ count)))) |
60 | 62 |
61 (defun backward-page (&optional count) | 63 (defun backward-page (&optional count) |
62 "Move backward to page boundary. With arg, repeat, or go fwd if negative. | 64 "Move backward to page boundary. With arg, repeat, or go fwd if negative. |
63 A page boundary is any line whose beginning matches the regexp | 65 A page boundary is any line whose beginning matches the regexp |
64 `page-delimiter'." | 66 `page-delimiter'." |
65 (interactive "_p") ; XEmacs | 67 (interactive "p") |
66 (or count (setq count 1)) | 68 (or count (setq count 1)) |
67 (forward-page (- count))) | 69 (forward-page (- count))) |
68 | 70 |
69 (defun mark-page (&optional arg) | 71 (defun mark-page (&optional arg) |
70 "Put mark at end of page, point at beginning. | 72 "Put mark at end of page, point at beginning. |
110 ;; include it. | 112 ;; include it. |
111 ;; Otherwise, show text starting with following line. | 113 ;; Otherwise, show text starting with following line. |
112 (if (and (eolp) (not (bobp))) | 114 (if (and (eolp) (not (bobp))) |
113 (forward-line 1)) | 115 (forward-line 1)) |
114 (point))))) | 116 (point))))) |
115 (put 'narrow-to-page 'disabled t) | |
116 | 117 |
117 (defun count-lines-page () | 118 (defun count-lines-page () |
118 "Report number of lines on current page, and how many are before or after point." | 119 "Report number of lines on current page, and how many are before or after point." |
119 (interactive "_") ; XEmacs | 120 (interactive "_") |
120 (save-excursion | 121 (save-excursion |
121 (let ((opoint (point)) beg end | 122 (let ((opoint (point)) beg end |
122 total before after) | 123 total before after) |
123 (forward-page) | 124 (forward-page) |
124 (beginning-of-line) | 125 (beginning-of-line) |
132 after (count-lines opoint end)) | 133 after (count-lines opoint end)) |
133 (message "Page has %d lines (%d + %d)" total before after)))) | 134 (message "Page has %d lines (%d + %d)" total before after)))) |
134 | 135 |
135 (defun what-page () | 136 (defun what-page () |
136 "Print page and line number of point." | 137 "Print page and line number of point." |
137 (interactive "_") ; XEmacs | 138 (interactive "_") |
138 (save-restriction | 139 (save-restriction |
139 (widen) | 140 (widen) |
140 (save-excursion | 141 (save-excursion |
141 (beginning-of-line) | 142 (beginning-of-line) |
142 (let ((count 1) | 143 (let ((count 1) |