annotate lisp/hyperbole/wrolo.el @ 35:279432d5c479

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