Mercurial > emacs
comparison lisp/finder.el @ 2228:d40154ca6354
(finder-compile-keywords) Treat nil in a path argument as $PWD.
(finder-by-keyword) Handle LFD as input gracefully.
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Wed, 17 Mar 1993 14:26:35 +0000 |
parents | 2596132752ff |
children | 2c7997f249eb |
comparison
equal
deleted
inserted
replaced
2227:d86258329922 | 2228:d40154ca6354 |
---|---|
77 (defun finder-compile-keywords (&rest dirs) | 77 (defun finder-compile-keywords (&rest dirs) |
78 "Regenerate the keywords association list into the file finder-inf.el. | 78 "Regenerate the keywords association list into the file finder-inf.el. |
79 Optional arguments are a list of Emacs Lisp directories to compile from; no | 79 Optional arguments are a list of Emacs Lisp directories to compile from; no |
80 arguments compiles from `load-path'." | 80 arguments compiles from `load-path'." |
81 (save-excursion | 81 (save-excursion |
82 (find-file "finder-inf.el") | 82 (let ((processed nil)) |
83 (erase-buffer) | 83 (find-file "finder-inf.el") |
84 (insert ";;; Don't edit this file. It's generated by finder.el\n\n") | 84 (erase-buffer) |
85 (insert "\n(setq finder-package-info '(\n") | 85 (insert ";;; Don't edit this file. It's generated by finder.el\n\n") |
86 (mapcar | 86 (insert "\n(setq finder-package-info '(\n") |
87 (function (lambda (d) | 87 (mapcar |
88 (mapcar | 88 (function |
89 (function (lambda (f) | 89 (lambda (d) |
90 (if (string-match "\\.el$" f) | 90 (mapcar |
91 (let (summary keystart) | 91 (function |
92 (save-excursion | 92 (lambda (f) |
93 (set-buffer (get-buffer-create "*finder-scratch*")) | 93 (if (and (string-match "\\.el$" f) (not (member f processed))) |
94 (erase-buffer) | 94 (let (summary keystart) |
95 (insert-file-contents | 95 (setq processed (cons f processed)) |
96 (concat (file-name-as-directory d) f)) | 96 (save-excursion |
97 (setq summary (lm-synopsis)) | 97 (set-buffer (get-buffer-create "*finder-scratch*")) |
98 (setq keywords (lm-keywords))) | 98 (erase-buffer) |
99 (insert | 99 (insert-file-contents |
100 (format " (\"%s\"\n " f)) | 100 (concat (file-name-as-directory (or d ".")) f)) |
101 (prin1 summary (current-buffer)) | 101 (setq summary (lm-synopsis)) |
102 (insert | 102 (setq keywords (lm-keywords))) |
103 "\n ") | 103 (insert |
104 (setq keystart (point)) | 104 (format " (\"%s\"\n " f)) |
105 (insert | 105 (prin1 summary (current-buffer)) |
106 (if keywords (format "(%s)" keywords) "nil") | 106 (insert |
107 ")\n") | 107 "\n ") |
108 (subst-char-in-region keystart (point) ?, ? ) | 108 (setq keystart (point)) |
109 ) | 109 (insert |
110 ))) | 110 (if keywords (format "(%s)" keywords) "nil") |
111 (directory-files (or d "."))) | 111 ")\n") |
112 )) | 112 (subst-char-in-region keystart (point) ?, ? ) |
113 (or dirs load-path)) | 113 ) |
114 (insert "))\n\n(provide 'finder-inf)\n") | 114 ))) |
115 (kill-buffer "*finder-scratch*") | 115 (directory-files (or d "."))) |
116 (basic-save-buffer) | 116 )) |
117 )) | 117 (or dirs load-path)) |
118 (insert "))\n\n(provide 'finder-inf)\n") | |
119 (kill-buffer "*finder-scratch*") | |
120 (basic-save-buffer) | |
121 ))) | |
118 | 122 |
119 ;;; Now the retrieval code | 123 ;;; Now the retrieval code |
120 | 124 |
121 (defun finder-by-keyword () | 125 (defun finder-by-keyword () |
122 "Find packages matching a given keyword." | 126 "Find packages matching a given keyword." |
130 )) | 134 )) |
131 finder-known-keywords) | 135 finder-known-keywords) |
132 (goto-char (point-min)) | 136 (goto-char (point-min)) |
133 (let (key | 137 (let (key |
134 (known (mapcar (function (lambda (x) (car x))) finder-known-keywords))) | 138 (known (mapcar (function (lambda (x) (car x))) finder-known-keywords))) |
135 (let ((key (intern (completing-read | 139 (let ((key (completing-read |
136 "Package keyword: " | 140 "Package keyword: " |
137 (vconcat known) | 141 (vconcat known) |
138 (function (lambda (arg) (memq arg known))) | 142 (function (lambda (arg) (memq arg known))) |
139 t)))) | 143 t)) |
144 id) | |
140 (erase-buffer) | 145 (erase-buffer) |
141 (insert | 146 (if (equal key "") |
142 "The following packages match the keyword `" (symbol-name key) "':\n\n") | 147 (delete-window (get-buffer-window "*Help*")) |
143 (mapcar | 148 (setq id (intern key)) |
144 (function (lambda (x) | 149 (insert |
145 (if (memq key (car (cdr (cdr x)))) | 150 "The following packages match the keyword `" key "':\n\n") |
146 (progn | 151 (mapcar |
147 (insert (car x)) | 152 (function (lambda (x) |
148 (insert-at-column 16 (car (cdr x)) "\n") | 153 (if (memq id (car (cdr (cdr x)))) |
149 )) | 154 (progn |
150 )) | 155 (insert (car x)) |
151 finder-package-info) | 156 (insert-at-column 16 (car (cdr x)) "\n") |
152 (goto-char (point-min)) | 157 )) |
153 ))) | 158 )) |
159 finder-package-info) | |
160 (goto-char (point-min)) | |
161 )))) | |
154 | 162 |
155 (provide 'finder) | 163 (provide 'finder) |
156 | 164 |
157 ;;; finder.el ends here | 165 ;;; finder.el ends here |