annotate lisp/textmodes/page-ext.el @ 8155:ad36865ac28e

(tpu-save-all-buffers-kill-emacs): Use delete-old-versions, and bind it locally.
author Richard M. Stallman <rms@gnu.org>
date Wed, 06 Jul 1994 21:32:04 +0000
parents cc7cd83ccf3f
children 187735b53d52
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
1 ;;; page-ext.el --- extended page handling commands
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
3 ;; You may use these commands to handle an address list or other
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
4 ;; small data base.
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
5
7300
cc7cd83ccf3f Update copyright.
Karl Heuer <kwzh@gnu.org>
parents: 6337
diff changeset
6 ;; Copyright (C) 1990, 1991, 1993, 1994 Free Software Foundation
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
7
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
8 ;; Maintainer: Robert J. Chassell <bob@gnu.ai.mit.edu>
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9
664
9b0e666dfdf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
10 ;; This file is part of GNU Emacs.
9b0e666dfdf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
11
9b0e666dfdf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
9b0e666dfdf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 664
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
664
9b0e666dfdf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
15 ;; any later version.
9b0e666dfdf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
16
9b0e666dfdf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
9b0e666dfdf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
9b0e666dfdf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9b0e666dfdf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
20 ;; GNU General Public License for more details.
9b0e666dfdf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
21
9b0e666dfdf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
22 ;; You should have received a copy of the GNU General Public License
9b0e666dfdf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to
9b0e666dfdf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
24 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
9b0e666dfdf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
25
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
27 ;;; Summary
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 ; The current page commands are:
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 ; forward-page C-x ]
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 ; backward-page C-x [
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 ; narrow-to-page C-x p
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 ; count-lines-page C-x l
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 ; mark-page C-x C-p (change this to C-x C-p C-m)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 ; sort-pages not bound
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 ; what-page not bound
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 ; The new page handling commands all use `C-x C-p' as a prefix. This
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 ; means that the key binding for `mark-page' must be changed.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 ; Otherwise, no other changes are made to the current commands or
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 ; their bindings.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 ; New page handling commands:
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 ; next-page C-x C-p C-n
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 ; previous-page C-x C-p C-p
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 ; search-pages C-x C-p C-s
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 ; add-new-page C-x C-p C-a
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 ; sort-pages-buffer C-x C-p s
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 ; set-page-delimiter C-x C-p C-l
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 ; pages-directory C-x C-p C-d
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 ; pages-directory-for-addresses C-x C-p d
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
54 ; pages-directory-goto C-c C-c
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
57 ;;; Using the page commands
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
58
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 ; The page commands are helpful in several different contexts. For
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 ; example, programmers often divide source files into sections using the
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 ; `page-delimiter'; you can use the `pages-directory' command to list
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 ; the sections.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 ; You may change the buffer local value of the `page-delimiter' with
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 ; the `set-page-delimiter' command. This command is bound to `C-x C-p
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 ; C-l' The command prompts you for a new value for the page-delimiter.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 ; Called with a prefix-arg, the command resets the value of the
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 ; page-delimiter to its original value.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
70 ; You may set several user options:
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
71 ;
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
72 ; The `pages-directory-buffer-narrowing-p' variable causes the
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
73 ; `pages-directory-goto' command to narrow to the destination page.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
74 ;
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
75 ; The `pages-directory-for-adding-page-narrowing-p' variable, causes the
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
76 ; `add-new-page' command to narrow to the new entry.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
77 ;
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
78 ; The `pages-directory-for-adding-new-page-before-current-page-p' variable
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
79 ; causes the `add-new-page' command to insert a new page before current
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
80 ; page.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
81 ;
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
82 ; These variables are true by default.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
83 ;
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
84 ; Additional, addresses-related user options are described in the next page
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
85 ; of this file.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
86
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
88 ;;; Handling an address list or small data base
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 ; You may use the page commands to handle an address list or other
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 ; small data base. Put each address or entry on its own page. The
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 ; first line of text in each page is a `header line' and is listed by
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 ; the `pages-directory' or `pages-directory-for-addresses' command.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 ; Specifically:
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 ;
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 ; 1. Begin each entry with a `page-delimiter' (which is, by default,
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 ; `^L' at the beginning of the line).
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 ;
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 ; 2. The first line of text in each entry is the `heading line'; it
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 ; will appear in the pages-directory-buffer which is constructed
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 ; using the `C-x C-p C-d' (pages-directory) command or the `C-x
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 ; C-p d' (pages-directory-for-addresses) command.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 ;
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 ; The heading line may be on the same line as the page-delimiter
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 ; or it may follow after. It is the first non-blank line on the
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 ; page. Conventionally, the heading line is placed on the line
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 ; immediately following the line containing page-delimiter.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 ;
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 ; 3. Follow the heading line with the body of the entry. The body
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 ; extends up to the next `page-delimiter'. The body may be of any
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 ; length. It is conventional to place a blank line after the last
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 ; line of the body.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 ; For example, a file might look like this:
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 ;
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 ; FSF
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 ; Free Software Foundation
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 ; 675 Massachusetts Avenue
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 ; Cambridge, MA 02139 USA
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 ; (617) 876-3296
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 ; gnu@prep.ai.mit.edu
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 ;
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 ;
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 ; House Subcommittee on Intellectual Property,
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 ; U.S. House of Representatives,
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 ; Washington, DC 20515
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 ;
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 ; Congressional committee concerned with permitting or preventing
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
130 ; monopolistic restrictions on the use of software technology.
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 ;
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 ;
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 ; George Lakoff
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 ; ``Women, Fire, and Dangerous Things:
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 ; What Categories Reveal about the Mind''
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 ; 1987, Univ. of Chicago Press
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 ;
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 ; About philosophy, Whorfian effects, and linguistics.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 ;
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 ;
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 ; OBI (On line text collection.)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 ; Open Book Initiative
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 ; c/o Software Tool & Die
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 ; 1330 Beacon St, Brookline, MA 02146 USA
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 ; (617) 739-0202
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 ; obi@world.std.com
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 ; In this example, the heading lines are:
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 ;
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 ; FSF
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 ; House Subcommittee on Intellectual Property
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 ; George Lakoff
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 ; OBI (On line text collection.)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 ; The `C-x C-p s' (sort-pages-buffer) command sorts the entries in the
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 ; buffer alphabetically.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 ; You may use any of the page commands, including the `next-page',
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 ; `previous-page', `add-new-page', `mark-page', and `search-pages'
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 ; commands.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 ; You may use either the `C-x C-p d' (pages-directory-for-addresses)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 ; or the `C-x C-p C-d' (pages-directory) command to construct and
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 ; dislay a directory of all the heading lines.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 ; In the directory, you may position the cursor over a heading line
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
167 ; and type `C-c C-c' (pages-directory-goto) to go to the entry to
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
168 ; which it refers in the pages buffer.
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
170 ; You can type `C-c C-p C-a' (add-new-page) to add a new entry in the
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
171 ; pages buffer or address file. This is the same command you use to
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
172 ; add a new entry when you are in the pages buffer or address file.
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 ; If you wish, you may create several different directories,
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 ; one for each different buffer.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 ;; `pages-directory-for-addresses' in detail
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 ; The `pages-directory-for-addresses' assumes a default addresses
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 ; file. You do not need to specify the addresses file but merely type
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 ; `C-x C-p d' from any buffer. The command finds the file, constructs
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 ; a directory for it, and switches you to the directory. If you call
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 ; the command with a prefix arg, `C-u C-x C-p d', it prompts you for a
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 ; file name.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
186 ; You may customize the addresses commands:
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
187
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
188 ; The `pages-addresses-file-name' variable determines the name of
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
189 ; the addresses file; by default it is "~/addresses".
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
190
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
191 ; The `pages-directory-for-addresses-goto-narrowing-p' variable
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
192 ; determines whether `pages-directory-goto' narrows the addresses
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
193 ; buffer to the entry, which it does by default.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
194
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
195 ; The `pages-directory-for-addresses-buffer-keep-windows-p' variable
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
196 ; determines whether `pages-directory-for-addresses' deletes other
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
197 ; windows to show as many lines as possible on the screen or works
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
198 ; in the usual Emacs manner and keeps other windows. Default is to
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
199 ; keep other windows.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
200
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
201 ; The `pages-directory-for-adding-addresses-narrowing-p' variable
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
202 ; determines whether `pages-directory-for-addresses' narrows the
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
203 ; addresses buffer to a new entry when you are adding that entry.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
204 ; Default is to narrow to new entry, which means you see a blank
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
205 ; screen before you write the new entry.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
206
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 ;; `pages-directory' in detail
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
209 ; Call the `pages-directory' command from the buffer for which you
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
210 ; want a directory created; it creates a directory for the buffer and
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
211 ; pops you to the directory.
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 ; The `pages-directory' command has several options:
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 ; Called with a prefix arg, `C-u C-x C-p C-d', the `pages-directory'
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 ; prompts you for a regular expression and only lists only those
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 ; header lines that are part of pages that contain matches to the
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 ; regexp. In the example above, `C-u C-x C-p C-d 617 RET' would
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 ; match the telephone area code of the first and fourth entries, so
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 ; only the header lines of those two entries would appear in the
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 ; pages-directory-buffer.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 ;
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 ; Called with a numeric argument, the `pages-directory' command
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 ; lists the number of lines in each page. This is helpful when you
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 ; are printing hardcopy.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 ; Called with a negative numeric argument, the `pages-directory'
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 ; command lists the lengths of pages whose contents match a regexp.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
230 ;;; Code:
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
231
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
233 ;;; Customarily customizable variable definitions
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
234
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
235 (defvar pages-directory-buffer-narrowing-p t
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
236 "*If non-nil, `pages-directory-goto' narrows pages buffer to entry.")
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
237
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
238 (defvar pages-directory-for-adding-page-narrowing-p t
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
239 "*If non-nil, `add-new-page' narrows page buffer to new entry.")
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
240
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
241 (defvar pages-directory-for-adding-new-page-before-current-page-p t
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
242 "*If non-nil, `add-new-page' inserts new page before current page.")
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
243
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
244
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
245 ;;; Addresses related variables
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
246
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
247 (defvar pages-addresses-file-name "~/addresses"
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
248 "*Standard name for file of addresses. Entries separated by page-delimiter.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
249 Used by `pages-directory-for-addresses' function.")
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
250
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
251 (defvar pages-directory-for-addresses-goto-narrowing-p t
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
252 "*If non-nil, `pages-directory-goto' narrows addresses buffer to entry.")
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
253
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
254 (defvar pages-directory-for-addresses-buffer-keep-windows-p t
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
255 "*If nil, `pages-directory-for-addresses' deletes other windows.")
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
256
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
257 (defvar pages-directory-for-adding-addresses-narrowing-p t
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
258 "*If non-nil, `add-new-page' narrows addresses buffer to new entry.")
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
259
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
260
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
261 ;;; Key bindings for page handling functions
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 (global-unset-key "\C-x\C-p")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 (defvar ctl-x-ctl-p-map (make-sparse-keymap)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 "Keymap for subcommands of C-x C-p, which are for page handling.")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 (define-key ctl-x-map "\C-p" 'ctl-x-ctl-p-prefix)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 (fset 'ctl-x-ctl-p-prefix ctl-x-ctl-p-map)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 (define-key ctl-x-ctl-p-map "\C-n" 'next-page)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 (define-key ctl-x-ctl-p-map "\C-p" 'previous-page)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 (define-key ctl-x-ctl-p-map "\C-a" 'add-new-page)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 (define-key ctl-x-ctl-p-map "\C-m" 'mark-page)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 (define-key ctl-x-ctl-p-map "\C-s" 'search-pages)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 (define-key ctl-x-ctl-p-map "s" 'sort-pages-buffer)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 (define-key ctl-x-ctl-p-map "\C-l" 'set-page-delimiter)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 (define-key ctl-x-ctl-p-map "\C-d" 'pages-directory)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 (define-key ctl-x-ctl-p-map "d" 'pages-directory-for-addresses)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
282 ;;; Page movement function definitions
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 (defun next-page (&optional count)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 "Move to the next page bounded by the `page-delimiter' variable.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 With arg (prefix if interactive), move that many pages."
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 (interactive "p")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 (or count (setq count 1))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 (widen)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 ;; Cannot use forward-page because of problems at page boundaries.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 (while (and (> count 0) (not (eobp)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 (if (re-search-forward page-delimiter nil t)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 nil
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 (goto-char (point-max)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 (setq count (1- count)))
1770
29bcc2c88773 * page-ext.el (next-page): Correctly handle negative page count.
Jim Blandy <jimb@redhat.com>
parents: 845
diff changeset
296 ;; If COUNT is negative, we want to go back -COUNT + 1 page boundaries.
29bcc2c88773 * page-ext.el (next-page): Correctly handle negative page count.
Jim Blandy <jimb@redhat.com>
parents: 845
diff changeset
297 ;; The first page boundary we reach is the top of the current page,
29bcc2c88773 * page-ext.el (next-page): Correctly handle negative page count.
Jim Blandy <jimb@redhat.com>
parents: 845
diff changeset
298 ;; which doesn't count.
29bcc2c88773 * page-ext.el (next-page): Correctly handle negative page count.
Jim Blandy <jimb@redhat.com>
parents: 845
diff changeset
299 (while (and (< count 1) (not (bobp)))
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 (if (re-search-backward page-delimiter nil t)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 (goto-char (match-beginning 0))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 (goto-char (point-min)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 (setq count (1+ count)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 (narrow-to-page)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 (goto-char (point-min))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 (recenter 0))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 (defun previous-page (&optional count)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 "Move to the previous page bounded by the `page-delimiter' variable.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 With arg (prefix if interactive), move that many pages."
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 (interactive "p")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 (or count (setq count 1))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 (next-page (- count)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
316 ;;; Adding and searching pages
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 (defun add-new-page (header-line)
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
319 "Insert new page. Prompt for header line.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
320
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
321 If point is in the pages directory buffer, insert the new page in the
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
322 buffer associated with the directory.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
323
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
324 Insert the new page just before current page if
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
325 pages-directory-for-adding-new-page-before-current-page-p variable
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
326 is non-nil. Else insert at exact location of point.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
327
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
328 Narrow to new page if
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
329 pages-directory-for-adding-page-narrowing-p variable
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
330 is non-nil.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
331
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
332 Page begins with a `^L' as the default page-delimiter.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
333 Use \\[set-page-delimiter] to change the page-delimiter.
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 Point is left in the body of page."
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 (interactive "sHeader line: ")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 (widen)
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
337 ;; If in pages directory buffer
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
338 (if (eq major-mode 'pages-directory-mode)
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
339 (progn
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
340 ;; Add new page before or after current page?
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
341 (if pages-directory-for-adding-new-page-before-current-page-p
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
342 (pages-directory-goto)
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
343 (pages-directory-goto)
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
344 (forward-page)
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
345 (or (eobp) (forward-line -1)))))
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
346 (widen)
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
347 ;; Move point before current delimiter if desired.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
348 (and pages-directory-for-adding-new-page-before-current-page-p
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
349 (if (re-search-backward page-delimiter nil t)
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
350 (goto-char (match-beginning 0))
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
351 ;; If going to beginning of file, insert a page-delimiter
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
352 ;; before current first page.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
353 (goto-char (point-min))
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
354 (insert
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
355 (format "%s\n"
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
356 ;; Remove leading `^' from page-delimiter string
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
357 (if (eq '^ (car (read-from-string page-delimiter)))
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
358 (substring page-delimiter 1))))
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
359 (goto-char (point-min))))
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
360 ;; Insert page delimiter at beginning of line.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
361 (if (not (looking-at "^.")) (forward-line 1))
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
362 (insert (format "%s\n%s\n\n\n"
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
363 (if (eq '^ (car (read-from-string page-delimiter)))
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
364 (substring page-delimiter 1))
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
365 header-line))
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
366 (forward-line -1)
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
367 (and pages-directory-for-adding-page-narrowing-p (narrow-to-page)))
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 (defvar pages-last-search nil
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 "Value of last regexp searched for. Initially, nil.")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 (defun search-pages (regexp)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 "Search for REGEXP, starting from point, and narrow to page it is in."
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 (interactive (list
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 (read-string
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 (format "Search for `%s' (end with RET): "
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 (or pages-last-search "regexp")))))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 (if (equal regexp "")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 (setq regexp pages-last-search)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 (setq pages-last-search regexp))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 (widen)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 (re-search-forward regexp)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 (narrow-to-page))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
386 ;;; Sorting pages
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 (autoload 'sort-subr "sort" "Primary function for sorting." t nil)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 (defun sort-pages-in-region (reverse beg end)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391 "Sort pages in region alphabetically. Prefix arg means reverse order.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393 Called from a program, there are three arguments:
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 REVERSE (non-nil means reverse order), BEG and END (region to sort)."
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 ;;; This sort function handles ends of pages differently than
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 ;;; `sort-pages' and works better with lists of addresses and similar
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 ;;; files.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 (interactive "P\nr")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 (save-restriction
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 (narrow-to-region beg end)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 (goto-char (point-min))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 ;;; `sort-subr' takes three arguments
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 (sort-subr reverse
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 ;; NEXTRECFUN is called with point at the end of the
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 ;; previous record. It moves point to the start of the
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409 ;; next record.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 (function (lambda ()
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 (re-search-forward page-delimiter nil t)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 (skip-chars-forward " \t\n")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 ))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 ;; ENDRECFUN is is called with point within the record.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 ;; It should move point to the end of the record.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 (function (lambda ()
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 (if (re-search-forward
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 page-delimiter
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 nil
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421 t)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 (goto-char (match-beginning 0))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 (goto-char (point-max))))))))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 (defun sort-pages-buffer (&optional reverse)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 "Sort pages alphabetically in buffer. Prefix arg means reverse order.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 \(Non-nil arg if not interactive.\)"
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 (interactive "P")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 (or reverse (setq reverse nil))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 (widen)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 (let ((beginning (point-min))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 (end (point-max)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 (sort-pages-in-region reverse beginning end)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
437 ;;; Pages directory ancillary definitions
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 (defvar pages-directory-previous-regexp nil
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 "Value of previous regexp used by `pages-directory'.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 \(This regular expression may be used to select only those pages that
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 contain matches to the regexp.\)")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 (defvar pages-buffer nil
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 "The buffer for which the pages-directory function creates the directory.")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 (defvar pages-directory-prefix "*Directory for:"
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 "Prefix of name of temporary buffer for pages-directory.")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 (defvar pages-pos-list nil
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 "List containing the positions of the pages in the pages-buffer.")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 (defvar pages-directory-map nil
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454 "Keymap for the pages-directory-buffer.")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456 (if pages-directory-map
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 ()
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 (setq pages-directory-map (make-sparse-keymap))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 (define-key pages-directory-map "\C-c\C-c"
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
460 'pages-directory-goto)
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
461 (define-key pages-directory-map "\C-c\C-p\C-a" 'add-new-page))
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
462
6337
32cb5a7228ab (original-page-delimiter, set-page-delimiter): Use printable escapes instead of
Karl Heuer <kwzh@gnu.org>
parents: 5311
diff changeset
463 (defvar original-page-delimiter "^\f"
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
464 "Default page delimiter.")
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 (defun set-page-delimiter (regexp reset-p)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 "Set buffer local value of page-delimiter to REGEXP.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 Called interactively with a prefix argument, reset `page-delimiter' to
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 its original value.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 In a program, non-nil second arg causes first arg to be ignored and
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 resets the page-delimiter to the original value."
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 (interactive
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 (if current-prefix-arg
6337
32cb5a7228ab (original-page-delimiter, set-page-delimiter): Use printable escapes instead of
Karl Heuer <kwzh@gnu.org>
parents: 5311
diff changeset
476 (list original-page-delimiter "^\f")
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 (list (read-string "Set page-delimiter to regexp: " page-delimiter)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478 nil)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479 (make-local-variable 'original-page-delimiter)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
480 (make-local-variable 'page-delimiter)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
481 (setq original-page-delimiter
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
482 (or original-page-delimiter page-delimiter))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483 (if (not reset-p)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 (setq page-delimiter regexp)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485 (setq page-delimiter original-page-delimiter))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486 (if (interactive-p)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487 (message "The value of `page-delimiter' is now: %s" page-delimiter)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
490 ;;; Pages directory main definitions
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492 (defun pages-directory
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 (pages-list-all-headers-p count-lines-p &optional regexp)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 "Display a directory of the page headers in a temporary buffer.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
495 A header is the first non-blank line after the page-delimiter.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496 \\[pages-directory-mode]
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
497 You may move point to one of the lines in the temporary buffer,
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498 then use \\<pages-directory-goto> to go to the same line in the pages buffer.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
499
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500 In interactive use:
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502 1. With no prefix arg, display all headers.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
504 2. With prefix arg, display the headers of only those pages that
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505 contain matches to a regular expression for which you are
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
506 prompted.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 3. With numeric prefix arg, for every page, print the number of
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509 lines within each page.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 4. With negative numeric prefix arg, for only those pages that
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
512 match a regular expression, print the number of lines within
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
513 each page.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
514
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515 When called from a program, non-nil first arg means list all headers;
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516 non-nil second arg means print numbers of lines in each page; if first
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 arg is nil, optional third arg is regular expression.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
519 If the buffer is narrowed, the `pages-directory' command creates a
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
520 directory for only the accessible portion of the buffer."
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522 (interactive
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523 (cond ((not current-prefix-arg)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
524 (list t nil nil))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
525 ((listp current-prefix-arg)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
526 (list nil
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
527 nil
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
528 (read-string
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
529 (format "Select according to `%s' (end with RET): "
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
530 (or pages-directory-previous-regexp "regexp")))))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
531 ((> (prefix-numeric-value current-prefix-arg) 0)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
532 (list t t nil))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
533 ((< (prefix-numeric-value current-prefix-arg) 0)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
534 (list nil
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
535 t
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
536 (read-string
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
537 (format "Select according to `%s' (end with RET): "
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
538 (or pages-directory-previous-regexp "regexp")))))))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
539
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
540 (if (equal regexp "")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
541 (setq regexp pages-directory-previous-regexp)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
542 (setq pages-directory-previous-regexp regexp))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
543
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
544 (if (interactive-p)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
545 (message "Creating directory for: %s "
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
546 (buffer-name)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
547
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
548 (let ((target-buffer (current-buffer))
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
549 (pages-directory-buffer
5311
da52825a3880 (pages-copy-header-and-position): Call end-of-line, not forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 5021
diff changeset
550 (concat pages-directory-prefix " " (buffer-name)))
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
551 (linenum 1)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
552 (pages-buffer-original-position (point))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
553 (pages-buffer-original-page 0))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
554
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
555 ;; `with-output-to-temp-buffer' binds the value of the variable
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
556 ;; `standard-output' to the buffer named as its first argument,
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557 ;; but does not switch to that buffer.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
558 (with-output-to-temp-buffer pages-directory-buffer
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
559 (save-excursion
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
560 (set-buffer standard-output)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561 (pages-directory-mode)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 (insert
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
563 "==== Pages Directory: use `C-c C-c' to go to page under cursor. ====" ?\n)
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
564 (setq pages-buffer target-buffer)
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
565 (setq pages-pos-list nil))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
566
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
567 (if pages-list-all-headers-p
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
568
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
569 ;; 1. If no prefix argument, list all headers
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
570 (save-excursion
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
571 (goto-char (point-min))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
572
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
573 ;; (a) Point is at beginning of buffer; but the first
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
574 ;; page may not begin with a page-delimiter
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
575 (save-restriction
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
576 ;; If page delimiter is at beginning of buffer, skip it
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
577 (if (and (save-excursion
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
578 (re-search-forward page-delimiter nil t))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
579 (= 1 (match-beginning 0)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
580 (goto-char (match-end 0)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
581 (narrow-to-page)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
582 (pages-copy-header-and-position count-lines-p))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
583
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
584 ;; (b) Search within pages buffer for next page-delimiter
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
585 (while (re-search-forward page-delimiter nil t)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
586 (pages-copy-header-and-position count-lines-p)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
587
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
588 ;; 2. Else list headers whose pages match regexp.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
589 (save-excursion
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
590 ;; REMOVED save-restriction AND widen FROM HERE
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
591 (goto-char (point-min))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
592
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
593 ;; (a) Handle first page
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
594 (save-restriction
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595 (narrow-to-page)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
596 ;; search for selection regexp
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
597 (if (save-excursion (re-search-forward regexp nil t))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598 (pages-copy-header-and-position count-lines-p)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
600 ;; (b) Search for next page-delimiter
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
601 (while (re-search-forward page-delimiter nil t)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602 (save-restriction
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
603 (narrow-to-page)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
604 ;; search for selection regexp
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
605 (if (save-excursion (re-search-forward regexp nil t))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
606 (pages-copy-header-and-position count-lines-p)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
607 )))))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
608
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
609 (set-buffer standard-output)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
610 ;; Put positions in increasing order to go with buffer.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
611 (setq pages-pos-list (nreverse pages-pos-list))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
612 (if (interactive-p)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
613 (message "%d matching lines in: %s"
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
614 (length pages-pos-list) (buffer-name target-buffer))))
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
615 (pop-to-buffer pages-directory-buffer)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
616 (sit-for 0) ; otherwise forward-line fails if N > window height.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
617 (forward-line (if (= 0 pages-buffer-original-page)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
618 1
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
619 pages-buffer-original-page))))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
620
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
621 (defun pages-copy-header-and-position (count-lines-p)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
622 "Copy page header and its position to the Pages Directory.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
623 Only arg non-nil, count lines in page and insert before header.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
624 Used by `pages-directory' function."
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
625
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
626 (let (position line-count)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
627
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
628 (if count-lines-p
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
629 (save-excursion
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
630 (save-restriction
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
631 (narrow-to-page)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
632 (setq line-count (count-lines (point-min) (point-max))))))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
633
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
634 ;; Keep track of page for later cursor positioning
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
635 (if (<= (point) pages-buffer-original-position)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636 (setq pages-buffer-original-page
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637 (1+ pages-buffer-original-page)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
638
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
639 (save-excursion
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
640 ;; go to first non-blank char after the page-delimiter
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
641 (skip-chars-forward " \t\n")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
642 ;; set the marker here; this the place to which the
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
643 ;; `pages-directory-goto' command will go
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 (setq position (make-marker))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
645 (set-marker position (point))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
646 (let ((start (point))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
647 (end (save-excursion (end-of-line) (point))))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
648 ;; change to directory buffer
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
649 (set-buffer standard-output)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
650 ;; record page position
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
651 (setq pages-pos-list (cons position pages-pos-list))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
652 ;; insert page header
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
653 (insert-buffer-substring target-buffer start end))
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655 (if count-lines-p
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
656 (save-excursion
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
657 (beginning-of-line)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
658 (insert (format "%3d: " line-count))))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
659
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
660 (terpri))
5311
da52825a3880 (pages-copy-header-and-position): Call end-of-line, not forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 5021
diff changeset
661 (end-of-line 1)))
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
663 (defun pages-directory-mode ()
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
664 "Mode for handling the pages-directory buffer.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
665
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
666 Move point to one of the lines in this buffer, then use \\[pages-directory-goto] to go
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
667 to the same line in the pages buffer."
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
668
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
669 (kill-all-local-variables)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
670 (use-local-map pages-directory-map)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
671 (setq major-mode 'pages-directory-mode)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
672 (setq mode-name "Pages-Directory")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
673 (make-local-variable 'pages-buffer)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 (make-local-variable 'pages-pos-list)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675 (make-local-variable 'pages-directory-buffer-narrowing-p))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
676
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
677 (defun pages-directory-goto ()
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
678 "Go to the corresponding line in the pages buffer."
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
679
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
680 ;;; This function is mostly a copy of `occur-mode-goto-occurrence'
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
681
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
682 (interactive)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
683 (if (or (not pages-buffer)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
684 (not (buffer-name pages-buffer)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
685 (progn
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
686 (setq pages-buffer nil
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
687 pages-pos-list nil)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
688 (error "Buffer in which pages were found is deleted.")))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
689 (beginning-of-line)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
690 (let* ((pages-number (1- (count-lines (point-min) (point))))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
691 (pos (nth pages-number pages-pos-list))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
692 (end-of-directory-p (eobp))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
693 (narrowing-p pages-directory-buffer-narrowing-p))
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
694 (pop-to-buffer pages-buffer)
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
695 (widen)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
696 (if end-of-directory-p
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
697 (goto-char (point-max))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
698 (goto-char (marker-position pos)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
699 (if narrowing-p (narrow-to-page))))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
700
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
701
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
702 ;;; The `pages-directory-for-addresses' function and ancillary code
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
703
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
704 (defun pages-directory-for-addresses (&optional filename)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
705 "Find addresses file and display its directory.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
706 By default, create and display directory of `pages-addresses-file-name'.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
707 Optional argument is FILENAME. In interactive use, with prefix
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
708 argument, prompt for file name and provide completion.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
709
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
710 Move point to one of the lines in the displayed directory,
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
711 then use \\[pages-directory-goto] to go to the same line
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
712 in the addresses buffer.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
713
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
714 If pages-directory-for-addresses-goto-narrowing-p is non-nil,
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
715 `pages-directory-goto' narrows addresses buffer to entry.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
716
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
717 If pages-directory-for-addresses-buffer-keep-windows-p is nil,
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
718 this command deletes other windows when it displays the addresses
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
719 directory."
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
720
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
721 (interactive
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
722 (list (if current-prefix-arg
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
723 (read-file-name "Filename: " pages-addresses-file-name))))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
724
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
725 (if (interactive-p)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
726 (message "Creating directory for: %s "
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
727 (or filename pages-addresses-file-name)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
728 (if (file-exists-p (or filename pages-addresses-file-name))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
729 (progn
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
730 (set-buffer
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
731 (find-file-noselect
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
732 (expand-file-name
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
733 (or filename pages-addresses-file-name))))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
734 (widen)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
735 (pages-directory t nil nil)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
736 (pages-directory-address-mode)
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
737 (setq pages-directory-buffer-narrowing-p
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
738 pages-directory-for-addresses-goto-narrowing-p)
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
739 (or pages-directory-for-addresses-buffer-keep-windows-p
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
740 (delete-other-windows))
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
741 (save-excursion
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
742 (goto-char (point-min))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
743 (delete-region (point) (save-excursion (end-of-line) (point)))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
744 (insert
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
745 "=== Address List Directory: use `C-c C-c' to go to page under cursor. ===")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
746 (set-buffer-modified-p nil)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
747 ))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
748 (error "No addresses file found!")))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
749
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
750 (defun pages-directory-address-mode ()
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
751 "Mode for handling the Addresses Directory buffer.
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
752
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
753 Move point to one of the lines in this buffer,
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
754 then use \\[pages-directory-goto] to go
235
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
755 to the same line in the pages buffer."
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
756
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
757 (use-local-map pages-directory-map)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
758 (setq major-mode 'pages-directory-address-mode)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
759 (setq mode-name "Addresses Directory")
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
760 (make-local-variable 'pages-buffer)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
761 (make-local-variable 'pages-pos-list)
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
762 (make-local-variable 'pages-directory-buffer-narrowing-p))
c7cad852d5b4 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
763
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
764
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
765 ;;; Place `provide' at end of file.
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
766 (provide 'page-ext)
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 235
diff changeset
767
5021
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
768 ;;;;;;;;;;;;;;;; end of page-ext.el ;;;;;;;;;;;;;;;;
47afb35f4968 Revise documentation. Add `provide'.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
769