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