mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-22 10:26:20 +00:00
(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.
This commit is contained in:
parent
274c59c95c
commit
f3b330d6d8
@ -1,6 +1,6 @@
|
|||||||
;;; finder.el --- topic & keyword-based code finder
|
;;; finder.el --- topic & keyword-based code finder
|
||||||
|
|
||||||
;; Copyright (C) 1992 Free Software Foundation, Inc.
|
;; Copyright (C) 1992, 1997 Free Software Foundation, Inc.
|
||||||
|
|
||||||
;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
|
;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
|
||||||
;; Created: 16 Jun 1992
|
;; Created: 16 Jun 1992
|
||||||
@ -87,6 +87,7 @@
|
|||||||
(let ((map (make-sparse-keymap)))
|
(let ((map (make-sparse-keymap)))
|
||||||
(define-key map " " 'finder-select)
|
(define-key map " " 'finder-select)
|
||||||
(define-key map "f" 'finder-select)
|
(define-key map "f" 'finder-select)
|
||||||
|
(define-key map [mouse-2] 'finder-mouse-select)
|
||||||
(define-key map "\C-m" 'finder-select)
|
(define-key map "\C-m" 'finder-select)
|
||||||
(define-key map "?" 'finder-summary)
|
(define-key map "?" 'finder-summary)
|
||||||
(define-key map "q" 'finder-exit)
|
(define-key map "q" 'finder-exit)
|
||||||
@ -117,7 +118,12 @@ arguments compiles from `load-path'."
|
|||||||
(lambda (d)
|
(lambda (d)
|
||||||
(mapcar
|
(mapcar
|
||||||
(lambda (f)
|
(lambda (f)
|
||||||
(if (and (string-match "^[^=.].*\\.el$" f)
|
(if (and (or (string-match "^[^=].*\\.el$" f)
|
||||||
|
;; Allow compressed files also. Fixme:
|
||||||
|
;; generalize this, especially for
|
||||||
|
;; MS-DOG-type filenames.
|
||||||
|
(and (string-match "^[^=].*\\.el\\.\\(gz\\|Z\\)$" f)
|
||||||
|
(require 'jka-compr)))
|
||||||
(not (member f processed)))
|
(not (member f processed)))
|
||||||
(let (summary keystart keywords)
|
(let (summary keystart keywords)
|
||||||
(setq processed (cons f processed))
|
(setq processed (cons f processed))
|
||||||
@ -130,7 +136,10 @@ arguments compiles from `load-path'."
|
|||||||
(setq summary (lm-synopsis))
|
(setq summary (lm-synopsis))
|
||||||
(setq keywords (lm-keywords)))
|
(setq keywords (lm-keywords)))
|
||||||
(insert
|
(insert
|
||||||
(format " (\"%s\"\n " f))
|
(format " (\"%s\"\n "
|
||||||
|
(if (string-match "\\.\\(gz\\|Z\\)$" f)
|
||||||
|
(file-name-sans-extension f)
|
||||||
|
f)))
|
||||||
(prin1 summary (current-buffer))
|
(prin1 summary (current-buffer))
|
||||||
(insert
|
(insert
|
||||||
"\n ")
|
"\n ")
|
||||||
@ -215,23 +224,9 @@ arguments compiles from `load-path'."
|
|||||||
(shrink-window-if-larger-than-buffer)
|
(shrink-window-if-larger-than-buffer)
|
||||||
(finder-summary)))
|
(finder-summary)))
|
||||||
|
|
||||||
;; Search for a file named FILE the same way `load' would search.
|
|
||||||
(defun finder-find-library (file)
|
|
||||||
(if (file-name-absolute-p file)
|
|
||||||
file
|
|
||||||
(let ((dirs load-path)
|
|
||||||
found)
|
|
||||||
(while (and dirs (not found))
|
|
||||||
(if (file-exists-p (expand-file-name (concat file ".el") (car dirs)))
|
|
||||||
(setq found (expand-file-name file (car dirs)))
|
|
||||||
(if (file-exists-p (expand-file-name file (car dirs)))
|
|
||||||
(setq found (expand-file-name file (car dirs)))))
|
|
||||||
(setq dirs (cdr dirs)))
|
|
||||||
found)))
|
|
||||||
|
|
||||||
(defun finder-commentary (file)
|
(defun finder-commentary (file)
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((str (lm-commentary (finder-find-library file))))
|
(let* ((str (lm-commentary (locate-library file))))
|
||||||
(if (null str)
|
(if (null str)
|
||||||
(error "Can't find any Commentary section"))
|
(error "Can't find any Commentary section"))
|
||||||
(pop-to-buffer "*Finder*")
|
(pop-to-buffer "*Finder*")
|
||||||
@ -261,9 +256,17 @@ arguments compiles from `load-path'."
|
|||||||
(defun finder-select ()
|
(defun finder-select ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((key (finder-current-item)))
|
(let ((key (finder-current-item)))
|
||||||
(if (string-match "\\.el$" key)
|
(if (string-match "\\.el$" key)
|
||||||
(finder-commentary key)
|
(finder-commentary key)
|
||||||
(finder-list-matches key))))
|
(finder-list-matches key))))
|
||||||
|
|
||||||
|
(defun finder-mouse-select (event)
|
||||||
|
(interactive "e")
|
||||||
|
(save-excursion
|
||||||
|
(set-buffer (window-buffer (posn-window (event-start event))))
|
||||||
|
(goto-char (posn-point (event-start event)))
|
||||||
|
(let ((key (finder-current-item)))
|
||||||
|
(finder-select))))
|
||||||
|
|
||||||
(defun finder-by-keyword ()
|
(defun finder-by-keyword ()
|
||||||
"Find packages matching a given keyword."
|
"Find packages matching a given keyword."
|
||||||
@ -289,13 +292,21 @@ arguments compiles from `load-path'."
|
|||||||
(interactive)
|
(interactive)
|
||||||
(message "%s"
|
(message "%s"
|
||||||
(substitute-command-keys
|
(substitute-command-keys
|
||||||
"\\<finder-mode-map>\\[finder-select] = select, \\[finder-list-keywords] = to finder directory, \\[finder-exit] = quit, \\[finder-summary] = help")))
|
"\\<finder-mode-map>\\[finder-select] = select, \\[finder-mouse-select] = select, \\[finder-list-keywords] = to finder directory, \\[finder-exit] = quit, \\[finder-summary] = help")))
|
||||||
|
|
||||||
(defun finder-exit ()
|
(defun finder-exit ()
|
||||||
"Exit Finder mode and kill the buffer"
|
"Exit Finder mode and kill the buffer"
|
||||||
(interactive)
|
(interactive)
|
||||||
(delete-window)
|
(condition-case nil ; might be sole window
|
||||||
(kill-buffer "*Finder*"))
|
(delete-window)
|
||||||
|
(error nil))
|
||||||
|
;; Can happen in either buffer -- kill each of the two that exists
|
||||||
|
(condition-case nil
|
||||||
|
(kill-buffer "*Finder*")
|
||||||
|
(error nil))
|
||||||
|
(condition-case nil
|
||||||
|
(kill-buffer "*Finder Category*")
|
||||||
|
(error nil)))
|
||||||
|
|
||||||
(provide 'finder)
|
(provide 'finder)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user