annotate lisp/hyperbole/wrolo.el @ 114:8619ce7e4c50 r20-1b9

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