aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier <[email protected]>2002-09-09 21:50:36 +0000
committerStefan Monnier <[email protected]>2002-09-09 21:50:36 +0000
commitf77a605054bbfbeb450701fdc5b4ed12acd3d9d5 (patch)
tree0419ad19fcd2ea1cbdf06eae3fd6ae43aec1b8fe
parent4f6d5bf0090c9e9de4f70eef4a21fd4c1feda082 (diff)
(find-library-suffixes, find-library-name)
(find-library): New funs. (find-function-search-for-symbol): Use it.
-rw-r--r--lisp/emacs-lisp/find-func.el46
1 files changed, 29 insertions, 17 deletions
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index 6e49140923..40016cec92 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -112,6 +112,34 @@ See the functions `find-function' and `find-variable'."
;;; Functions:
+(defun find-library-suffixes ()
+ (let ((suffixes nil))
+ (dolist (suffix load-suffixes (nreverse suffixes))
+ (unless (string-match "elc" suffix) (push suffix suffixes)))))
+
+(defun find-library-name (library)
+ "Return the full name of the elisp source of LIBRARY."
+ ;; If the library is byte-compiled, try to find a source library by
+ ;; the same name.
+ (if (string-match "\\.el\\(c\\(\\..*\\)\\)\\'" library)
+ (setq library (replace-match "" t t library 1)))
+ (or (locate-file library
+ (or find-function-source-path load-path)
+ (find-library-suffixes))
+ (error "Can't find library %s" file)))
+
+;;;###autoload
+(defun find-library (library)
+ "Find the elisp source of LIBRARY."
+ (interactive
+ (list
+ (completing-read "Library name: "
+ 'locate-file-completion
+ (cons (or find-function-source-path load-path)
+ (find-library-suffixes)))))
+ (let ((buf (find-file-noselect (find-library-name library))))
+ (condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf)))))
+
;;;###autoload
(defun find-function-search-for-symbol (symbol variable-p library)
"Search for SYMBOL.
@@ -126,23 +154,7 @@ If VARIABLE-P is nil, `find-function-regexp' is used, otherwise
(save-match-data
(if (string-match "\\.el\\(c\\)\\'" library)
(setq library (substring library 0 (match-beginning 1))))
- (let* ((path find-function-source-path)
- (compression (or (rassq 'jka-compr-handler file-name-handler-alist)
- (member 'crypt-find-file-hook find-file-hook)))
- (filename (progn
- ;; use `file-name-sans-extension' here? (if it gets fixed)
- (if (string-match "\\(\\.el\\)\\'" library)
- (setq library (substring library 0
- (match-beginning 1))))
- (or (locate-library (concat library ".el") t path)
- (locate-library library t path)
- (if compression
- (or (locate-library (concat library ".el.gz")
- t path)
- (locate-library (concat library ".gz")
- t path)))))))
- (if (not filename)
- (error "The library `%s' is not in the path" library))
+ (let* ((filename (find-library-name library)))
(with-current-buffer (find-file-noselect filename)
(let ((regexp (format (if variable-p
find-variable-regexp