Mercurial > emacs
annotate lisp/finder.el @ 21763:b685f9451792
(change_frame_size_1): Use FRAME_CURSOR_X_LIMIT.
(update_frame): Likewise.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 25 Apr 1998 23:08:09 +0000 |
parents | bc7f520d8251 |
children | aafa93c1a5ce |
rev | line source |
---|---|
867 | 1 ;;; finder.el --- topic & keyword-based code finder |
2 | |
20009
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
3 ;; Copyright (C) 1992, 1997 Free Software Foundation, Inc. |
867 | 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 | |
12244 | 14 ;; the Free Software Foundation; either version 2, or (at your option) |
867 | 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 | |
14169 | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
867 | 26 |
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
|
27 ;;; Commentary: |
867 | 28 |
29 ;; This mode uses the Keywords library header to provide code-finding | |
30 ;; services by keyword. | |
31 ;; | |
32 ;; Things to do: | |
33 ;; 1. Support multiple keywords per search. This could be extremely hairy; | |
34 ;; there doesn't seem to be any way to get completing-read to exit on | |
35 ;; an EOL with no substring pending, which is what we'd want to end the loop. | |
36 ;; 2. Search by string in synopsis line? | |
37 ;; 3. Function to check finder-package-info for unknown keywords. | |
38 | |
39 ;;; Code: | |
40 | |
41 (require 'lisp-mnt) | |
42 (require 'finder-inf) | |
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") |
5141
3efae588d663
(finder-known-keywords): Add data, faces, mouse, matching.
Richard M. Stallman <rms@gnu.org>
parents:
3708
diff
changeset
|
50 (bib . "code related to the `bib' bibliography processor") |
11470
2958364d4d99
(finder-known-keywords): Generalize `c' keyword.
Richard M. Stallman <rms@gnu.org>
parents:
11454
diff
changeset
|
51 (c . "support for the C language and related languages") |
867 | 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") |
5141
3efae588d663
(finder-known-keywords): Add data, faces, mouse, matching.
Richard M. Stallman <rms@gnu.org>
parents:
3708
diff
changeset
|
54 (data . "support editing files of data") |
867 | 55 (docs . "support for Emacs documentation") |
56 (emulations . "emulations of other editors") | |
57 (extensions . "Emacs Lisp language extensions") | |
5141
3efae588d663
(finder-known-keywords): Add data, faces, mouse, matching.
Richard M. Stallman <rms@gnu.org>
parents:
3708
diff
changeset
|
58 (faces . "support for multiple fonts") |
11454
d9ec5322d181
(finder-known-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
9200
diff
changeset
|
59 (frames . "support for Emacs frames and window systems") |
867 | 60 (games . "games, jokes and amusements") |
61 (hardware . "support for interfacing with exotic hardware") | |
62 (help . "support for on-line help systems") | |
11454
d9ec5322d181
(finder-known-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
9200
diff
changeset
|
63 (hypermedia . "support for links between text or other media types") |
2996
358fe58ae153
(finder-known-keywords): Use i18n, not i14n.
Richard M. Stallman <rms@gnu.org>
parents:
2716
diff
changeset
|
64 (i18n . "internationalization and alternate character-set support") |
867 | 65 (internal . "code for Emacs internals, build process, defaults") |
66 (languages . "specialized modes for editing programming languages") | |
67 (lisp . "Lisp support, including Emacs Lisp") | |
68 (local . "code local to your site") | |
69 (maint . "maintenance aids for the Emacs development group") | |
70 (mail . "modes for electronic-mail handling") | |
5141
3efae588d663
(finder-known-keywords): Add data, faces, mouse, matching.
Richard M. Stallman <rms@gnu.org>
parents:
3708
diff
changeset
|
71 (matching . "various sorts of searching and matching") |
3efae588d663
(finder-known-keywords): Add data, faces, mouse, matching.
Richard M. Stallman <rms@gnu.org>
parents:
3708
diff
changeset
|
72 (mouse . "mouse support") |
867 | 73 (news . "support for netnews reading and posting") |
11454
d9ec5322d181
(finder-known-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
9200
diff
changeset
|
74 (oop . "support for object-oriented programming") |
d9ec5322d181
(finder-known-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
9200
diff
changeset
|
75 (outlines . "support for hierarchical outlining") |
867 | 76 (processes . "process, subshell, compilation, and job control support") |
77 (terminals . "support for terminal types") | |
78 (tex . "code related to the TeX formatter") | |
79 (tools . "programming tools") | |
80 (unix . "front-ends/assistants for, or emulators of, UNIX features") | |
81 (vms . "support code for vms") | |
82 (wp . "word processing") | |
83 )) | |
84 | |
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
|
85 (defvar finder-mode-map nil) |
9200
e48652e64736
(finder-mode-map): Change key bindings:
Richard M. Stallman <rms@gnu.org>
parents:
7943
diff
changeset
|
86 (or finder-mode-map |
e48652e64736
(finder-mode-map): Change key bindings:
Richard M. Stallman <rms@gnu.org>
parents:
7943
diff
changeset
|
87 (let ((map (make-sparse-keymap))) |
e48652e64736
(finder-mode-map): Change key bindings:
Richard M. Stallman <rms@gnu.org>
parents:
7943
diff
changeset
|
88 (define-key map " " 'finder-select) |
e48652e64736
(finder-mode-map): Change key bindings:
Richard M. Stallman <rms@gnu.org>
parents:
7943
diff
changeset
|
89 (define-key map "f" 'finder-select) |
20009
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
90 (define-key map [mouse-2] 'finder-mouse-select) |
9200
e48652e64736
(finder-mode-map): Change key bindings:
Richard M. Stallman <rms@gnu.org>
parents:
7943
diff
changeset
|
91 (define-key map "\C-m" 'finder-select) |
e48652e64736
(finder-mode-map): Change key bindings:
Richard M. Stallman <rms@gnu.org>
parents:
7943
diff
changeset
|
92 (define-key map "?" 'finder-summary) |
e48652e64736
(finder-mode-map): Change key bindings:
Richard M. Stallman <rms@gnu.org>
parents:
7943
diff
changeset
|
93 (define-key map "q" 'finder-exit) |
e48652e64736
(finder-mode-map): Change key bindings:
Richard M. Stallman <rms@gnu.org>
parents:
7943
diff
changeset
|
94 (define-key map "d" 'finder-list-keywords) |
e48652e64736
(finder-mode-map): Change key bindings:
Richard M. Stallman <rms@gnu.org>
parents:
7943
diff
changeset
|
95 (setq finder-mode-map map))) |
e48652e64736
(finder-mode-map): Change key bindings:
Richard M. Stallman <rms@gnu.org>
parents:
7943
diff
changeset
|
96 |
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
|
97 |
867 | 98 ;;; Code for regenerating the keyword list. |
99 | |
100 (defvar finder-package-info nil | |
101 "Assoc list mapping file names to description & keyword lists.") | |
102 | |
103 (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
|
104 "Regenerate the keywords association list into the file `finder-inf.el'. |
867 | 105 Optional arguments are a list of Emacs Lisp directories to compile from; no |
1475 | 106 arguments compiles from `load-path'." |
867 | 107 (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
|
108 (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
|
109 (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
|
110 (erase-buffer) |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2228
diff
changeset
|
111 (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
|
112 (insert ";; Keywords: help\n") |
2457
3d2f74e16e54
Added or corrected documentation headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2271
diff
changeset
|
113 (insert ";;; Commentary:\n") |
3d2f74e16e54
Added or corrected documentation headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2271
diff
changeset
|
114 (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
|
115 (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
|
116 (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
|
117 (mapcar |
14599 | 118 (lambda (d) |
21758
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
119 (when (file-exists-p (directory-file-name d)) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
120 (message "Directory %s" d) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
121 (mapcar |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
122 (lambda (f) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
123 (if (and (or (string-match "^[^=].*\\.el$" f) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
124 ;; Allow compressed files also. Fixme: |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
125 ;; generalize this, especially for |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
126 ;; MS-DOG-type filenames. |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
127 (and (string-match "^[^=].*\\.el\\.\\(gz\\|Z\\)$" f) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
128 (require 'jka-compr))) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
129 ;; Ignore lock files. |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
130 (not (string-match "^.#" f)) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
131 (not (member f processed))) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
132 (let (summary keystart keywords) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
133 (setq processed (cons f processed)) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
134 (save-excursion |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
135 (set-buffer (get-buffer-create "*finder-scratch*")) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
136 (buffer-disable-undo (current-buffer)) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
137 (erase-buffer) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
138 (insert-file-contents |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
139 (concat (file-name-as-directory (or d ".")) f)) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
140 (setq summary (lm-synopsis)) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
141 (setq keywords (lm-keywords))) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
142 (insert |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
143 (format " (\"%s\"\n " |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
144 (if (string-match "\\.\\(gz\\|Z\\)$" f) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
145 (file-name-sans-extension f) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
146 f))) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
147 (prin1 summary (current-buffer)) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
148 (insert |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
149 "\n ") |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
150 (setq keystart (point)) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
151 (insert |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
152 (if keywords (format "(%s)" keywords) "nil") |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
153 ")\n") |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
154 (subst-char-in-region keystart (point) ?, ? ) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
155 ))) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
156 (directory-files (or d "."))))) |
2228
d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1475
diff
changeset
|
157 (or dirs load-path)) |
2457
3d2f74e16e54
Added or corrected documentation headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2271
diff
changeset
|
158 (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
|
159 (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
|
160 (eval-current-buffer) ;; So we get the new keyword list immediately |
14599 | 161 (basic-save-buffer)))) |
867 | 162 |
14669
6feeb4e59815
(finder-compile-keywords-make-dist): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14599
diff
changeset
|
163 (defun finder-compile-keywords-make-dist () |
6feeb4e59815
(finder-compile-keywords-make-dist): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14599
diff
changeset
|
164 "Regenerate `finder-inf.el' for the Emacs distribution." |
17745
ae0f1e4a63be
(finder-compile-keywords-make-dist):
Richard M. Stallman <rms@gnu.org>
parents:
14669
diff
changeset
|
165 (apply 'finder-compile-keywords command-line-args-left) |
ae0f1e4a63be
(finder-compile-keywords-make-dist):
Richard M. Stallman <rms@gnu.org>
parents:
14669
diff
changeset
|
166 (kill-emacs)) |
14669
6feeb4e59815
(finder-compile-keywords-make-dist): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14599
diff
changeset
|
167 |
867 | 168 ;;; Now the retrieval code |
169 | |
14599 | 170 (defun finder-insert-at-column (column &rest strings) |
171 "Insert list of STRINGS, at column COLUMN." | |
172 (if (> (current-column) column) (insert "\n")) | |
173 (move-to-column column) | |
174 (let ((col (current-column))) | |
175 (if (< col column) | |
176 (indent-to column) | |
177 (if (and (/= col column) | |
178 (= (preceding-char) ?\t)) | |
179 (let (indent-tabs-mode) | |
180 (delete-char -1) | |
181 (indent-to col) | |
182 (move-to-column column))))) | |
183 (apply 'insert strings)) | |
184 | |
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
|
185 (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
|
186 "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
|
187 (interactive) |
18226
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
188 (if (get-buffer "*Finder*") |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
189 (pop-to-buffer "*Finder*") |
18284
21a40db838e2
(finder-list-keywords): Create *Finder* buffer if nec.
Richard M. Stallman <rms@gnu.org>
parents:
18226
diff
changeset
|
190 (pop-to-buffer (set-buffer (get-buffer-create "*Finder*"))) |
18226
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
191 (finder-mode) |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
192 (setq buffer-read-only nil) |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
193 (erase-buffer) |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
194 (mapcar |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
195 (lambda (assoc) |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
196 (let ((keyword (car assoc))) |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
197 (insert (symbol-name keyword)) |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
198 (finder-insert-at-column 14 (concat (cdr assoc) "\n")) |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
199 (cons (symbol-name keyword) keyword))) |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
200 finder-known-keywords) |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
201 (goto-char (point-min)) |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
202 (setq finder-headmark (point)) |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
203 (setq buffer-read-only t) |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
204 (set-buffer-modified-p nil) |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
205 (balance-windows) |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
206 (finder-summary))) |
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
|
207 |
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 (defun finder-list-matches (key) |
18687
3854a35dffd8
(finder-list-matches): Create *Finder Category* buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18284
diff
changeset
|
209 (pop-to-buffer (set-buffer (get-buffer-create "*Finder Category*"))) |
18226
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
210 (finder-mode) |
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
|
211 (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
|
212 (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
|
213 (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
|
214 (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
|
215 "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
|
216 (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
|
217 (mapcar |
14599 | 218 (lambda (x) |
219 (if (memq id (car (cdr (cdr x)))) | |
220 (progn | |
221 (insert (car x)) | |
222 (finder-insert-at-column 16 (concat (car (cdr x)) "\n"))))) | |
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
|
223 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
|
224 (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
|
225 (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
|
226 (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
|
227 (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
|
228 (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
|
229 (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
|
230 |
20264
3b9b07f3eab5
(finder-find-library): Re-instate (with a different
Karl Heuer <kwzh@gnu.org>
parents:
20241
diff
changeset
|
231 ;; Search for a file named FILE on `load-path', also trying compressed |
3b9b07f3eab5
(finder-find-library): Re-instate (with a different
Karl Heuer <kwzh@gnu.org>
parents:
20241
diff
changeset
|
232 ;; versions if jka-compr is in use. |
3b9b07f3eab5
(finder-find-library): Re-instate (with a different
Karl Heuer <kwzh@gnu.org>
parents:
20241
diff
changeset
|
233 (defun finder-find-library (library) |
3b9b07f3eab5
(finder-find-library): Re-instate (with a different
Karl Heuer <kwzh@gnu.org>
parents:
20241
diff
changeset
|
234 (or (locate-library library t) |
3b9b07f3eab5
(finder-find-library): Re-instate (with a different
Karl Heuer <kwzh@gnu.org>
parents:
20241
diff
changeset
|
235 (if (rassq 'jka-compr-handler file-name-handler-alist) |
3b9b07f3eab5
(finder-find-library): Re-instate (with a different
Karl Heuer <kwzh@gnu.org>
parents:
20241
diff
changeset
|
236 (or (locate-library (concat library ".gz") t) |
3b9b07f3eab5
(finder-find-library): Re-instate (with a different
Karl Heuer <kwzh@gnu.org>
parents:
20241
diff
changeset
|
237 (locate-library (concat library ".Z") t) |
3b9b07f3eab5
(finder-find-library): Re-instate (with a different
Karl Heuer <kwzh@gnu.org>
parents:
20241
diff
changeset
|
238 ;; last resort for MS-DOG et al |
3b9b07f3eab5
(finder-find-library): Re-instate (with a different
Karl Heuer <kwzh@gnu.org>
parents:
20241
diff
changeset
|
239 (locate-library (concat library "z")))))) |
3b9b07f3eab5
(finder-find-library): Re-instate (with a different
Karl Heuer <kwzh@gnu.org>
parents:
20241
diff
changeset
|
240 |
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
|
241 (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
|
242 (interactive) |
20264
3b9b07f3eab5
(finder-find-library): Re-instate (with a different
Karl Heuer <kwzh@gnu.org>
parents:
20241
diff
changeset
|
243 (let* ((str (lm-commentary (finder-find-library file)))) |
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
|
244 (if (null str) |
7943
8053544ffe30
(finder-commentary): Fix error message syntax.
Richard M. Stallman <rms@gnu.org>
parents:
5848
diff
changeset
|
245 (error "Can't find any Commentary section")) |
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
|
246 (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
|
247 (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
|
248 (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
|
249 (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
|
250 (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
|
251 (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
|
252 (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
|
253 (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
|
254 (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
|
255 (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
|
256 (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
|
257 (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
|
258 (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
|
259 (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
|
260 (shrink-window-if-larger-than-buffer) |
14599 | 261 (finder-summary))) |
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
|
262 |
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
|
263 (defun finder-current-item () |
2996
358fe58ae153
(finder-known-keywords): Use i18n, not i14n.
Richard M. Stallman <rms@gnu.org>
parents:
2716
diff
changeset
|
264 (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
|
265 (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
|
266 (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
|
267 (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
|
268 (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
|
269 |
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
|
270 (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
|
271 (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
|
272 (let ((key (finder-current-item))) |
20009
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
273 (if (string-match "\\.el$" key) |
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
274 (finder-commentary key) |
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
275 (finder-list-matches key)))) |
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
276 |
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
277 (defun finder-mouse-select (event) |
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
278 (interactive "e") |
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
279 (save-excursion |
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
280 (set-buffer (window-buffer (posn-window (event-start event)))) |
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
281 (goto-char (posn-point (event-start event))) |
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
282 (let ((key (finder-current-item))) |
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
283 (finder-select)))) |
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
|
284 |
867 | 285 (defun finder-by-keyword () |
286 "Find packages matching a given keyword." | |
287 (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
|
288 (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
|
289 |
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
|
290 (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
|
291 "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
|
292 \\<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
|
293 \\[finder-select] more help for the item on the current line |
5848 | 294 \\[finder-exit] exit Finder mode and kill the Finder buffer. |
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
|
295 " |
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
|
296 (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
|
297 (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
|
298 (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
|
299 (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
|
300 (setq major-mode 'finder-mode) |
2996
358fe58ae153
(finder-known-keywords): Use i18n, not i14n.
Richard M. Stallman <rms@gnu.org>
parents:
2716
diff
changeset
|
301 (make-local-variable 'finder-headmark) |
14599 | 302 (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
|
303 |
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
|
304 (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
|
305 "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
|
306 (interactive) |
14313
8e13f59d2c19
(finder-summary): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
307 (message "%s" |
2716
acd678e58602
* finder.el: Bind finder-exit to 'q', not 'x'; the former is the
Jim Blandy <jimb@redhat.com>
parents:
2527
diff
changeset
|
308 (substitute-command-keys |
20009
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
309 "\\<finder-mode-map>\\[finder-select] = select, \\[finder-mouse-select] = select, \\[finder-list-keywords] = to finder directory, \\[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
|
310 |
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
|
311 (defun finder-exit () |
20264
3b9b07f3eab5
(finder-find-library): Re-instate (with a different
Karl Heuer <kwzh@gnu.org>
parents:
20241
diff
changeset
|
312 "Exit Finder mode and kill the buffer." |
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
|
313 (interactive) |
20241 | 314 (or (one-window-p t) |
315 (delete-window)) | |
20009
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
316 ;; Can happen in either buffer -- kill each of the two that exists |
20241 | 317 (and (get-buffer "*Finder*") |
318 (kill-buffer "*Finder*")) | |
319 (and (get-buffer "*Finder Category*") | |
320 (kill-buffer "*Finder Category*"))) | |
867 | 321 |
322 (provide 'finder) | |
323 | |
324 ;;; finder.el ends here |