Mercurial > emacs
comparison lisp/finder.el @ 20009:09bc233eb018
(finder-mode-map): Bind [mouse-2].
(finder-compile-keywords): Match compressed file names, but don't
put compression extension in the output.
(finder-find-library): Deleted.
(finder-commentary): Use locate-library, not finder-find-library.
(finder-mouse-select): New function.
(finder-summary): Mention mouse binding.
(finder-exit): Kill "*Finder Category*" buffer too. Avoid error
from deleting sole window.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Tue, 30 Sep 1997 07:36:28 +0000 |
parents | 0ffc25f09344 |
children | 25b1541c8219 |
comparison
equal
deleted
inserted
replaced
20008:173f2683e3c4 | 20009:09bc233eb018 |
---|---|
1 ;;; finder.el --- topic & keyword-based code finder | 1 ;;; finder.el --- topic & keyword-based code finder |
2 | 2 |
3 ;; Copyright (C) 1992 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1992, 1997 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com> | 5 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com> |
6 ;; Created: 16 Jun 1992 | 6 ;; Created: 16 Jun 1992 |
7 ;; Version: 1.0 | 7 ;; Version: 1.0 |
8 ;; Keywords: help | 8 ;; Keywords: help |
85 (defvar finder-mode-map nil) | 85 (defvar finder-mode-map nil) |
86 (or finder-mode-map | 86 (or finder-mode-map |
87 (let ((map (make-sparse-keymap))) | 87 (let ((map (make-sparse-keymap))) |
88 (define-key map " " 'finder-select) | 88 (define-key map " " 'finder-select) |
89 (define-key map "f" 'finder-select) | 89 (define-key map "f" 'finder-select) |
90 (define-key map [mouse-2] 'finder-mouse-select) | |
90 (define-key map "\C-m" 'finder-select) | 91 (define-key map "\C-m" 'finder-select) |
91 (define-key map "?" 'finder-summary) | 92 (define-key map "?" 'finder-summary) |
92 (define-key map "q" 'finder-exit) | 93 (define-key map "q" 'finder-exit) |
93 (define-key map "d" 'finder-list-keywords) | 94 (define-key map "d" 'finder-list-keywords) |
94 (setq finder-mode-map map))) | 95 (setq finder-mode-map map))) |
115 (insert "\n(setq finder-package-info '(\n") | 116 (insert "\n(setq finder-package-info '(\n") |
116 (mapcar | 117 (mapcar |
117 (lambda (d) | 118 (lambda (d) |
118 (mapcar | 119 (mapcar |
119 (lambda (f) | 120 (lambda (f) |
120 (if (and (string-match "^[^=.].*\\.el$" f) | 121 (if (and (or (string-match "^[^=].*\\.el$" f) |
122 ;; Allow compressed files also. Fixme: | |
123 ;; generalize this, especially for | |
124 ;; MS-DOG-type filenames. | |
125 (and (string-match "^[^=].*\\.el\\.\\(gz\\|Z\\)$" f) | |
126 (require 'jka-compr))) | |
121 (not (member f processed))) | 127 (not (member f processed))) |
122 (let (summary keystart keywords) | 128 (let (summary keystart keywords) |
123 (setq processed (cons f processed)) | 129 (setq processed (cons f processed)) |
124 (save-excursion | 130 (save-excursion |
125 (set-buffer (get-buffer-create "*finder-scratch*")) | 131 (set-buffer (get-buffer-create "*finder-scratch*")) |
128 (insert-file-contents | 134 (insert-file-contents |
129 (concat (file-name-as-directory (or d ".")) f)) | 135 (concat (file-name-as-directory (or d ".")) f)) |
130 (setq summary (lm-synopsis)) | 136 (setq summary (lm-synopsis)) |
131 (setq keywords (lm-keywords))) | 137 (setq keywords (lm-keywords))) |
132 (insert | 138 (insert |
133 (format " (\"%s\"\n " f)) | 139 (format " (\"%s\"\n " |
140 (if (string-match "\\.\\(gz\\|Z\\)$" f) | |
141 (file-name-sans-extension f) | |
142 f))) | |
134 (prin1 summary (current-buffer)) | 143 (prin1 summary (current-buffer)) |
135 (insert | 144 (insert |
136 "\n ") | 145 "\n ") |
137 (setq keystart (point)) | 146 (setq keystart (point)) |
138 (insert | 147 (insert |
213 (setq buffer-read-only t) | 222 (setq buffer-read-only t) |
214 (set-buffer-modified-p nil) | 223 (set-buffer-modified-p nil) |
215 (shrink-window-if-larger-than-buffer) | 224 (shrink-window-if-larger-than-buffer) |
216 (finder-summary))) | 225 (finder-summary))) |
217 | 226 |
218 ;; Search for a file named FILE the same way `load' would search. | |
219 (defun finder-find-library (file) | |
220 (if (file-name-absolute-p file) | |
221 file | |
222 (let ((dirs load-path) | |
223 found) | |
224 (while (and dirs (not found)) | |
225 (if (file-exists-p (expand-file-name (concat file ".el") (car dirs))) | |
226 (setq found (expand-file-name file (car dirs))) | |
227 (if (file-exists-p (expand-file-name file (car dirs))) | |
228 (setq found (expand-file-name file (car dirs))))) | |
229 (setq dirs (cdr dirs))) | |
230 found))) | |
231 | |
232 (defun finder-commentary (file) | 227 (defun finder-commentary (file) |
233 (interactive) | 228 (interactive) |
234 (let* ((str (lm-commentary (finder-find-library file)))) | 229 (let* ((str (lm-commentary (locate-library file)))) |
235 (if (null str) | 230 (if (null str) |
236 (error "Can't find any Commentary section")) | 231 (error "Can't find any Commentary section")) |
237 (pop-to-buffer "*Finder*") | 232 (pop-to-buffer "*Finder*") |
238 (setq buffer-read-only nil) | 233 (setq buffer-read-only nil) |
239 (erase-buffer) | 234 (erase-buffer) |
259 (current-word)))) | 254 (current-word)))) |
260 | 255 |
261 (defun finder-select () | 256 (defun finder-select () |
262 (interactive) | 257 (interactive) |
263 (let ((key (finder-current-item))) | 258 (let ((key (finder-current-item))) |
264 (if (string-match "\\.el$" key) | 259 (if (string-match "\\.el$" key) |
265 (finder-commentary key) | 260 (finder-commentary key) |
266 (finder-list-matches key)))) | 261 (finder-list-matches key)))) |
262 | |
263 (defun finder-mouse-select (event) | |
264 (interactive "e") | |
265 (save-excursion | |
266 (set-buffer (window-buffer (posn-window (event-start event)))) | |
267 (goto-char (posn-point (event-start event))) | |
268 (let ((key (finder-current-item))) | |
269 (finder-select)))) | |
267 | 270 |
268 (defun finder-by-keyword () | 271 (defun finder-by-keyword () |
269 "Find packages matching a given keyword." | 272 "Find packages matching a given keyword." |
270 (interactive) | 273 (interactive) |
271 (finder-list-keywords)) | 274 (finder-list-keywords)) |
287 (defun finder-summary () | 290 (defun finder-summary () |
288 "Summarize basic Finder commands." | 291 "Summarize basic Finder commands." |
289 (interactive) | 292 (interactive) |
290 (message "%s" | 293 (message "%s" |
291 (substitute-command-keys | 294 (substitute-command-keys |
292 "\\<finder-mode-map>\\[finder-select] = select, \\[finder-list-keywords] = to finder directory, \\[finder-exit] = quit, \\[finder-summary] = help"))) | 295 "\\<finder-mode-map>\\[finder-select] = select, \\[finder-mouse-select] = select, \\[finder-list-keywords] = to finder directory, \\[finder-exit] = quit, \\[finder-summary] = help"))) |
293 | 296 |
294 (defun finder-exit () | 297 (defun finder-exit () |
295 "Exit Finder mode and kill the buffer" | 298 "Exit Finder mode and kill the buffer" |
296 (interactive) | 299 (interactive) |
297 (delete-window) | 300 (condition-case nil ; might be sole window |
298 (kill-buffer "*Finder*")) | 301 (delete-window) |
302 (error nil)) | |
303 ;; Can happen in either buffer -- kill each of the two that exists | |
304 (condition-case nil | |
305 (kill-buffer "*Finder*") | |
306 (error nil)) | |
307 (condition-case nil | |
308 (kill-buffer "*Finder Category*") | |
309 (error nil))) | |
299 | 310 |
300 (provide 'finder) | 311 (provide 'finder) |
301 | 312 |
302 ;;; finder.el ends here | 313 ;;; finder.el ends here |