aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2002-09-09 21:50:36 +0000
committerStefan Monnier2002-09-09 21:50:36 +0000
commitf77a605054bbfbeb450701fdc5b4ed12acd3d9d5 (patch)
tree0419ad19fcd2ea1cbdf06eae3fd6ae43aec1b8fe
parent4f6d5bf0090c9e9de4f70eef4a21fd4c1feda082 (diff)
downloademacs-f77a605054bbfbeb450701fdc5b4ed12acd3d9d5.tar.gz
emacs-f77a605054bbfbeb450701fdc5b4ed12acd3d9d5.zip
(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 6e491409233..40016cec928 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'."
112 112
113;;; Functions: 113;;; Functions:
114 114
115(defun find-library-suffixes ()
116 (let ((suffixes nil))
117 (dolist (suffix load-suffixes (nreverse suffixes))
118 (unless (string-match "elc" suffix) (push suffix suffixes)))))
119
120(defun find-library-name (library)
121 "Return the full name of the elisp source of LIBRARY."
122 ;; If the library is byte-compiled, try to find a source library by
123 ;; the same name.
124 (if (string-match "\\.el\\(c\\(\\..*\\)\\)\\'" library)
125 (setq library (replace-match "" t t library 1)))
126 (or (locate-file library
127 (or find-function-source-path load-path)
128 (find-library-suffixes))
129 (error "Can't find library %s" file)))
130
131;;;###autoload
132(defun find-library (library)
133 "Find the elisp source of LIBRARY."
134 (interactive
135 (list
136 (completing-read "Library name: "
137 'locate-file-completion
138 (cons (or find-function-source-path load-path)
139 (find-library-suffixes)))))
140 (let ((buf (find-file-noselect (find-library-name library))))
141 (condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf)))))
142
115;;;###autoload 143;;;###autoload
116(defun find-function-search-for-symbol (symbol variable-p library) 144(defun find-function-search-for-symbol (symbol variable-p library)
117 "Search for SYMBOL. 145 "Search for SYMBOL.
@@ -126,23 +154,7 @@ If VARIABLE-P is nil, `find-function-regexp' is used, otherwise
126 (save-match-data 154 (save-match-data
127 (if (string-match "\\.el\\(c\\)\\'" library) 155 (if (string-match "\\.el\\(c\\)\\'" library)
128 (setq library (substring library 0 (match-beginning 1)))) 156 (setq library (substring library 0 (match-beginning 1))))
129 (let* ((path find-function-source-path) 157 (let* ((filename (find-library-name library)))
130 (compression (or (rassq 'jka-compr-handler file-name-handler-alist)
131 (member 'crypt-find-file-hook find-file-hook)))
132 (filename (progn
133 ;; use `file-name-sans-extension' here? (if it gets fixed)
134 (if (string-match "\\(\\.el\\)\\'" library)
135 (setq library (substring library 0
136 (match-beginning 1))))
137 (or (locate-library (concat library ".el") t path)
138 (locate-library library t path)
139 (if compression
140 (or (locate-library (concat library ".el.gz")
141 t path)
142 (locate-library (concat library ".gz")
143 t path)))))))
144 (if (not filename)
145 (error "The library `%s' is not in the path" library))
146 (with-current-buffer (find-file-noselect filename) 158 (with-current-buffer (find-file-noselect filename)
147 (let ((regexp (format (if variable-p 159 (let ((regexp (format (if variable-p
148 find-variable-regexp 160 find-variable-regexp