annotate lisp/finder.el @ 2607:fcf578723758

(Fexpand_file_name): Undo last change--too risky for now.
author Richard M. Stallman <rms@gnu.org>
date Thu, 29 Apr 1993 13:17:56 +0000
parents 93015b63b041
children acd678e58602
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
867
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1 ;;; finder.el --- topic & keyword-based code finder
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3 ;; Copyright (C) 1992 Free Software Foundation, Inc.
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
4
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
5 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
6 ;; Created: 16 Jun 1992
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
7 ;; Version: 1.0
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
8 ;; Keywords: help
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
9
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
11
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 1, or (at your option)
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
15 ;; any later version.
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
16
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
21
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
24 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
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
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
27
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
28 ;; This mode uses the Keywords library header to provide code-finding
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
29 ;; services by keyword.
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
30 ;;
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
31 ;; Things to do:
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
32 ;; 1. Support multiple keywords per search. This could be extremely hairy;
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
33 ;; there doesn't seem to be any way to get completing-read to exit on
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
34 ;; an EOL with no substring pending, which is what we'd want to end the loop.
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
35 ;; 2. Search by string in synopsis line?
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
36 ;; 3. Function to check finder-package-info for unknown keywords.
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
37
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
38 ;;; Code:
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
39
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
40 (require 'lisp-mnt)
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
41 (require 'finder-inf)
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
42 (require 'picture)
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
43
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
44 (defvar finder-known-keywords
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
45 '(
2270
a74fc62a3a1f Typo fix.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
46 (abbrev . "abbreviation handling, typing shortcuts, macros")
867
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
47 (bib . "code related to the bib(1) bibliography processor")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
48 (c . "C and C++ language support")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
49 (calendar . "calendar and time management support")
2247
2c7997f249eb Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2228
diff changeset
50 (comm . "communications, networking, remote access to files")
867
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
51 (docs . "support for Emacs documentation")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
52 (emulations . "emulations of other editors")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
53 (extensions . "Emacs Lisp language extensions")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
54 (games . "games, jokes and amusements")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
55 (hardware . "support for interfacing with exotic hardware")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
56 (help . "support for on-line help systems")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
57 (i14n . "internationalization and alternate character-set support")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
58 (internal . "code for Emacs internals, build process, defaults")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
59 (languages . "specialized modes for editing programming languages")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
60 (lisp . "Lisp support, including Emacs Lisp")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
61 (local . "code local to your site")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
62 (maint . "maintenance aids for the Emacs development group")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
63 (mail . "modes for electronic-mail handling")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
64 (news . "support for netnews reading and posting")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
65 (processes . "process, subshell, compilation, and job control support")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
66 (terminals . "support for terminal types")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
67 (tex . "code related to the TeX formatter")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
68 (tools . "programming tools")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
69 (unix . "front-ends/assistants for, or emulators of, UNIX features")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
70 (vms . "support code for vms")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
71 (wp . "word processing")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
72 ))
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
73
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
74 (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
75 ;(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
76 ; 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
77 (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
78 (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
79 (define-key finder-mode-map "?" '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
80 (define-key finder-mode-map "x" '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
81 (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
82 ; )
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
83
867
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
84 ;;; Code for regenerating the keyword list.
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
85
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
86 (defvar finder-package-info nil
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
87 "Assoc list mapping file names to description & keyword lists.")
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
88
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
89 (defun finder-compile-keywords (&rest dirs)
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
90 "Regenerate the keywords association list into the file finder-inf.el.
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
91 Optional arguments are a list of Emacs Lisp directories to compile from; no
1475
2596132752ff Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 928
diff changeset
92 arguments compiles from `load-path'."
867
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
93 (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
94 (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
95 (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
96 (erase-buffer)
2247
2c7997f249eb Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2228
diff changeset
97 (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
98 (insert ";; Keywords: help\n")
2457
3d2f74e16e54 Added or corrected documentation headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2271
diff changeset
99 (insert ";;; Commentary:\n")
3d2f74e16e54 Added or corrected documentation headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2271
diff changeset
100 (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
101 (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
102 (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
103 (mapcar
d40154ca6354 (finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1475
diff changeset
104 (function
d40154ca6354 (finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1475
diff changeset
105 (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
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 (f)
d40154ca6354 (finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1475
diff changeset
109 (if (and (string-match "\\.el$" f) (not (member 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
110 (let (summary keystart)
d40154ca6354 (finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1475
diff changeset
111 (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
112 (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
113 (set-buffer (get-buffer-create "*finder-scratch*"))
d40154ca6354 (finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1475
diff changeset
114 (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
115 (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
116 (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
117 (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
118 (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
119 (insert
d40154ca6354 (finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1475
diff changeset
120 (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
121 (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
122 (insert
d40154ca6354 (finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1475
diff changeset
123 "\n ")
d40154ca6354 (finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1475
diff changeset
124 (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
125 (insert
d40154ca6354 (finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1475
diff changeset
126 (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
127 ")\n")
d40154ca6354 (finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1475
diff changeset
128 (subst-char-in-region 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
129 )
d40154ca6354 (finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1475
diff changeset
130 )))
d40154ca6354 (finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1475
diff changeset
131 (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
132 ))
d40154ca6354 (finder-compile-keywords) Treat nil in a path argument as $PWD.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1475
diff changeset
133 (or dirs load-path))
2457
3d2f74e16e54 Added or corrected documentation headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2271
diff changeset
134 (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
135 (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
136 (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
137 (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
138 )))
867
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
139
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
140 ;;; Now the retrieval code
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
141
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
142 (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
143 "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
144 (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
145 (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
146 (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
147 (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
148 (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
149 (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
150 (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
151 (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
152 (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
153 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
154 (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
155 (setq headmark (point))
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 (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
157 (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
158 (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
159 (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
160
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 (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
162 (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
163 (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
164 (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
165 (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
166 "The following packages match the keyword `" key "':\n\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
167 (setq headmark (point))
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 (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
169 (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
170 (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
171 (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
172 (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
173 (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
174 (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
175 ))
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 ))
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 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
178 (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
179 (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
180 (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
181 (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
182 (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
183 (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
184
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-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
186 (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
187 (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
188 (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
189 (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
190 (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
191 (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
192 (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
193 (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
194 (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
195 (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
196 (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
197 (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
198 (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
199 (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
200 (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
201 (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
202 (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
203 (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
204 (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
205 (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
206 ))
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-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
209 (if (and headmark (< (point) headmark))
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 (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
211 (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
212 (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
213 (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
214
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 (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
216 (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
217 (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
218 (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
219 (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
220 (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
221
867
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
222 (defun finder-by-keyword ()
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
223 "Find packages matching a given keyword."
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
224 (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
225 (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
226 (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
227
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 (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
229 "Major mode for browsing package documentation.
2502
190371d9bc2e * finder.el (finder-by-keyword): Build an alist to pass to
Jim Blandy <jimb@redhat.com>
parents: 2457
diff changeset
230
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
231 \\[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
232 \\[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
233 "
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 (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
235 (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
236 (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
237 (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
238 (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
239 (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
240 (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
241 (setq major-mode '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
242 (make-local-variable 'headmark)
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 (setq headmark 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
244 )
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
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 (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
247 "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
248 (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
249 (message
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 "SPC = select, f = back to Finder, x = eXit, ? = help"))
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
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 (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
253 "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
254 (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
255 (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
256 (kill-buffer "*Finder*"))
867
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
257
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
258 (provide 'finder)
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
259
f120dd3a71b0 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
260 ;;; finder.el ends here