Mercurial > emacs
annotate lisp/finder.el @ 107483:2b2a771fc89b
* vc-dispatcher.el (vc-start-logentry): Doc fix.
(log-view-process-buffer, log-edit-extra-flags): Declare.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Tue, 23 Mar 2010 20:30:53 -0700 |
parents | f0ec21d379ff |
children | d928a6a7c3f2 |
rev | line source |
---|---|
867 | 1 ;;; finder.el --- topic & keyword-based code finder |
2 | |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
3 ;; Copyright (C) 1992, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005, |
106815 | 4 ;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
867 | 5 |
6 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com> | |
7 ;; Created: 16 Jun 1992 | |
8 ;; Version: 1.0 | |
9 ;; Keywords: help | |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94183
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
867 | 14 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94183
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94183
diff
changeset
|
16 ;; (at your option) any later version. |
867 | 17 |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94183
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
867 | 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 ;;; Code: | |
32 | |
33 (require 'lisp-mnt) | |
47419
0e00286fe517
(finder-find-library): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44105
diff
changeset
|
34 (require 'find-func) ;for find-library(-suffixes) |
44105
70f755b6a5c9
Don't load finder-inf.el during byte-compilation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38436
diff
changeset
|
35 ;; Use `load' rather than `require' so that it doesn't get loaded |
70f755b6a5c9
Don't load finder-inf.el during byte-compilation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38436
diff
changeset
|
36 ;; during byte-compilation (at which point it might be missing). |
47825
3c21e01f4d87
("finder-inf"): Don't fail if the file is absent.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47419
diff
changeset
|
37 (load "finder-inf" t t) |
867 | 38 |
25622 | 39 ;; These are supposed to correspond to top-level customization groups, |
40 ;; says rms. | |
867 | 41 (defvar finder-known-keywords |
42 '( | |
2270 | 43 (abbrev . "abbreviation handling, typing shortcuts, macros") |
33420
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
44 ;; Too specific: |
5141
3efae588d663
(finder-known-keywords): Add data, faces, mouse, matching.
Richard M. Stallman <rms@gnu.org>
parents:
3708
diff
changeset
|
45 (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
|
46 (c . "support for the C language and related languages") |
867 | 47 (calendar . "calendar and time management support") |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2228
diff
changeset
|
48 (comm . "communications, networking, remote access to files") |
22295
b2ceb0b98995
(finder-known-keywords): Fix `convenience' entry.
Dave Love <fx@gnu.org>
parents:
22129
diff
changeset
|
49 (convenience . "convenience features for faster editing") |
54483
b7f0abc3ce60
(finder-known-keywords): Fix data, tex, unix.
Juri Linkov <juri@jurta.org>
parents:
53501
diff
changeset
|
50 (data . "support for editing files of data") |
867 | 51 (docs . "support for Emacs documentation") |
52 (emulations . "emulations of other editors") | |
53 (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
|
54 (faces . "support for multiple fonts") |
33420
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
55 (files . "support for editing and manipulating files") |
11454
d9ec5322d181
(finder-known-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
9200
diff
changeset
|
56 (frames . "support for Emacs frames and window systems") |
867 | 57 (games . "games, jokes and amusements") |
58 (hardware . "support for interfacing with exotic hardware") | |
59 (help . "support for on-line help systems") | |
11454
d9ec5322d181
(finder-known-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
9200
diff
changeset
|
60 (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
|
61 (i18n . "internationalization and alternate character-set support") |
867 | 62 (internal . "code for Emacs internals, build process, defaults") |
63 (languages . "specialized modes for editing programming languages") | |
64 (lisp . "Lisp support, including Emacs Lisp") | |
65 (local . "code local to your site") | |
66 (maint . "maintenance aids for the Emacs development group") | |
67 (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
|
68 (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
|
69 (mouse . "mouse support") |
25308
8a92c65da346
(finder-known-keywords): Add `multimedia'.
Dave Love <fx@gnu.org>
parents:
24221
diff
changeset
|
70 (multimedia . "images and sound support") |
867 | 71 (news . "support for netnews reading and posting") |
11454
d9ec5322d181
(finder-known-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
9200
diff
changeset
|
72 (oop . "support for object-oriented programming") |
d9ec5322d181
(finder-known-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
9200
diff
changeset
|
73 (outlines . "support for hierarchical outlining") |
867 | 74 (processes . "process, subshell, compilation, and job control support") |
75 (terminals . "support for terminal types") | |
54483
b7f0abc3ce60
(finder-known-keywords): Fix data, tex, unix.
Juri Linkov <juri@jurta.org>
parents:
53501
diff
changeset
|
76 (tex . "supporting code for the TeX formatter") |
867 | 77 (tools . "programming tools") |
54483
b7f0abc3ce60
(finder-known-keywords): Fix data, tex, unix.
Juri Linkov <juri@jurta.org>
parents:
53501
diff
changeset
|
78 (unix . "front-ends/assistants for, or emulators of, UNIX-like features") |
867 | 79 (wp . "word processing") |
80 )) | |
81 | |
54572
2f882266c186
(finder-mode): Follow coding convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54483
diff
changeset
|
82 (defvar finder-mode-map |
106267
823bbd791783
(finder-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105994
diff
changeset
|
83 (let ((map (make-sparse-keymap)) |
823bbd791783
(finder-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105994
diff
changeset
|
84 (menu-map (make-sparse-keymap "Finder"))) |
54572
2f882266c186
(finder-mode): Follow coding convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54483
diff
changeset
|
85 (define-key map " " 'finder-select) |
2f882266c186
(finder-mode): Follow coding convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54483
diff
changeset
|
86 (define-key map "f" 'finder-select) |
66413
4e56b3fda002
* menu-bar.el (menu-bar-help-menu): Rename "psychiatrist", in line
Chong Yidong <cyd@stupidchicken.com>
parents:
64762
diff
changeset
|
87 (define-key map [follow-link] 'mouse-face) |
54572
2f882266c186
(finder-mode): Follow coding convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54483
diff
changeset
|
88 (define-key map [mouse-2] 'finder-mouse-select) |
2f882266c186
(finder-mode): Follow coding convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54483
diff
changeset
|
89 (define-key map "\C-m" 'finder-select) |
2f882266c186
(finder-mode): Follow coding convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54483
diff
changeset
|
90 (define-key map "?" 'finder-summary) |
69914
ef1d39034359
(finder-mode-map): Add n and p bindings.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
91 (define-key map "n" 'next-line) |
ef1d39034359
(finder-mode-map): Add n and p bindings.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
92 (define-key map "p" 'previous-line) |
54572
2f882266c186
(finder-mode): Follow coding convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54483
diff
changeset
|
93 (define-key map "q" 'finder-exit) |
2f882266c186
(finder-mode): Follow coding convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54483
diff
changeset
|
94 (define-key map "d" 'finder-list-keywords) |
106267
823bbd791783
(finder-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105994
diff
changeset
|
95 |
823bbd791783
(finder-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105994
diff
changeset
|
96 (define-key map [menu-bar finder-mode] |
823bbd791783
(finder-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105994
diff
changeset
|
97 (cons "Finder" menu-map)) |
823bbd791783
(finder-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105994
diff
changeset
|
98 (define-key menu-map [finder-exit] |
823bbd791783
(finder-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105994
diff
changeset
|
99 '(menu-item "Quit" finder-exit |
823bbd791783
(finder-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105994
diff
changeset
|
100 :help "Exit Finder mode")) |
823bbd791783
(finder-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105994
diff
changeset
|
101 (define-key menu-map [finder-summary] |
823bbd791783
(finder-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105994
diff
changeset
|
102 '(menu-item "Summary" finder-summary |
823bbd791783
(finder-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105994
diff
changeset
|
103 :help "Summary item on current line in a finder buffer")) |
823bbd791783
(finder-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105994
diff
changeset
|
104 (define-key menu-map [finder-list-keywords] |
823bbd791783
(finder-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105994
diff
changeset
|
105 '(menu-item "List keywords" finder-list-keywords |
823bbd791783
(finder-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105994
diff
changeset
|
106 :help "Display descriptions of the keywords in the Finder buffer")) |
823bbd791783
(finder-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105994
diff
changeset
|
107 (define-key menu-map [finder-select] |
823bbd791783
(finder-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105994
diff
changeset
|
108 '(menu-item "Select" finder-select |
823bbd791783
(finder-mode-map): Add a menu.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105994
diff
changeset
|
109 :help "Select item on current line in a finder buffer")) |
54572
2f882266c186
(finder-mode): Follow coding convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54483
diff
changeset
|
110 map)) |
9200
e48652e64736
(finder-mode-map): Change key bindings:
Richard M. Stallman <rms@gnu.org>
parents:
7943
diff
changeset
|
111 |
93178
6c44d22f4d83
(finder-mode-syntax-table, finder-font-lock-keywords): New variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
112 (defvar finder-mode-syntax-table |
6c44d22f4d83
(finder-mode-syntax-table, finder-font-lock-keywords): New variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
113 (let ((st (make-syntax-table emacs-lisp-mode-syntax-table))) |
6c44d22f4d83
(finder-mode-syntax-table, finder-font-lock-keywords): New variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
114 (modify-syntax-entry ?\; ". " st) |
6c44d22f4d83
(finder-mode-syntax-table, finder-font-lock-keywords): New variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
115 st) |
6c44d22f4d83
(finder-mode-syntax-table, finder-font-lock-keywords): New variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
116 "Syntax table used while in `finder-mode'.") |
6c44d22f4d83
(finder-mode-syntax-table, finder-font-lock-keywords): New variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
117 |
6c44d22f4d83
(finder-mode-syntax-table, finder-font-lock-keywords): New variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
118 (defvar finder-font-lock-keywords |
95750
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
119 '(("`\\([^'`]+\\)'" 1 font-lock-constant-face prepend)) |
93178
6c44d22f4d83
(finder-mode-syntax-table, finder-font-lock-keywords): New variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
120 "Font-lock keywords for Finder mode.") |
6c44d22f4d83
(finder-mode-syntax-table, finder-font-lock-keywords): New variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
121 |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
122 (defvar finder-headmark nil |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
123 "Internal finder-mode variable, local in 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
|
124 |
867 | 125 ;;; Code for regenerating the keyword list. |
126 | |
127 (defvar finder-package-info nil | |
128 "Assoc list mapping file names to description & keyword lists.") | |
129 | |
48991
d3a44c8bd8d2
* finder.el (generated-finder-keywords-file): New variable.
Andreas Schwab <schwab@suse.de>
parents:
48688
diff
changeset
|
130 (defvar generated-finder-keywords-file "finder-inf.el" |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
131 "The function `finder-compile-keywords' writes keywords into this file.") |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
132 |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
133 ;; Skip autogenerated files, because they will never contain anything |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
134 ;; useful, and because in parallel builds of Emacs they may get |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
135 ;; modified while we are trying to read them. |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
136 ;; http://lists.gnu.org/archive/html/emacs-pretest-bug/2007-01/msg00469.html |
96163
afc4aa03c2d5
(finder-no-scan-regexp): Add ldefs-boot.el
Glenn Morris <rgm@gnu.org>
parents:
95750
diff
changeset
|
137 ;; ldefs-boot is not auto-generated, but has nothing useful. |
afc4aa03c2d5
(finder-no-scan-regexp): Add ldefs-boot.el
Glenn Morris <rgm@gnu.org>
parents:
95750
diff
changeset
|
138 (defvar finder-no-scan-regexp "\\(^\\.#\\|\\(loaddefs\\|ldefs-boot\\|\ |
afc4aa03c2d5
(finder-no-scan-regexp): Add ldefs-boot.el
Glenn Morris <rgm@gnu.org>
parents:
95750
diff
changeset
|
139 cus-load\\|finder-inf\\|esh-groups\\|subdirs\\)\\.el$\\)" |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
140 "Regexp matching file names not to scan for keywords.") |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
141 |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
142 (autoload 'autoload-rubric "autoload") |
48991
d3a44c8bd8d2
* finder.el (generated-finder-keywords-file): New variable.
Andreas Schwab <schwab@suse.de>
parents:
48688
diff
changeset
|
143 |
867 | 144 (defun finder-compile-keywords (&rest dirs) |
48991
d3a44c8bd8d2
* finder.el (generated-finder-keywords-file): New variable.
Andreas Schwab <schwab@suse.de>
parents:
48688
diff
changeset
|
145 "Regenerate the keywords association list into `generated-finder-keywords-file'. |
24221
efc15742dcc3
(finder-commentary): Fix interactive spec. Try
Dave Love <fx@gnu.org>
parents:
22295
diff
changeset
|
146 Optional arguments DIRS are a list of Emacs Lisp directories to compile from; |
efc15742dcc3
(finder-commentary): Fix interactive spec. Try
Dave Love <fx@gnu.org>
parents:
22295
diff
changeset
|
147 no arguments compiles from `load-path'." |
867 | 148 (save-excursion |
95750
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
149 (find-file generated-finder-keywords-file) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
150 (setq buffer-undo-list t) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
151 (erase-buffer) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
152 (insert (autoload-rubric generated-finder-keywords-file |
105859
658336850f93
Use autoload-rubric's feature argument.
Glenn Morris <rgm@gnu.org>
parents:
102450
diff
changeset
|
153 "keyword-to-package mapping" t)) |
95750
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
154 (search-backward "") |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
155 (insert "(setq finder-package-info '(\n") |
95629
470520f9b596
(finder-compile-keywords): Use lm-keywords-list rather than lm-keywords.
Glenn Morris <rgm@gnu.org>
parents:
95583
diff
changeset
|
156 (let (processed summary keywords) |
84870
19e1cc64b115
(finder-compile-keywords): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
84659
diff
changeset
|
157 (mapc |
14599 | 158 (lambda (d) |
21758
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
159 (when (file-exists-p (directory-file-name d)) |
bc7f520d8251
(finder-compile-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
20264
diff
changeset
|
160 (message "Directory %s" d) |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
161 (mapc |
24221
efc15742dcc3
(finder-commentary): Fix interactive spec. Try
Dave Love <fx@gnu.org>
parents:
22295
diff
changeset
|
162 (lambda (f) |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
163 ;; FIXME should this not be using (expand-file-name f d)? |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
164 (unless (or (member f processed) |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
165 (string-match finder-no-scan-regexp f)) |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
166 (setq processed (cons f processed)) |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
167 (with-temp-buffer |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
168 (insert-file-contents (expand-file-name f d)) |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
169 (setq summary (lm-synopsis) |
95629
470520f9b596
(finder-compile-keywords): Use lm-keywords-list rather than lm-keywords.
Glenn Morris <rgm@gnu.org>
parents:
95583
diff
changeset
|
170 keywords (lm-keywords-list))) |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
171 (insert |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
172 (format " (\"%s\"\n " |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
173 (if (string-match "\\.\\(gz\\|Z\\)$" f) |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
174 (file-name-sans-extension f) |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
175 f))) |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
176 (prin1 summary (current-buffer)) |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
177 (insert "\n ") |
107390 | 178 (prin1 (mapcar 'intern keywords) (current-buffer)) |
95629
470520f9b596
(finder-compile-keywords): Use lm-keywords-list rather than lm-keywords.
Glenn Morris <rgm@gnu.org>
parents:
95583
diff
changeset
|
179 (insert ")\n"))) |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
180 (directory-files d nil |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
181 ;; Allow compressed files also. FIXME: |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
182 ;; generalize this, especially for |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
183 ;; MS-DOG-type filenames. |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
184 "^[^=].*\\.el\\(\\.\\(gz\\|Z\\)\\)?$" |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
185 )))) |
95750
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
186 (or dirs load-path))) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
187 (insert " ))\n") |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
188 (eval-buffer) ; so we get the new keyword list immediately |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
189 (basic-save-buffer))) |
867 | 190 |
14669
6feeb4e59815
(finder-compile-keywords-make-dist): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14599
diff
changeset
|
191 (defun finder-compile-keywords-make-dist () |
6feeb4e59815
(finder-compile-keywords-make-dist): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14599
diff
changeset
|
192 "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
|
193 (apply 'finder-compile-keywords command-line-args-left) |
ae0f1e4a63be
(finder-compile-keywords-make-dist):
Richard M. Stallman <rms@gnu.org>
parents:
14669
diff
changeset
|
194 (kill-emacs)) |
14669
6feeb4e59815
(finder-compile-keywords-make-dist): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14599
diff
changeset
|
195 |
867 | 196 ;;; Now the retrieval code |
197 | |
14599 | 198 (defun finder-insert-at-column (column &rest strings) |
21805
aafa93c1a5ce
(finder-insert-at-column): Simplify.
Dave Love <fx@gnu.org>
parents:
21758
diff
changeset
|
199 "Insert, at column COLUMN, other args STRINGS." |
38359
29beb6347e09
(finder-insert-at-column): Also move to the next line if exactly at COLUMN.
Miles Bader <miles@gnu.org>
parents:
33420
diff
changeset
|
200 (if (>= (current-column) column) (insert "\n")) |
21805
aafa93c1a5ce
(finder-insert-at-column): Simplify.
Dave Love <fx@gnu.org>
parents:
21758
diff
changeset
|
201 (move-to-column column t) |
14599 | 202 (apply 'insert strings)) |
203 | |
33420
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
204 (defvar finder-help-echo nil) |
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
205 |
21805
aafa93c1a5ce
(finder-insert-at-column): Simplify.
Dave Love <fx@gnu.org>
parents:
21758
diff
changeset
|
206 (defun finder-mouse-face-on-line () |
33420
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
207 "Put `mouse-face' and `help-echo' properties on the previous line." |
21805
aafa93c1a5ce
(finder-insert-at-column): Simplify.
Dave Love <fx@gnu.org>
parents:
21758
diff
changeset
|
208 (save-excursion |
84659
76e7ca025173
(finder-compile-keywords): Fix up comment style.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78236
diff
changeset
|
209 (forward-line -1) |
95750
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
210 ;; If finder-insert-at-column moved us to a new line, go back one more. |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
211 (if (looking-at "[ \t]") (forward-line -1)) |
33420
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
212 (unless finder-help-echo |
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
213 (setq finder-help-echo |
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
214 (let* ((keys1 (where-is-internal 'finder-select |
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
215 finder-mode-map)) |
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
216 (keys (nconc (where-is-internal |
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
217 'finder-mouse-select finder-mode-map) |
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
218 keys1))) |
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
219 (concat (mapconcat 'key-description keys ", ") |
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
220 ": select item")))) |
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
221 (add-text-properties |
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
222 (line-beginning-position) (line-end-position) |
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
223 '(mouse-face highlight |
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
224 help-echo finder-help-echo)))) |
21805
aafa93c1a5ce
(finder-insert-at-column): Simplify.
Dave Love <fx@gnu.org>
parents:
21758
diff
changeset
|
225 |
107391
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
226 (defun finder-unknown-keywords () |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
227 "Return an alist of unknown keywords and number of their occurences. |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
228 Unknown are keywords that are present in `finder-package-info' |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
229 but absent in `finder-known-keywords'." |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
230 (let ((unknown-keywords-hash (make-hash-table))) |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
231 ;; Prepare a hash where key is a keyword |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
232 ;; and value is the number of keyword occurences. |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
233 (mapc (lambda (package) |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
234 (mapc (lambda (keyword) |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
235 (unless (assq keyword finder-known-keywords) |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
236 (puthash keyword |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
237 (1+ (gethash keyword unknown-keywords-hash 0)) |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
238 unknown-keywords-hash))) |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
239 (nth 2 package))) |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
240 finder-package-info) |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
241 ;; Make an alist from the hash and sort by the keyword name. |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
242 (sort (let (unknown-keywords-list) |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
243 (maphash (lambda (key value) |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
244 (push (cons key value) unknown-keywords-list)) |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
245 unknown-keywords-hash) |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
246 unknown-keywords-list) |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
247 (lambda (a b) (string< (car a) (car b)))))) |
78dd74750b2b
Add finder unknown keywords.
Juri Linkov <juri@jurta.org>
parents:
107390
diff
changeset
|
248 |
28528
7618c3801a21
(finder-commentary): Add autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
26675
diff
changeset
|
249 ;;;###autoload |
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
|
250 (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
|
251 "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
|
252 (interactive) |
18226
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
253 (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
|
254 (pop-to-buffer "*Finder*") |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
255 (pop-to-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
|
256 (finder-mode) |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
257 (setq buffer-read-only nil |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
258 buffer-undo-list t) |
18226
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
259 (erase-buffer) |
33420
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
260 (mapc |
18226
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
261 (lambda (assoc) |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
262 (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
|
263 (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
|
264 (finder-insert-at-column 14 (concat (cdr assoc) "\n")) |
21805
aafa93c1a5ce
(finder-insert-at-column): Simplify.
Dave Love <fx@gnu.org>
parents:
21758
diff
changeset
|
265 (finder-mouse-face-on-line))) |
18226
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
266 finder-known-keywords) |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
267 (goto-char (point-min)) |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
268 (setq finder-headmark (point) |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
269 buffer-read-only t) |
18226
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
270 (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
|
271 (balance-windows) |
37ff8dfff53b
(finder-mode): Don't switch buffers or change text here.
Richard M. Stallman <rms@gnu.org>
parents:
17745
diff
changeset
|
272 (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
|
273 |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
274 (defun finder-list-matches (key) |
18687
3854a35dffd8
(finder-list-matches): Create *Finder Category* buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18284
diff
changeset
|
275 (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
|
276 (finder-mode) |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
277 (setq buffer-read-only nil |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
278 buffer-undo-list t) |
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
|
279 (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
|
280 (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
|
281 (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
|
282 "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
|
283 (setq finder-headmark (point)) |
33420
cc332f3565f2
(finder-known-keywords): Add `files', remove `vms'.
Dave Love <fx@gnu.org>
parents:
30883
diff
changeset
|
284 (mapc |
14599 | 285 (lambda (x) |
95750
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
286 (when (memq id (cadr (cdr x))) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
287 (insert (car x)) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
288 (finder-insert-at-column 16 (concat (cadr x) "\n")) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
289 (finder-mouse-face-on-line))) |
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
|
290 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
|
291 (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
|
292 (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
|
293 (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
|
294 (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
|
295 (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
|
296 (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
|
297 |
95750
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
298 (define-button-type 'finder-xref 'action #'finder-goto-xref) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
299 |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
300 (defun finder-goto-xref (button) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
301 "Jump to a lisp file for the BUTTON at point." |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
302 (let* ((file (button-get button 'xref)) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
303 (lib (locate-library file))) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
304 (if lib (finder-commentary lib) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
305 (message "Unable to locate `%s'" file)))) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
306 |
28528
7618c3801a21
(finder-commentary): Add autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
26675
diff
changeset
|
307 ;;;###autoload |
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
|
308 (defun finder-commentary (file) |
24221
efc15742dcc3
(finder-commentary): Fix interactive spec. Try
Dave Love <fx@gnu.org>
parents:
22295
diff
changeset
|
309 "Display FILE's commentary section. |
efc15742dcc3
(finder-commentary): Fix interactive spec. Try
Dave Love <fx@gnu.org>
parents:
22295
diff
changeset
|
310 FILE should be in a form suitable for passing to `locate-library'." |
47419
0e00286fe517
(finder-find-library): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44105
diff
changeset
|
311 (interactive |
0e00286fe517
(finder-find-library): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44105
diff
changeset
|
312 (list |
0e00286fe517
(finder-find-library): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44105
diff
changeset
|
313 (completing-read "Library name: " |
94183
bade431b9780
* finder.el (finder-commentary):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93178
diff
changeset
|
314 (apply-partially 'locate-file-completion-table |
bade431b9780
* finder.el (finder-commentary):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93178
diff
changeset
|
315 (or find-function-source-path load-path) |
bade431b9780
* finder.el (finder-commentary):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93178
diff
changeset
|
316 (find-library-suffixes))))) |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
317 (let ((str (lm-commentary (find-library-name file)))) |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
318 (or str (error "Can't find any Commentary section")) |
48408
2eb7a3846b4c
(finder-commentary): Use buffer *Finder-package*.
Richard M. Stallman <rms@gnu.org>
parents:
47825
diff
changeset
|
319 ;; This used to use *Finder* but that would clobber the |
2eb7a3846b4c
(finder-commentary): Use buffer *Finder-package*.
Richard M. Stallman <rms@gnu.org>
parents:
47825
diff
changeset
|
320 ;; directory of categories. |
2eb7a3846b4c
(finder-commentary): Use buffer *Finder-package*.
Richard M. Stallman <rms@gnu.org>
parents:
47825
diff
changeset
|
321 (pop-to-buffer "*Finder-package*") |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
322 (setq buffer-read-only nil |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
323 buffer-undo-list t) |
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
|
324 (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
|
325 (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
|
326 (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
|
327 (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
|
328 (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
|
329 (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
|
330 (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
|
331 (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
|
332 (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
|
333 (goto-char (point-min)) |
95750
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
334 (while (re-search-forward "\\<\\([-[:alnum:]]+\\.el\\)\\>" nil t) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
335 (if (locate-library (match-string 1)) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
336 (make-text-button (match-beginning 1) (match-end 1) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
337 'xref (match-string-no-properties 1) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
338 'help-echo "Read this file's commentary" |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
339 :type 'finder-xref))) |
6c14c564fa23
(finder-font-lock-keywords): Handle ``quotes''.
Glenn Morris <rgm@gnu.org>
parents:
95629
diff
changeset
|
340 (goto-char (point-min)) |
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
|
341 (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
|
342 (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
|
343 (shrink-window-if-larger-than-buffer) |
26675
995b6841718b
(finder-commentary): Activate Finder mode.
Gerd Moellmann <gerd@gnu.org>
parents:
25622
diff
changeset
|
344 (finder-mode) |
14599 | 345 (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
|
346 |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
347 (defun finder-current-item () |
60746
23533546bb38
(finder-current-item): Throw an error on an empty line.
Eli Zaretskii <eliz@gnu.org>
parents:
54572
diff
changeset
|
348 (let ((key (save-excursion |
23533546bb38
(finder-current-item): Throw an error on an empty line.
Eli Zaretskii <eliz@gnu.org>
parents:
54572
diff
changeset
|
349 (beginning-of-line) |
23533546bb38
(finder-current-item): Throw an error on an empty line.
Eli Zaretskii <eliz@gnu.org>
parents:
54572
diff
changeset
|
350 (current-word)))) |
23533546bb38
(finder-current-item): Throw an error on an empty line.
Eli Zaretskii <eliz@gnu.org>
parents:
54572
diff
changeset
|
351 (if (or (and finder-headmark (< (point) finder-headmark)) |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
352 (zerop (length key))) |
60746
23533546bb38
(finder-current-item): Throw an error on an empty line.
Eli Zaretskii <eliz@gnu.org>
parents:
54572
diff
changeset
|
353 (error "No keyword or filename on this line") |
23533546bb38
(finder-current-item): Throw an error on an empty line.
Eli Zaretskii <eliz@gnu.org>
parents:
54572
diff
changeset
|
354 key))) |
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
|
355 |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
356 (defun finder-select () |
21805
aafa93c1a5ce
(finder-insert-at-column): Simplify.
Dave Love <fx@gnu.org>
parents:
21758
diff
changeset
|
357 "Select item on current line in a 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
|
358 (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
|
359 (let ((key (finder-current-item))) |
20009
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
360 (if (string-match "\\.el$" key) |
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
361 (finder-commentary key) |
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
362 (finder-list-matches key)))) |
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
363 |
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
364 (defun finder-mouse-select (event) |
21805
aafa93c1a5ce
(finder-insert-at-column): Simplify.
Dave Love <fx@gnu.org>
parents:
21758
diff
changeset
|
365 "Select item in a finder buffer with the mouse." |
20009
09bc233eb018
(finder-mode-map): Bind [mouse-2].
Karl Heuer <kwzh@gnu.org>
parents:
19169
diff
changeset
|
366 (interactive "e") |
105994
009383a57ce8
* x-dnd.el (x-dnd-maybe-call-test-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105859
diff
changeset
|
367 (with-current-buffer (window-buffer (posn-window (event-start event))) |
21805
aafa93c1a5ce
(finder-insert-at-column): Simplify.
Dave Love <fx@gnu.org>
parents:
21758
diff
changeset
|
368 (goto-char (posn-point (event-start event))) |
aafa93c1a5ce
(finder-insert-at-column): Simplify.
Dave Love <fx@gnu.org>
parents:
21758
diff
changeset
|
369 (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
|
370 |
28528
7618c3801a21
(finder-commentary): Add autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
26675
diff
changeset
|
371 ;;;###autoload |
867 | 372 (defun finder-by-keyword () |
373 "Find packages matching a given keyword." | |
374 (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
|
375 (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
|
376 |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
377 (define-derived-mode finder-mode nil "Finder" |
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
|
378 "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
|
379 \\<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
|
380 \\[finder-select] more help for the item on the current line |
24221
efc15742dcc3
(finder-commentary): Fix interactive spec. Try
Dave Love <fx@gnu.org>
parents:
22295
diff
changeset
|
381 \\[finder-exit] exit Finder mode and kill the Finder buffer." |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
382 :syntax-table finder-mode-syntax-table |
93178
6c44d22f4d83
(finder-mode-syntax-table, finder-font-lock-keywords): New variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
383 (setq font-lock-defaults '(finder-font-lock-keywords nil nil |
6c44d22f4d83
(finder-mode-syntax-table, finder-font-lock-keywords): New variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
384 (("+-*/.<>=!?$%_&~^:@" . "w")) nil)) |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
385 (set (make-local-variable '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
|
386 |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
387 (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
|
388 "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
|
389 (interactive) |
14313
8e13f59d2c19
(finder-summary): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
390 (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
|
391 (substitute-command-keys |
21805
aafa93c1a5ce
(finder-insert-at-column): Simplify.
Dave Love <fx@gnu.org>
parents:
21758
diff
changeset
|
392 "\\<finder-mode-map>\\[finder-select] = select, \ |
aafa93c1a5ce
(finder-insert-at-column): Simplify.
Dave Love <fx@gnu.org>
parents:
21758
diff
changeset
|
393 \\[finder-mouse-select] = select, \\[finder-list-keywords] = to \ |
aafa93c1a5ce
(finder-insert-at-column): Simplify.
Dave Love <fx@gnu.org>
parents:
21758
diff
changeset
|
394 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
|
395 |
93015b63b041
Rewritten. The Finder is now a major mode with the ability to browse
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2502
diff
changeset
|
396 (defun finder-exit () |
93178
6c44d22f4d83
(finder-mode-syntax-table, finder-font-lock-keywords): New variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
397 "Exit Finder mode. |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
398 Delete the window and kill all Finder-related buffers." |
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
|
399 (interactive) |
95555
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
400 (ignore-errors (delete-window)) |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
401 (dolist (buff '("*Finder*" "*Finder-package*" "*Finder Category*")) |
97c7d857b5e3
(finder-headmark): Initialize and add doc string.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
402 (and (get-buffer buff) (kill-buffer buff)))) |
867 | 403 |
30883
869204bacd5f
Add local-variable settings to the generated file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28528
diff
changeset
|
404 |
867 | 405 (provide 'finder) |
406 | |
84659
76e7ca025173
(finder-compile-keywords): Fix up comment style.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78236
diff
changeset
|
407 ;; arch-tag: ec85ff49-8cb8-41f5-a63f-9131d53ce2c5 |
867 | 408 ;;; finder.el ends here |