annotate lisp/hyperbole/wrolo.el @ 90:99da576a67e7 xemacs-20-0

Import from CVS: tag xemacs-20-0
author cvs
date Mon, 13 Aug 2007 09:10:46 +0200
parents 131b0175ea99
children 4be1180a9e89
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;!emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; FILE: wrolo.el V2 (Renamed from rolo.el in earlier versions to avoid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; load path conflicts with the rolo.el written by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; another author.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; SUMMARY: Hierarchical, multi-file, easy to use rolodex system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; USAGE: GNU Emacs Lisp Library
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; KEYWORDS: hypermedia, matching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; AUTHOR: Bob Weiner
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
11 ;; ORG: Motorola Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; ORIG-DATE: 7-Jun-89 at 22:08:29
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
14 ;; LAST-MOD: 31-Oct-95 at 18:39:54 by Bob Weiner
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; This file is part of Hyperbole.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; Available for use and distribution under the same terms as GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
19 ;; Copyright (C) 1989, '90, '91, '92, '95 Free Software Foundation, Inc.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
20 ;; Developed with support from Motorola Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; DESCRIPTION:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; The `put whatever you feel like into it' rolodex.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; FEATURES:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; 1. Multiple rolodex files with free text lookup. No structured
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; fields are used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; 2. Hierarchical rolodex entries as in:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; * Company
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; ** Manager
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; *** Underlings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; Searching for Manager turns up all Underlings. Searching for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; Company retrieves all listed employees.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; This hierarchical system has proved very effective for retrieving
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; computer system administration problem reports by vendor name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; problem number or by subject area, without having to resort to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; database system, and also for extraction of relevant text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; sections from reports.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; 3. String and regular expression searching capabilities. Matches are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; found anywhere within entries, so entries may be of any format you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; like without the bother of fixed field restrictions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; Ability to restrict number of matches or to report number of matches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; without displaying entries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; 4. Smart addition, editing and sorting of entries by hierarchy level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; 5. Support for Hyperbole buttons within rolodex entries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; See "wrolo-logic.el" for logical search functions (and, or, not, xor).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; See "wrolo-menu.el" for menu handling functions. (If you received
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; wrolo as part of Hyperbole, this file in unneeded and so not included.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; SETUP:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
62 ;; The variable 'rolo-file-list' is a list of files to search for
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; matching rolodex entries. To add personal files to rolo-file-list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; when you find these functions are useful for any sort of list lookup,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; add the following to your ~/.emacs file (substituting where you see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; <fileN>):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; (setq rolo-file-list (append rolo-file-list '("<file1>" "<file2>")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
70 ;; We recommend that entries in 'rolo-file-list' have ".otl" suffixes
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; so that they do not conflict with file names that other rolodex
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
72 ;; programs might use and so that they are edited in 'outline-mode' by
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; default. If you want the latter behavior, uncomment and add something
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; like the following to one of your GNU Emacs initialization files:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; ;; Add to the list of suffixes that causes automatic mode invocation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; (setq auto-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; (append '(("\\.otl$" . outline-mode)) auto-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; The buffers containing the rolodex files are not killed after a search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; on the assumption that another search is likely to follow within this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; Emacs session. You may wish to change this behavior with the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;; setting:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; (setq rolo-kill-buffers-after-use t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; After an entry is killed, the modified rolodex file is automatically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; saved. If you would rather always save files yourself, use this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; setting:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; (setq rolo-save-buffers-after-use nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; When adding an entry from within a buffer containing a mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; message, the rolodex add function will extract the sender's name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; and e-mail address and prompt you with the name as a default. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; you accept it, it will enter the name and the email address using
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
97 ;; the format given by the 'rolo-email-format' variable. See its
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; documentation if you want to change its value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;; If you use Hyperbole V2.3 or greater, then no other rolodex setup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;; is necessary, simply select the "Rolo/" menu item from the top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; level Hyperbole menu. Otherwise, add the following to your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;; "~/.emacs" file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; (autoload 'rolo-menu "rolo-menu" "Load wrolo system." t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;; (global-set-key "\C-x4r" 'rolo-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; And then simply invoke the rolodex menu with {C-x 4 r} after Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;; has read those lines in your init file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;; SUMMARY OF USE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;; The rolo menu provides access to the following commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;; Menu Item Function Description
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;; ====================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;; Add rolo-add Adds a rolodex entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;; Display rolo-display-matches Displays last matches again
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;; Edit rolo-edit Edits an existing rolodex entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;; Info Displays Rolodex manual entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;; Kill rolo-kill Removes an entry from the rolodex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; Order rolo-sort Sorts all levels in rolodex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; RegexFind rolo-grep Finds all entries containing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;; a regular expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;; StringFind rolo-fgrep Finds all entries containing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; a string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; WordFind rolo-word Finds all entries containing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; a string of whole words
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; Yank rolo-yank Inserts first matching rolodex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; entry at point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; For any of these commands that prompt you for a name, you may use the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; parent/child to locate a child entry below a parent entry, e.g.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; from the example near the top, we could give Company/Manager/Underlings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
138 ;; Here is a snippet from our group rolodex file. The ';'s should be
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
139 ;; removed of course and the '*'s should begin at the start of the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;; line. If a rolodex file begins with two separator lines whose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;; first three characters are "===", then these lines and any text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;; between them are prepended to the output buffer whenever any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;; entries are retrieved from that file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;=============================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;; GROUP ROLODEX
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;; <Last Name>, <First Name> <Co/Categ> W<Work #> H<Home #> P<Pager #>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;; F<Fax #> M<Modem #> C<Cellular #>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;; <Address> <Miscellaneous Info, Key Words>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;;=============================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;;* EX594, Digital-Systems-Research
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;;** Weiner, Bob Motorola W2087 P7-7489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;; FL19, L-1035
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;; FOR PROGRAMMERS:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;; Entries in rolodex files are separated by patterns matching
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
159 ;; 'rolo-entry-regexp'. Each entry may have any number of sub-entries
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;; which represent the next level down in the entry hierarchy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; Sub-entries' separator patterns are always longer than their parents'.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
162 ;; For example, if an entry began with '*' then its sub-entries would begin
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
163 ;; with '**' and so on. Blank lines in rolodex files will not end up where
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;; you want them if you use the rolo-sort commands; therefore, blank lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;; are not recommended. If you change the value of
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
166 ;; 'rolo-entry-regexp', you will have to modify 'rolo-sort'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;; The following additional functions are provided:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
170 ;; 'rolo-sort-level' sorts a specific level of entries in a rolodex file;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
171 ;; 'rolo-map-level' runs a user specified function on a specific level of
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;; entries in a rolodex file;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
173 ;; 'rolo-fgrep-file', same as 'rolo-fgrep' but operates on a single file;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
174 ;; 'rolo-grep-file', same as 'rolo-grep' but operates on a single file;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
175 ;; 'rolo-display-matches', display last set of rolodex matches, if any;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
176 ;; 'rolo-toggle-narrow-to-entry' toggles between display of current entry
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;; and display of all matching entries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;; MOD HISTORY:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;; 12/17/89
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
183 ;; Added internal 'rolo-shrink-window' function for use in
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; compressing/uncompressing the rolo view window to/from a size just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;; large enough for the selected entry. This is useful when a search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;; turns up more entries than desired.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; 02/21/90
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
189 ;; Modified 'rolo-grep-file' and 'rolo-map-level' so they only set buffers
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;; read-only the first time they are read in. This way, if someone edits a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;; rolodex file and then does a rolo-fgrep or other function, the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;; will not be back in read-only mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;; 04/18/91
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
195 ;; Modified 'rolo-grep-file' to expand any hidden entries in rolo file
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;; before doing a search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;; 12/24/91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;; Added Hyperbole button support.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;; 12/30/91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;; Added convenient support for entry add, edit, kill and yank.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; 01/10/91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;; Fixed bug in rolo-to that ended search too early.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;; DESCRIP-END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;;; Other required Elisp libraries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (require 'hversion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (require 'hmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;;; Public variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (defvar rolo-email-format "%s\t\t<%s>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 "Format string to use when adding an entry with e-mail addr from a mail msg.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 It must contain a %s indicating where to put the entry name and a second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 %s indicating where to put the e-mail address.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (defvar rolo-file-list
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
226 (if (memq system-type '(ms-windows windows-nt ms-dos))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 '("c:/_rolodex.otl") '("~/.rolodex.otl"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 "*List of files containing rolodex entries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 The first file should be a user-specific rolodex file, typically in the home
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 directory. The second file is often a shared, group-specific rolodex file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 A rolo-file consists of:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (1) an optional header beginning with and ending with a line which matches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 rolo-hdr-regexp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (2) one or more rolodex entries which each begin with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 rolo-entry-regexp and may be nested.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (defvar rolo-highlight-face nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 "*Face used to highlight rolodex search matches.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (if rolo-highlight-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (setq rolo-highlight-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (cond (hyperb:emacs19-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (if (fboundp 'make-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (progn (make-face 'rolo-highlight-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 'rolo-highlight-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (hyperb:epoch-p (make-style))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (t (if (fboundp 'make-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (face-name (make-face 'rolo-highlight-face))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (if (fboundp 'hproperty:set-item-highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (hproperty:set-item-highlight)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (defvar rolo-kill-buffers-after-use nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 "*Non-nil means kill rolodex file buffers after searching them for entries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 Only unmodified buffers are killed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (defvar rolo-save-buffers-after-use t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 "*Non-nil means save rolodex file after an entry is killed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (defvar wrolo-yank-reformat-function nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 "*Value is a function of two arguments, START and END, invoked after a rolo-yank.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 It should reformat the region given by the arguments to some preferred style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 Default value is nil, meaning no reformmating is done.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;;; Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (defun rolo-add (name &optional file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 "Adds a new entry in personal rolodex for NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 Last name first is best, e.g. \"Smith, John\".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 With prefix argument, prompts for optional FILE to add entry within.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 NAME may be of the form: parent/child to insert child below a parent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 entry which begins with the parent string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (or (fboundp 'mail-fetch-field) (require 'mail-utils))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (let* ((lst (rolo-name-and-email))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (name (car lst))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (email (car (cdr lst)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (entry (read-string "Name to add to rolo: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (or name email))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (list (if (and email name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (string-match (concat "\\`" (regexp-quote entry)) name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (format rolo-email-format entry email) entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 current-prefix-arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (if (or (not (stringp name)) (string= name ""))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
289 (error "(rolo-add): Invalid name: '%s'" name))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (if (and (interactive-p) file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (setq file (completing-read "File to add to: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (mapcar 'list rolo-file-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (if (null file) (setq file (car rolo-file-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (cond ((and file (or (not (stringp file)) (string= file "")))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
295 (error "(rolo-add): Invalid file: '%s'" file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 ((and (file-exists-p file) (not (file-readable-p file)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
297 (error "(rolo-add): File not readable: '%s'" file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ((not (file-writable-p file))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
299 (error "(rolo-add): File not writable: '%s'" file)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (set-buffer (or (get-file-buffer file) (find-file-noselect file)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
301 (if (interactive-p) (message "Locating insertion point for '%s'..." name))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (let ((parent "") (level "") end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (widen) (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (while (setq end (string-match "/" name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (setq parent (substring name 0 end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 name (substring name (min (1+ end) (length name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (if (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (concat "\\(" rolo-entry-regexp "\\)[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (regexp-quote parent)) nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (setq level (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (match-end 1)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
312 (error "(rolo-add): '%s' category not found in \"%s\"."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 parent file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (narrow-to-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (progn (rolo-to-entry-end t level) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (let* ((len (length name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (name-level (concat level "*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (level-len (length name-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (entry "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (entry-spc "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (entry-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (again t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (while (and again
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (concat "\\(" rolo-entry-regexp "\\)\\([ \t]*\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 nil 'end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (setq entry-level (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (if (/= (length entry-level) level-len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (rolo-to-entry-end t entry-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (setq entry (buffer-substring (point) (+ (point) len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 entry-spc (buffer-substring (match-beginning 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (match-end 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (cond ((string< entry name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (rolo-to-entry-end t entry-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ((string< name entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (setq again nil) (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (t ;; found existing entry matching name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (setq again nil match t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (if match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (insert (or entry-level (concat level "*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (if (string= entry-spc "") " " entry-spc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 name "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (backward-char 1))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
349 (widen)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
350 (rolo-to-buffer (current-buffer))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
351 ;; Fixes non-display update bug when buf is on screen before
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
352 ;; interactive command invocation.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
353 (goto-char (point))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (message "Edit entry at point.")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (defun rolo-display-matches (&optional display-buf return-to-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 "Display optional DISPLAY-BUF buffer of previously found rolodex matches.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
360 If DISPLAY-BUF is nil, use the value in 'rolo-display-buffer'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 Second arg RETURN-TO-BUFFER is the buffer to leave point within after the display."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (or display-buf (setq display-buf (get-buffer rolo-display-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (if display-buf nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (error "(rolo-display-matches): Search the rolodex first."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ;; Save current window configuration if rolodex match buffer is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 ;; displayed in one of the windows already.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 ;; Handle both Emacs V18 and V19 versions of get-buffer-window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (get-buffer-window display-buf (selected-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (error (get-buffer-window display-buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (setq *rolo-wconfig* (current-window-configuration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (rolo-to-buffer display-buf t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (if (eq major-mode 'wrolo-mode) nil (wrolo-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (if (fboundp 'hproperty:but-create) (hproperty:but-create))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (rolo-shrink-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (run-hooks 'wrolo-display-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 ;; Leave point in match buffer unless a specific RETURN-TO-BUFFER has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ;; been specified. Use {q} to quit and restore display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (if return-to-buffer (rolo-to-buffer return-to-buffer t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (defun rolo-edit (&optional name file)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
389 "Edits a rolodex entry given by optional NAME within 'rolo-file-list'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 With prefix argument, prompts for optional FILE to locate entry within.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
391 With no NAME arg, simply displays FILE or first entry in 'rolo-file-list' in an
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 editable mode. NAME may be of the form: parent/child to edit child below a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 parent entry which begins with the parent string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (interactive "sName to edit in rolo: \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (if (string-equal name "") (setq name nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (and name (not (stringp name))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
397 (error "(rolo-edit): Invalid name: '%s'" name))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (if (and (interactive-p) current-prefix-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (if (= (length rolo-file-list) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (setq file (car rolo-file-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (setq file (completing-read "Entry's File: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (mapcar 'list rolo-file-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (let ((found-point) (file-list (if file (list file) rolo-file-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (or file (setq file (car file-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (if (null name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (progn (if (not (file-writable-p file))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
407 (error "(rolo-edit): File not writable: '%s'" file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (find-file-other-window file) (setq buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (if (setq found-point (rolo-to name file-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (setq file buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (if (file-writable-p file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (message
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
415 "(rolo-edit): Entry found but file not writable: '%s'" file)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (beep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (rolo-to-buffer (current-buffer)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
418 (message "(rolo-edit): '%s' not found." name)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (rolo-to-buffer (or (get-file-buffer (car file-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (find-file-noselect (car file-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (setq buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (widen)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
424 ;; Fixes display update bug in some Emacs versions. When buf is
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
425 ;; on screen before interactive command invocation, point is not
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
426 ;; moved to proper location.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
427 (if found-point (goto-char found-point)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (defun rolo-edit-entry ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 "Edit the source entry of the rolodex match buffer entry at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 Returns entry name if found, else nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (let ((name (rolo-name-at)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (if name (progn (rolo-edit name (hbut:key-src))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (defun rolo-fgrep (string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 &optional max-matches rolo-file count-only no-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 "Display rolodex entries matching STRING.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 To a maximum of optional prefix arg MAX-MATCHES, in file(s) from optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 ROLO-FILE or rolo-file-list. Default is to find all matching entries. Each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 entry is displayed with all of its sub-entries. Optional COUNT-ONLY non-nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 means don't retrieve and don't display matching entries. Optional NO-DISPLAY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 non-nil means retrieve entries but don't display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 Nil value of MAX-MATCHES means find all matches, t value means find all matches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 but omit file headers, negative values mean find up to the inverse of that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 number of entries and omit file headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 Returns number of entries matched. See also documentation for the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 rolo-file-list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (interactive "sRolodex string to match: \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (let ((total-matches (rolo-grep (regexp-quote string) max-matches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 rolo-file count-only no-display)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (message "%s matching entr%s found in rolodex."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (if (= total-matches 0) "No" total-matches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (if (= total-matches 1) "y" "ies")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 total-matches))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (defun rolo-grep (regexp &optional max-matches rolo-bufs count-only no-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 "Display rolodex entries matching REGEXP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 To a maximum of prefix arg MAX-MATCHES, in buffer(s) from optional ROLO-BUFS or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 rolo-file-list. Default is to find all matching entries. Each entry is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 displayed with all of its sub-entries. Optional COUNT-ONLY non-nil means don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 retrieve and don't display matching entries. Optional NO-DISPLAY non-nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 means retrieve entries but don't display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 Nil value of MAX-MATCHES means find all matches, t value means find all matches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 but omit file headers, negative values mean find up to the inverse of that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 number of entries and omit file headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 Returns number of entries matched. See also documentation for the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 rolo-file-list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (interactive "sRolodex regular expression to match: \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (let ((rolo-file-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (cond ((null rolo-bufs) rolo-file-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ((listp rolo-bufs) rolo-bufs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ((list rolo-bufs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (display-buf (if count-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (set-buffer (get-buffer-create rolo-display-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (total-matches 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (num-matched 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (inserting (or (eq max-matches t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (and (integerp max-matches) (< max-matches 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (if count-only nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (or inserting (erase-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (while (and (setq file (car rolo-file-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (or (not (integerp max-matches))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (< total-matches (max max-matches (- max-matches)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (setq rolo-file-list (cdr rolo-file-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 num-matched (rolo-grep-file file regexp max-matches count-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 total-matches (+ total-matches num-matched))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (if (integerp max-matches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (setq max-matches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (if (>= max-matches 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (- max-matches num-matched)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (+ max-matches num-matched)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (if (or count-only no-display inserting (= total-matches 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (rolo-display-matches display-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (message "%s matching entr%s found in rolodex."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (if (= total-matches 0) "No" total-matches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (if (= total-matches 1) "y" "ies")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 total-matches))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (defun rolo-isearch ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 "Interactively search forward for next occurrence of current match regexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 Use this to add characters to further narrow the search."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (if (equal (buffer-name) rolo-display-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (execute-kbd-macro (concat "\e\C-s" rolo-match-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (error "(rolo-isearch): Use this command in the %s match buffer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 rolo-display-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (defun rolo-kill (name &optional file)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
525 "Kills a rolodex entry given by NAME within 'rolo-file-list'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 With prefix argument, prompts for optional FILE to locate entry within.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 NAME may be of the form: parent/child to kill child below a parent entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 which begins with the parent string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 Returns t if entry is killed, nil otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (interactive "sName to kill in rolo: \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (if (or (not (stringp name)) (string= name ""))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
532 (error "(rolo-kill): Invalid name: '%s'" name))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (if (and (interactive-p) current-prefix-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (setq file (completing-read "Entry's File: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (mapcar 'list rolo-file-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (let ((file-list (if file (list file) rolo-file-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (killed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (or file (setq file (car file-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (if (rolo-to name file-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (setq file buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (if (file-writable-p file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (let ((kill-op
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (function (lambda (start level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (kill-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 start (rolo-to-entry-end t level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (setq killed t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (rolo-save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (rolo-kill-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 start end level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (re-search-backward rolo-entry-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (setq end (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (setq start (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 level (buffer-substring start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (let ((entry-line (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (min (+ (point) 60)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (progn (end-of-line) (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (if (y-or-n-p (format "Kill `%s...' " entry-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (funcall kill-op start level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (message "Killed"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (message "Aborted")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (funcall kill-op start level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (message
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
571 "(rolo-kill): Entry found but file not writable: '%s'" file)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (beep)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
573 (message "(rolo-kill): '%s' not found." name)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (beep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 killed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (defun rolo-mail-to ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 "Start composing mail addressed to the first e-mail address at or after point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (let ((opoint (point)) button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (skip-chars-backward "^ \t\n\r<>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (if (and (re-search-forward mail-address-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (goto-char (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (setq button (ibut:at-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (hui:hbut-act button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (message "(rolo-mail-to): Invalid buffer or no e-mail address found"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (defun rolo-next-match ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 "Move point forward to the start of the next rolodex search match."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (if (not (stringp rolo-match-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (error "(rolo-next-match): Invoke a rolodex search expression first"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (let ((start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (if (looking-at rolo-match-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (goto-char (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (if (re-search-forward rolo-match-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 "(rolo-next-match): No following matches for \"%s\"" rolo-match-regexp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (defun rolo-previous-match ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 "Move point back to the start of the previous rolodex search match."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (if (not (stringp rolo-match-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (error "(rolo-previous-match): Invoke a rolodex search expression first"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (if (re-search-backward rolo-match-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 "(rolo-previous-match): No prior matches for \"%s\"" rolo-match-regexp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (defun rolo-quit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 "Quit from the rolodex match buffer and restore the prior frame display."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (bury-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (if (and *rolo-wconfig*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (if (fboundp 'window-configuration-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (window-configuration-p *rolo-wconfig*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (set-window-configuration *rolo-wconfig*)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (defun rolo-sort (&optional rolo-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 "Sorts up to 14 levels of entries in ROLO-FILE (default is personal rolo).
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
629 Assumes entries are delimited by one or more '*'characters.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 Returns list of number of groupings at each entry level."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (list (let ((default "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (setq file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (format "Sort rolo file (default %s): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (file-name-nondirectory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (setq default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (if (and buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (memq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 t (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (lambda (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (equal buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (expand-file-name file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 rolo-file-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (car rolo-file-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (mapcar 'list rolo-file-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (if (string= file "") default file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (if (or (not rolo-file) (equal rolo-file ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (setq rolo-file (car rolo-file-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (if (not (and (stringp rolo-file) (file-readable-p rolo-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (error "(rolo-sort): Invalid or unreadable file: %s" rolo-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (let ((level-regexp (regexp-quote "**************"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (entries-per-level-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (while (not (equal level-regexp ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (setq n (rolo-sort-level rolo-file level-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (if (or (/= n 0) entries-per-level-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (setq entries-per-level-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (append (list n) entries-per-level-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (setq level-regexp (substring level-regexp 0 (- (length level-regexp) 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 entries-per-level-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (defun rolo-sort-level (rolo-file level-regexp &optional max-groupings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 "Sorts groupings of entries in ROLO-FILE at hierarchy level LEVEL-REGEXP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 To a maximum of optional MAX-GROUPINGS. Nil value of MAX-GROUPINGS means all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 groupings at the given level. LEVEL-REGEXP should simply match the text of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 any rolodex entry of the given level, not the beginning of a line (^); an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 example, might be (regexp-quote \"**\") to match level two. Returns number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 of groupings sorted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (interactive "sRolodex file to sort: \nRegexp for level's entries: \nP")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
674 (rolo-map-level
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
675 (function (lambda (start end) (sort-lines nil start end)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
676 rolo-file
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
677 level-regexp
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
678 max-groupings))
36
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 24
diff changeset
679
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (defun rolo-toggle-narrow-to-entry ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 "Toggle between display of current entry and display of all matched entries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 Useful when bound to a mouse key."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (if (rolo-narrowed-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (if (or (looking-at rolo-entry-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (re-search-backward rolo-entry-regexp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (progn (forward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (narrow-to-region (1- (point)) (rolo-display-to-entry-end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (rolo-shrink-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (goto-char (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (defun rolo-word (string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 &optional max-matches rolo-file count-only no-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 "Display rolodex entries with whole word matches for STRING.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 To a maximum of optional prefix arg MAX-MATCHES, in file(s) from optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 ROLO-FILE or rolo-file-list. Default is to find all matching entries. Each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 entry is displayed with all of its sub-entries. Optional COUNT-ONLY non-nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 means don't retrieve and don't display matching entries. Optional NO-DISPLAY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 non-nil means retrieve entries but don't display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 Nil value of MAX-MATCHES means find all matches, t value means find all matches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 but omit file headers, negative values mean find up to the inverse of that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 number of entries and omit file headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 Returns number of entries matched. See also documentation for the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 rolo-file-list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (interactive "sRolodex whole words to match: \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (let ((total-matches (rolo-grep (format "\\b%s\\b" (regexp-quote string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 max-matches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 rolo-file count-only no-display)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (message "%s matching entr%s found in rolodex."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (if (= total-matches 0) "No" total-matches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (if (= total-matches 1) "y" "ies")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 total-matches))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (defun rolo-yank (name &optional regexp-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 "Inserts at point the first rolodex entry matching NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 With optional prefix arg, REGEXP-P, treats NAME as a regular expression instead
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 of a string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (interactive "sName to insert record for: \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (let ((rolo-display-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (setq found (if regexp-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (rolo-grep name -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (rolo-grep (regexp-quote name) -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 ;; Let user reformat the region just yanked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (if (and (= found 1) (fboundp wrolo-yank-reformat-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (funcall wrolo-yank-reformat-function start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 ;;; Public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (defun rolo-fgrep-file (rolo-buf string &optional max-matches count-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 "Retrieve entries in ROLO-BUF matching STRING to a maximum of optional MAX-MATCHES.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 Nil value of MAX-MATCHES means find all matches, t value means find all matches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 but omit file headers, negative values mean find up to the inverse of that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 number of entries and omit file headers. Optional COUNT-ONLY non-nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 means don't retrieve matching entries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 Returns number of matching entries found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (rolo-grep-file rolo-buf (regexp-quote string) max-matches count-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (defun rolo-grep-file (rolo-buf regexp &optional max-matches count-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 "Retrieve entries in ROLO-BUF matching REGEXP to a maximum of optional MAX-MATCHES.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 Nil value of MAX-MATCHES means find all matches, t value means find all matches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 but omit file headers, negative values mean find up to the inverse of that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 number of entries and omit file headers. Optional COUNT-ONLY non-nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 means don't retrieve matching entries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 Returns number of matching entries found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 ;; Save regexp as last rolodex search expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (setq rolo-match-regexp regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (let ((new-buf-p) (actual-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (if (and (or (null max-matches) (eq max-matches t) (integerp max-matches))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (or (setq actual-buf (rolo-buffer-exists-p rolo-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (if (file-exists-p rolo-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (setq actual-buf (find-file-noselect rolo-buf t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 new-buf-p t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (let ((hdr-pos) (num-found 0) (curr-entry-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (incl-hdr t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (if max-matches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (cond ((eq max-matches t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (setq incl-hdr nil max-matches nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 ((< max-matches 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (setq incl-hdr nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 max-matches (- max-matches)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (set-buffer actual-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (if new-buf-p (setq buffer-read-only t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 ;; Ensure no entries in outline mode are hidden.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
781 ;; Uses 'show-all' function from outline.el.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (and (search-forward "\C-m" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (show-all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (if (re-search-forward rolo-hdr-regexp nil t 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (progn (forward-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (setq hdr-pos (cons (point-min) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (re-search-forward rolo-entry-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (while (and (or (null max-matches) (< num-found max-matches))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (re-search-forward regexp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (re-search-backward rolo-entry-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (let ((start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (next-entry-exists))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (re-search-forward rolo-entry-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (setq curr-entry-level (buffer-substring start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (rolo-to-entry-end t curr-entry-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (or count-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (if (and (= num-found 0) incl-hdr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (let* ((src (or (buffer-file-name actual-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 actual-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (src-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (concat (if (boundp 'hbut:source-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 hbut:source-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 "@loc> ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 "%s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (prin1-to-string src))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (set-buffer rolo-display-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (if hdr-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (insert-buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 actual-buf (car hdr-pos) (cdr hdr-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (insert src-line "\n\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (insert (format rolo-hdr-format src-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (set-buffer actual-buf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (setq num-found (1+ num-found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (or count-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (rolo-add-match rolo-display-buffer regexp start (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (rolo-kill-buffer actual-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 num-found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (defun rolo-map-level (func rolo-buf level-regexp &optional max-groupings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 "Perform FUNC on groupings of ROLO-BUF entries at level LEVEL-REGEXP,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 to a maximum of optional argument MAX-GROUPINGS. Nil value of MAX-GROUPINGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 means all groupings at the given level. FUNC should take two arguments, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 start and the end of the region that it should manipulate. LEVEL-REGEXP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 should simply match the text of any rolodex entry of the given level, not the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 beginning of a line (^); an example, might be (regexp-quote \"**\") to match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 level two. Returns number of groupings matched."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (let ((actual-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (if (and (or (null max-groupings) (< 0 max-groupings))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (or (setq actual-buf (rolo-buffer-exists-p rolo-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (if (file-exists-p rolo-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (progn (setq actual-buf (find-file-noselect rolo-buf t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (set-buffer actual-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (let ((num-found 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (exact-level-regexp (concat "^\\(" level-regexp "\\)[ \t\n]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (outline-regexp rolo-entry-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (level-len))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
844 ;; Load 'outline' library since its functions are used here.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (if (not (boundp 'outline-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (load-library "outline"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 ;; Pass buffer header if it exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (if (re-search-forward rolo-hdr-regexp nil t 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (forward-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (while (and (or (null max-groupings) (< num-found max-groupings))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (re-search-forward exact-level-regexp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (setq num-found (1+ num-found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (let* ((opoint (prog1 (point) (beginning-of-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (grouping-start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (start grouping-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (level-len (or level-len (- (1- opoint) start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (next-level-len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (next-entry-exists)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (grouping-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (no-subtree))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (while (and (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (if (setq next-entry-exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 rolo-entry-regexp nil t 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (setq next-level-len
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (- (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (progn (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 grouping-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (< next-level-len level-len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 no-subtree
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (<= next-level-len level-len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (setq grouping-end t no-subtree t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (goto-char (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (let ((end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (hide-subtree) ; And hide multiple entry lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 ;; Move to start of next entry at equal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 ;; or higher level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (setq start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (if no-subtree
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (if (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 rolo-entry-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (point-max))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
888 ;; Remember last expression in 'progn'
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 ;; must always return non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (goto-char start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (not grouping-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (let ((end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (goto-char grouping-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (funcall func grouping-start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (goto-char end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (show-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (rolo-kill-buffer actual-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 num-found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 ;;; Private functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (defun rolo-add-match (rolo-matches-buffer regexp start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 "Insert before point in ROLO-MATCHES-BUFFER an entry matching REGEXP from the current region between START to END."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (let ((rolo-buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (set-buffer (get-buffer-create rolo-matches-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (setq opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (insert-buffer-substring rolo-buf start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (rolo-highlight-matches regexp opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (set-buffer rolo-buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (defun rolo-buffer-exists-p (rolo-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 "Returns buffer given by ROLO-BUF or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 ROLO-BUF may be a file-name, buffer-name, or buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (car (memq (get-buffer (or (and (stringp rolo-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (get-file-buffer rolo-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 rolo-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (buffer-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (defun rolo-display-to-entry-end ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 "Go to end of current entry, ignoring sub-entries."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (if (re-search-forward (concat rolo-hdr-regexp "\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 rolo-entry-regexp) nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (goto-char (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (defun rolo-format-name (name-str first last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 "Reverse order of NAME-STR field given my regexp match field FIRST and LAST."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (if (match-beginning last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (concat (substring name-str (match-beginning last) (match-end last))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 ", "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (substring name-str (match-beginning first) (match-end first)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (defun rolo-highlight-matches (regexp start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 "Highlight matches for REGEXP in region from START to END."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (if (fboundp 'hproperty:but-add)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (let ((hproperty:but-emphasize-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (while (re-search-forward regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (hproperty:but-add (match-beginning 0) (match-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (or rolo-highlight-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 hproperty:highlight-face)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (defun rolo-kill-buffer (&optional rolo-buf)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
950 "Kills optional ROLO-BUF if unchanged and 'rolo-kill-buffers-after-use' is t.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 Default is current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (or rolo-buf (setq rolo-buf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (and rolo-kill-buffers-after-use (not (buffer-modified-p rolo-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (kill-buffer rolo-buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (defun rolo-name-and-email ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 "If point is in a mail message, returns list of (name email-addr) of sender.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
958 Name is returned as 'last, first-and-middle'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (let ((email) (name) (from))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (if (or (hmail:lister-p) (hnews:lister-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (other-window 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (if (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (narrow-to-region (point-min) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (setq email (mail-fetch-field "reply-to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 from (mail-fetch-field "from")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (if from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 ;; Match: email, email (name), email "name"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 ((string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (concat "^\\([^\"<>() \t\n]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 "\\([ \t]*[(\"][ \t]*\\([^\"()]+\\)[ \t]+"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 "\\([^\" \t()]+\\)[ \t]*[)\"]\\)?[ \t]*$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (setq name (rolo-format-name from 3 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (or email (setq email (substring from (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (match-end 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 ;; Match: <email>, name <email>, "name" <email>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 ((string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (concat "^\\(\"?\\([^\"<>()\n]+\\)[ \t]+"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 "\\([^\" \t()<>]+\\)\"?[ \t]+\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 "<\\([^\"<>() \t\n]+\\)>[ \t]*$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (setq name (rolo-format-name from 2 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (or email (setq email (substring from (match-beginning 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (match-end 4)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (if (or name email)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (list name email))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (defun rolo-name-at ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
994 "If point is within an entry in 'rolo-display-buffer', returns entry, else nil."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (if (string-equal (buffer-name) rolo-display-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (if (or (looking-at rolo-entry-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (progn (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (re-search-backward rolo-entry-regexp nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (progn (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (if (or (looking-at "[^ \t\n\^M]+ ?, ?[^ \t\n\^M]+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (looking-at "\\( ?[^ \t\n\^M]+\\)+"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (match-end 0))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (defun rolo-narrowed-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (or (/= (point-min) 1) (/= (1+ (buffer-size)) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (defun rolo-save-buffer (&optional rolo-buf)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
1011 "Saves optional ROLO-BUF if changed and 'rolo-save-buffers-after-use' is t.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 Default is current buffer. Used, for example, after a rolo entry is killed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (or rolo-buf (setq rolo-buf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (and rolo-save-buffers-after-use (buffer-modified-p rolo-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (set-buffer rolo-buf) (save-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (defun rolo-shrink-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (let* ((lines (count-lines (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (height (window-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (window-min-height 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (desired-shrinkage (1- (min (- height lines)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (and (>= lines 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (/= desired-shrinkage 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (> (frame-height) (1+ height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (shrink-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (if (< desired-shrinkage 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (max desired-shrinkage (- height (/ (frame-height) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (min desired-shrinkage (- height window-min-height)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (defun rolo-to (name &optional file-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 "Moves point to entry for NAME within optional FILE-LIST.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
1032 'rolo-file-list' is used as default when FILE-LIST is nil.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 Leaves point immediately after match for NAME within entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 Switches internal current buffer but does not alter the frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 Returns point where matching entry begins or nil if not found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (or file-list (setq file-list rolo-file-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (let ((found) file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (while (and (not found) file-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (setq file (car file-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 file-list (cdr file-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (cond ((and file (or (not (stringp file)) (string= file "")))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
1042 (error "(rolo-to): Invalid file: '%s'" file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 ((and (file-exists-p file) (not (file-readable-p file)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
1044 (error "(rolo-to): File not readable: '%s'" file)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (set-buffer (or (get-file-buffer file) (find-file-noselect file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (let ((case-fold-search t) (real-name name) (parent "") (level) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (widen) (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (while (setq end (string-match "/" name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (setq level nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 parent (substring name 0 end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 name (substring name (min (1+ end) (length name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (cond ((progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (while (and (not level) (search-forward parent nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (if (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (concat "\\(" rolo-entry-regexp "\\)[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (regexp-quote parent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (setq level (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (match-end 1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 ((equal name real-name));; Try next file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (t;; Found parent but not child
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (rolo-to-buffer (current-buffer))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
1066 (error "(rolo-to): '%s' part of name not found in \"%s\"."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 parent file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 (if level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 (narrow-to-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (rolo-to-entry-end t level) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (while (and (search-forward name nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (not (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (setq found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (if (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (concat "\\(" rolo-entry-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 "\\)[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (regexp-quote name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (point))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (or found (rolo-kill-buffer))) ;; conditionally kill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (defun rolo-to-buffer (buffer &optional other-window-flag frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 "Pop to BUFFER."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (cond (hyperb:lemacs-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (pop-to-buffer buffer other-window-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 ;; default is to use selected frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (or frame (selected-frame))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (t (pop-to-buffer buffer other-window-flag))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (defun rolo-to-entry-end (&optional include-sub-entries curr-entry-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 "Goes to end of whole entry if optional INCLUDE-SUB-ENTRIES is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 CURR-ENTRY-LEVEL is a string whose length is the same as the last found entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 header. If INCLUDE-SUB-ENTRIES is nil, CURR-ENTRY-LEVEL is not needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 Returns current point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (while (and (setq next-entry-exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (re-search-forward rolo-entry-regexp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 include-sub-entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (> (- (point) (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (length curr-entry-level))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 (if next-entry-exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (goto-char (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (defun wrolo-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 "Major mode for the rolodex match buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 Calls the functions given by `wrolo-mode-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 \\{wrolo-mode-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 (setq major-mode 'wrolo-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 mode-name "Rolodex")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 (use-local-map wrolo-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 ;; Loads menus under non-tty InfoDock, XEmacs or Emacs19; does nothing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 ;; otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 (and (not (featurep 'wrolo-menu)) hyperb:window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (or hyperb:lemacs-p hyperb:emacs19-p) (require 'wrolo-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (if (not (fboundp 'outline-minor-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (outline-minor-mode 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (run-hooks 'wrolo-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 ;;; Private variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (defvar rolo-display-buffer "*Rolodex*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 "Buffer used to display set of last matching rolodex entries.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (defvar rolo-entry-regexp "^\\*+"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 "Regular expression to match the beginning of a rolodex entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 This pattern must match the beginning of the line. Entries may be nested
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 through the use of increasingly longer beginning patterns.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (defconst rolo-hdr-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 "======================================================================\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 "%s\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 "======================================================================\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 "Header to insert preceding a file's first rolodex entry match when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 file has none of its own. Used with one argument, the file name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (defconst rolo-hdr-regexp "^==="
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 "Regular expression to match the first and last lines of rolodex file headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 This header is inserted into rolo-display-buffer before any entries from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 file are added.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (defconst rolo-match-regexp nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 "Last regular expression used to search the rolodex.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 Nil before a search is done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 String search expressions are converted to regular expressions.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (defvar *rolo-wconfig* nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 "Saves frame's window configuration prior to a rolodex search.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (defvar wrolo-mode-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 "Keymap for the rolodex match buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (if wrolo-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 (setq wrolo-mode-map (make-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (if (fboundp 'set-keymap-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (set-keymap-name wrolo-mode-map 'wrolo-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (suppress-keymap wrolo-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (define-key wrolo-mode-map "<" 'beginning-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (define-key wrolo-mode-map ">" 'end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 (define-key wrolo-mode-map "." 'beginning-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 (define-key wrolo-mode-map "," 'end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (define-key wrolo-mode-map "?" 'describe-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (define-key wrolo-mode-map "\177" 'scroll-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 (define-key wrolo-mode-map " " 'scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (define-key wrolo-mode-map "a" 'show-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (define-key wrolo-mode-map "b" 'outline-backward-same-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (define-key wrolo-mode-map "e" 'rolo-edit-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (define-key wrolo-mode-map "f" 'outline-forward-same-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (define-key wrolo-mode-map "h" 'hide-subtree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (define-key wrolo-mode-map "m" 'rolo-mail-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (define-key wrolo-mode-map "n" 'outline-next-visible-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (define-key wrolo-mode-map "p" 'outline-previous-visible-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (define-key wrolo-mode-map "q" 'rolo-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 (define-key wrolo-mode-map "r" 'rolo-previous-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (define-key wrolo-mode-map "s" 'show-subtree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (define-key wrolo-mode-map "\M-s" 'rolo-isearch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (define-key wrolo-mode-map "t" 'hide-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (define-key wrolo-mode-map "\C-i" 'rolo-next-match) ;; {TAB}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (define-key wrolo-mode-map "\M-\C-i" 'rolo-previous-match) ;; {M-TAB}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (define-key wrolo-mode-map "u" 'outline-up-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (provide 'wrolo)