diff options
author | Dmitry Gutov <dgutov@yandex.ru> | 2014-12-27 16:06:37 +0200 |
---|---|---|
committer | Dmitry Gutov <dgutov@yandex.ru> | 2014-12-27 16:07:31 +0200 |
commit | 6d14e0d361cfb3589874fe1b559e30b4fd3eb284 (patch) | |
tree | d358b0ef77e8e814113d274df1596c2489634d70 /lisp/emacs-lisp | |
parent | 09d2e8477aa64308447395a0f01cfe5414619811 (diff) | |
download | emacs-6d14e0d361cfb3589874fe1b559e30b4fd3eb284.tar.gz emacs-6d14e0d361cfb3589874fe1b559e30b4fd3eb284.tar.bz2 emacs-6d14e0d361cfb3589874fe1b559e30b4fd3eb284.zip |
elisp-xref-find: Don't create buffers eagerly
* lisp/emacs-lisp/find-func.el (find-function-library): New function,
extracted from `find-function-noselect'.
* lisp/progmodes/elisp-mode.el (elisp--identifier-location): Fold back
into `elisp--company-location'.
(elisp--identifier-completion-table): Rename to
`elisp--identifier-completion-table', and do not include just any
symbols with a property list.
(elisp-completion-at-point): Revert the 2014-12-25 change.
(elisp--xref-identifier-file): New function.
(elisp--xref-find-definitions): Use it.
* lisp/progmodes/xref.el (xref-elisp-location): New class.
(xref-make-elisp-location): New function.
(xref-location-marker): New implementation.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/find-func.el | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index c372117b104..e1586a96716 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -311,6 +311,39 @@ The search is done in the source for library LIBRARY." (cons (current-buffer) (point))) (cons (current-buffer) nil)))))))) +(defun find-function-library (function &optional lisp-only verbose) + "Return the library FUNCTION is defined in. + +If FUNCTION is a built-in function and LISP-ONLY is non-nil, +signal an error. + +If VERBOSE is non-nil, and FUNCTION is an alias, display a +message about the whole chain of aliases." + (let ((def (symbol-function (find-function-advised-original function))) + aliases) + ;; FIXME for completeness, it might be nice to print something like: + ;; foo (which is advised), which is an alias for bar (which is advised). + (while (symbolp def) + (or (eq def function) + (not verbose) + (if aliases + (setq aliases (concat aliases + (format ", which is an alias for `%s'" + (symbol-name def)))) + (setq aliases (format "`%s' is an alias for `%s'" + function (symbol-name def))))) + (setq function (symbol-function (find-function-advised-original function)) + def (symbol-function (find-function-advised-original function)))) + (if aliases + (message "%s" aliases)) + (cond + ((autoloadp def) (nth 1 def)) + ((subrp def) + (if lisp-only + (error "%s is a built-in function" function)) + (help-C-file-name def 'subr)) + ((symbol-file function 'defun))))) + ;;;###autoload (defun find-function-noselect (function &optional lisp-only) "Return a pair (BUFFER . POINT) pointing to the definition of FUNCTION. @@ -329,30 +362,8 @@ searched for in `find-function-source-path' if non-nil, otherwise in `load-path'." (if (not function) (error "You didn't specify a function")) - (let ((def (symbol-function (find-function-advised-original function))) - aliases) - ;; FIXME for completeness, it might be nice to print something like: - ;; foo (which is advised), which is an alias for bar (which is advised). - (while (symbolp def) - (or (eq def function) - (if aliases - (setq aliases (concat aliases - (format ", which is an alias for `%s'" - (symbol-name def)))) - (setq aliases (format "`%s' is an alias for `%s'" - function (symbol-name def))))) - (setq function (symbol-function (find-function-advised-original function)) - def (symbol-function (find-function-advised-original function)))) - (if aliases - (message "%s" aliases)) - (let ((library - (cond ((autoloadp def) (nth 1 def)) - ((subrp def) - (if lisp-only - (error "%s is a built-in function" function)) - (help-C-file-name def 'subr)) - ((symbol-file function 'defun))))) - (find-function-search-for-symbol function nil library)))) + (let ((library (find-function-library function lisp-only t))) + (find-function-search-for-symbol function nil library))) (defun find-function-read (&optional type) "Read and return an interned symbol, defaulting to the one near point. |