Mercurial > emacs
comparison lisp/emacs-lisp/find-func.el @ 111084:8c55e138333b
* lisp/emacs-lisp/find-func.el (find-library): Use test-completion.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 21 Oct 2010 23:17:26 -0400 |
parents | 1d1d5d9bd884 |
children | 417b1e4d63cd |
comparison
equal
deleted
inserted
replaced
111083:9a8bf31cd307 | 111084:8c55e138333b |
---|---|
211 "Find the Emacs Lisp source of LIBRARY. | 211 "Find the Emacs Lisp source of LIBRARY. |
212 LIBRARY should be a string (the name of the library)." | 212 LIBRARY should be a string (the name of the library)." |
213 (interactive | 213 (interactive |
214 (let* ((dirs (or find-function-source-path load-path)) | 214 (let* ((dirs (or find-function-source-path load-path)) |
215 (suffixes (find-library-suffixes)) | 215 (suffixes (find-library-suffixes)) |
216 (table (apply-partially 'locate-file-completion-table | |
217 dirs suffixes)) | |
216 (def (if (eq (function-called-at-point) 'require) | 218 (def (if (eq (function-called-at-point) 'require) |
217 ;; `function-called-at-point' may return 'require | 219 ;; `function-called-at-point' may return 'require |
218 ;; with `point' anywhere on this line. So wrap the | 220 ;; with `point' anywhere on this line. So wrap the |
219 ;; `save-excursion' below in a `condition-case' to | 221 ;; `save-excursion' below in a `condition-case' to |
220 ;; avoid reporting a scan-error here. | 222 ;; avoid reporting a scan-error here. |
224 (forward-char) | 226 (forward-char) |
225 (forward-sexp 2) | 227 (forward-sexp 2) |
226 (thing-at-point 'symbol)) | 228 (thing-at-point 'symbol)) |
227 (error nil)) | 229 (error nil)) |
228 (thing-at-point 'symbol)))) | 230 (thing-at-point 'symbol)))) |
229 (when def | 231 (when (and def (not (test-completion def table))) |
230 (setq def (and (locate-file-completion-table | 232 (setq def nil)) |
231 dirs suffixes def nil 'lambda) | |
232 def))) | |
233 (list | 233 (list |
234 (completing-read (if def (format "Library name (default %s): " def) | 234 (completing-read (if def (format "Library name (default %s): " def) |
235 "Library name: ") | 235 "Library name: ") |
236 (apply-partially 'locate-file-completion-table | 236 table nil nil nil nil def)))) |
237 dirs suffixes) | |
238 nil nil nil nil def)))) | |
239 (let ((buf (find-file-noselect (find-library-name library)))) | 237 (let ((buf (find-file-noselect (find-library-name library)))) |
240 (condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf))))) | 238 (condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf))))) |
241 | 239 |
242 ;;;###autoload | 240 ;;;###autoload |
243 (defun find-function-search-for-symbol (symbol type library) | 241 (defun find-function-search-for-symbol (symbol type library) |