annotate lisp/textmodes/page-ext.el @ 75962:920f6d87d9e6

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