Mercurial > emacs
annotate lisp/finder.el @ 3523:a9967fc643c5
[HAVE_TZNAME]: Declare tzname if not macro.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 06 Jun 1993 17:44:23 +0000 |
parents | 99d147f614f5 |
children | e2cbba9f0ea3 |
rev | line source |
---|---|
867 | 1 ;;; finder.el --- topic & keyword-based code finder |
2 | |
3 ;; Copyright (C) 1992 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com> | |
6 ;; Created: 16 Jun 1992 | |
7 ;; Version: 1.0 | |
8 ;; Keywords: help | |
9 | |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 1, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
24 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
25 | |
2527
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
26 ;;; Commentary: |
867 | 27 |
28 ;; This mode uses the Keywords library header to provide code-finding | |
29 ;; services by keyword. | |
30 ;; | |
31 ;; Things to do: | |
32 ;; 1. Support multiple keywords per search. This could be extremely hairy; | |
33 ;; there doesn't seem to be any way to get completing-read to exit on | |
34 ;; an EOL with no substring pending, which is what we'd want to end the loop. | |
35 ;; 2. Search by string in synopsis line? | |
36 ;; 3. Function to check finder-package-info for unknown keywords. | |
37 | |
38 ;;; Code: | |
39 | |
40 (require 'lisp-mnt) | |
41 (require 'finder-inf) | |
42 (require 'picture) | |
43 | |
2996
358fe58ae153
(finder-known-keywords): Use i18n, not i14n.
Richard M. Stallman <rms@gnu.org>
parents:
2716
diff
changeset
|
44 ;; Local variable in finder buffer. |
358fe58ae153
(finder-known-keywords): Use i18n, not i14n.
Richard M. Stallman <rms@gnu.org>
parents:
2716
diff
changeset
|
45 (defvar finder-headmark) |
358fe58ae153
(finder-known-keywords): Use i18n, not i14n.
Richard M. Stallman <rms@gnu.org>
parents:
2716
diff
changeset
|
46 |
867 | 47 (defvar finder-known-keywords |
48 '( | |
2270 | 49 (abbrev . "abbreviation handling, typing shortcuts, macros") |
867 | 50 (bib . "code related to the bib(1) bibliography processor") |
51 (c . "C and C++ language support") | |
52 (calendar . "calendar and time management support") | |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2228
diff
changeset
|
53 (comm . "communications, networking, remote access to files") |
867 | 54 (docs . "support for Emacs documentation") |
55 (emulations . "emulations of other editors") | |
56 (extensions . "Emacs Lisp language extensions") | |
57 (games . "games, jokes and amusements") | |
58 (hardware . "support for interfacing with exotic hardware") | |
59 (help . "support for on-line help systems") | |
2996
358fe58ae153
(finder-known-keywords): Use i18n, not i14n.
Richard M. Stallman <rms@gnu.org>
parents:
2716
diff
changeset
|
60 (i18n . "internationalization and alternate character-set support") |
867 | 61 (internal . "code for Emacs internals, build process, defaults") |
62 (languages . "specialized modes for editing programming languages") | |
63 (lisp . "Lisp support, including Emacs Lisp") | |
64 (local . "code local to your site") | |
65 (maint . "maintenance aids for the Emacs development group") | |
66 (mail . "modes for electronic-mail handling") | |
67 (news . "support for netnews reading and posting") | |
68 (processes . "process, subshell, compilation, and job control support") | |
69 (terminals . "support for terminal types") | |
70 (tex . "code related to the TeX formatter") | |
71 (tools . "programming tools") | |
72 (unix . "front-ends/assistants for, or emulators of, UNIX features") | |
73 (vms . "support code for vms") | |
74 (wp . "word processing") | |
75 )) | |
76 | |
2527
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
77 (defvar finder-mode-map nil) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
78 ;(if finder-mode-map |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
79 ; nil |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
80 (setq finder-mode-map (make-sparse-keymap)) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
81 (define-key finder-mode-map " " 'finder-select) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
82 (define-key finder-mode-map "?" 'finder-summary) |
2716
acd678e58602
* finder.el: Bind finder-exit to 'q', not 'x'; the former is the
Jim Blandy <jimb@redhat.com>
parents:
2527
diff
changeset
|
83 (define-key finder-mode-map "q" 'finder-exit) |
2527
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
84 (define-key finder-mode-map "f" 'finder-list-keywords) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
85 ; ) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
86 |
867 | 87 ;;; Code for regenerating the keyword list. |
88 | |
89 (defvar finder-package-info nil | |
90 "Assoc list mapping file names to description & keyword lists.") | |
91 | |
92 (defun finder-compile-keywords (&rest dirs) | |
2996
358fe58ae153
(finder-known-keywords): Use i18n, not i14n.
Richard M. Stallman <rms@gnu.org>
parents:
2716
diff
changeset
|
93 "Regenerate the keywords association list into the file `finder-inf.el'. |
867 | 94 Optional arguments are a list of Emacs Lisp directories to compile from; no |
1475 | 95 arguments compiles from `load-path'." |
867 | 96 (save-excursion |
2228
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
97 (let ((processed nil)) |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
98 (find-file "finder-inf.el") |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
99 (erase-buffer) |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2228
diff
changeset
|
100 (insert ";;; finder-inf.el --- keyword-to-package mapping\n") |
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2228
diff
changeset
|
101 (insert ";; Keywords: help\n") |
2457
3d2f74e16e54
Added or corrected documentation headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2271
diff
changeset
|
102 (insert ";;; Commentary:\n") |
3d2f74e16e54
Added or corrected documentation headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2271
diff
changeset
|
103 (insert ";; Don't edit this file. It's generated by finder.el\n\n") |
3d2f74e16e54
Added or corrected documentation headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2271
diff
changeset
|
104 (insert ";;; Code:\n") |
2228
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
105 (insert "\n(setq finder-package-info '(\n") |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
106 (mapcar |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
107 (function |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
108 (lambda (d) |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
109 (mapcar |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
110 (function |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
111 (lambda (f) |
2996
358fe58ae153
(finder-known-keywords): Use i18n, not i14n.
Richard M. Stallman <rms@gnu.org>
parents:
2716
diff
changeset
|
112 (if (and (string-match "^[^=].*\\.el$" f) |
358fe58ae153
(finder-known-keywords): Use i18n, not i14n.
Richard M. Stallman <rms@gnu.org>
parents:
2716
diff
changeset
|
113 (not (member f processed))) |
358fe58ae153
(finder-known-keywords): Use i18n, not i14n.
Richard M. Stallman <rms@gnu.org>
parents:
2716
diff
changeset
|
114 (let (summary keystart keywords) |
2228
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
115 (setq processed (cons f processed)) |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
116 (save-excursion |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
117 (set-buffer (get-buffer-create "*finder-scratch*")) |
2996
358fe58ae153
(finder-known-keywords): Use i18n, not i14n.
Richard M. Stallman <rms@gnu.org>
parents:
2716
diff
changeset
|
118 (buffer-disable-undo (current-buffer)) |
2228
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
119 (erase-buffer) |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
120 (insert-file-contents |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
121 (concat (file-name-as-directory (or d ".")) f)) |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
122 (setq summary (lm-synopsis)) |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
123 (setq keywords (lm-keywords))) |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
124 (insert |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
125 (format " (\"%s\"\n " f)) |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
126 (prin1 summary (current-buffer)) |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
127 (insert |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
128 "\n ") |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
129 (setq keystart (point)) |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
130 (insert |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
131 (if keywords (format "(%s)" keywords) "nil") |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
132 ")\n") |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
133 (subst-char-in-region keystart (point) ?, ? ) |
3013
99d147f614f5
* case-table.el, disp-table.el, finder.el, iso-ascii.el,
Jim Blandy <jimb@redhat.com>
parents:
2996
diff
changeset
|
134 ) |
2228
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
135 ))) |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
136 (directory-files (or d "."))) |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
137 )) |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
138 (or dirs load-path)) |
2457
3d2f74e16e54
Added or corrected documentation headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2271
diff
changeset
|
139 (insert "))\n\n(provide 'finder-inf)\n\n;;; finder-inf.el ends here\n") |
2228
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
140 (kill-buffer "*finder-scratch*") |
2271
026941de1886
Make sure that when new keywords are compiled, we see them
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2270
diff
changeset
|
141 (eval-current-buffer) ;; So we get the new keyword list immediately |
2228
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
142 (basic-save-buffer) |
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
143 ))) |
867 | 144 |
145 ;;; Now the retrieval code | |
146 | |
2527
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
147 (defun finder-list-keywords () |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
148 "Display descriptions of the keywords in the Finder buffer." |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
149 (interactive) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
150 (setq buffer-read-only nil) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
151 (erase-buffer) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
152 (mapcar |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
153 (function (lambda (assoc) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
154 (let ((keyword (car assoc))) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
155 (insert (symbol-name keyword)) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
156 (insert-at-column 14 (concat (cdr assoc) "\n")) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
157 (cons (symbol-name keyword) keyword)))) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
158 finder-known-keywords) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
159 (goto-char (point-min)) |
2996
358fe58ae153
(finder-known-keywords): Use i18n, not i14n.
Richard M. Stallman <rms@gnu.org>
parents:
2716
diff
changeset
|
160 (setq finder-headmark (point)) |
2527
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
161 (setq buffer-read-only t) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
162 (set-buffer-modified-p nil) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
163 (balance-windows) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
164 (finder-summary)) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
165 |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
166 (defun finder-list-matches (key) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
167 (setq buffer-read-only nil) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
168 (erase-buffer) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
169 (let ((id (intern key))) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
170 (insert |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
171 "The following packages match the keyword `" key "':\n\n") |
2996
358fe58ae153
(finder-known-keywords): Use i18n, not i14n.
Richard M. Stallman <rms@gnu.org>
parents:
2716
diff
changeset
|
172 (setq finder-headmark (point)) |
2527
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
173 (mapcar |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
174 (function (lambda (x) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
175 (if (memq id (car (cdr (cdr x)))) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
176 (progn |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
177 (insert (car x)) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
178 (insert-at-column 16 |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
179 (concat (car (cdr x)) "\n")) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
180 )) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
181 )) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
182 finder-package-info) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
183 (goto-char (point-min)) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
184 (forward-line) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
185 (setq buffer-read-only t) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
186 (set-buffer-modified-p nil) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
187 (shrink-window-if-larger-than-buffer) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
188 (finder-summary))) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
189 |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
190 (defun finder-commentary (file) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
191 (interactive) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
192 (let* ((str (lm-commentary file))) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
193 (if (null str) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
194 (error "Can't find any Commentary section.")) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
195 (pop-to-buffer "*Finder*") |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
196 (setq buffer-read-only nil) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
197 (erase-buffer) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
198 (insert str) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
199 (goto-char (point-min)) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
200 (delete-blank-lines) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
201 (goto-char (point-max)) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
202 (delete-blank-lines) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
203 (goto-char (point-min)) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
204 (while (re-search-forward "^;+ ?" nil t) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
205 (replace-match "" nil nil)) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
206 (goto-char (point-min)) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
207 (setq buffer-read-only t) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
208 (set-buffer-modified-p nil) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
209 (shrink-window-if-larger-than-buffer) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
210 (finder-summary) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
211 )) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
212 |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
213 (defun finder-current-item () |
2996
358fe58ae153
(finder-known-keywords): Use i18n, not i14n.
Richard M. Stallman <rms@gnu.org>
parents:
2716
diff
changeset
|
214 (if (and finder-headmark (< (point) finder-headmark)) |
2527
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
215 (error "No keyword or filename on this line") |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
216 (save-excursion |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
217 (beginning-of-line) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
218 (current-word)))) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
219 |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
220 (defun finder-select () |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
221 (interactive) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
222 (let ((key (finder-current-item))) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
223 (if (string-match "\\.el$" key) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
224 (finder-commentary key) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
225 (finder-list-matches key)))) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
226 |
867 | 227 (defun finder-by-keyword () |
228 "Find packages matching a given keyword." | |
229 (interactive) | |
2527
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
230 (finder-mode) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
231 (finder-list-keywords)) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
232 |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
233 (defun finder-mode () |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
234 "Major mode for browsing package documentation. |
2716
acd678e58602
* finder.el: Bind finder-exit to 'q', not 'x'; the former is the
Jim Blandy <jimb@redhat.com>
parents:
2527
diff
changeset
|
235 \\<finder-mode-map> |
2527
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
236 \\[finder-select] more help for the item on the current line |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
237 \\[finder-exit] exit Finder mode and fill the Finder buffer. |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
238 " |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
239 (interactive) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
240 (pop-to-buffer "*Finder*") |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
241 (setq buffer-read-only nil) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
242 (erase-buffer) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
243 (use-local-map finder-mode-map) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
244 (set-syntax-table emacs-lisp-mode-syntax-table) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
245 (setq mode-name "Finder") |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
246 (setq major-mode 'finder-mode) |
2996
358fe58ae153
(finder-known-keywords): Use i18n, not i14n.
Richard M. Stallman <rms@gnu.org>
parents:
2716
diff
changeset
|
247 (make-local-variable 'finder-headmark) |
358fe58ae153
(finder-known-keywords): Use i18n, not i14n.
Richard M. Stallman <rms@gnu.org>
parents:
2716
diff
changeset
|
248 (setq finder-headmark nil) |
2527
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
249 ) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
250 |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
251 (defun finder-summary () |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
252 "Summarize basic Finder commands." |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
253 (interactive) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
254 (message |
2716
acd678e58602
* finder.el: Bind finder-exit to 'q', not 'x'; the former is the
Jim Blandy <jimb@redhat.com>
parents:
2527
diff
changeset
|
255 (substitute-command-keys |
acd678e58602
* finder.el: Bind finder-exit to 'q', not 'x'; the former is the
Jim Blandy <jimb@redhat.com>
parents:
2527
diff
changeset
|
256 "\\<finder-mode-map>\\[finder-select] = select, \\[finder-list-keywords] = back to finder, \\[finder-exit] = quit, \\[finder-summary] = help"))) |
2527
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
257 |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
258 (defun finder-exit () |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
259 "Exit Finder mode and kill the buffer" |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
260 (interactive) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
261 (delete-window) |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
262 (kill-buffer "*Finder*")) |
867 | 263 |
264 (provide 'finder) | |
265 | |
266 ;;; finder.el ends here |