Unbreak jumping to an alias's definition
* lisp/emacs-lisp/find-func.el (find-function-library): Return a pair (ORIG-FUNCTION . LIBRARY) instead of just its second element. (find-function-noselect): Use it. * lisp/progmodes/elisp-mode.el (elisp--xref-identifier-file): Rename to `elisp--xref-identifier-location', incorporate logic from `elisp--xref-find-definitions', use the changed `find-function-library' return value.
This commit is contained in:
parent
ceed9dd191
commit
381c0bfaf2
4 changed files with 51 additions and 38 deletions
|
@ -1,3 +1,16 @@
|
|||
2014-12-29 Dmitry Gutov <dgutov@yandex.ru>
|
||||
|
||||
Unbreak jumping to an alias's definition.
|
||||
|
||||
* emacs-lisp/find-func.el (find-function-library): Return a pair
|
||||
(ORIG-FUNCTION . LIBRARY) instead of just its second element.
|
||||
(find-function-noselect): Use it.
|
||||
|
||||
* progmodes/elisp-mode.el (elisp--xref-identifier-file): Rename to
|
||||
`elisp--xref-identifier-location', incorporate logic from
|
||||
`elisp--xref-find-definitions', use the changed
|
||||
`find-function-library' return value.
|
||||
|
||||
2014-12-29 Juri Linkov <juri@linkov.net>
|
||||
|
||||
* comint.el (comint-history-isearch-message): Use field-beginning
|
||||
|
|
|
@ -312,9 +312,14 @@ The search is done in the source for library LIBRARY."
|
|||
(cons (current-buffer) nil))))))))
|
||||
|
||||
(defun find-function-library (function &optional lisp-only verbose)
|
||||
"Return the library FUNCTION is defined in.
|
||||
"Return the pair (ORIG-FUNCTION . LIBRARY) for FUNCTION.
|
||||
|
||||
If FUNCTION is a built-in function and LISP-ONLY is non-nil,
|
||||
ORIG-FUNCTION is the original name, after removing all advice and
|
||||
resolving aliases. LIBRARY is an absolute file name, a relative
|
||||
file name inside the C sources directory, or a name of an
|
||||
autoloaded feature.
|
||||
|
||||
If ORIG-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
|
||||
|
@ -336,13 +341,14 @@ message about the whole chain of aliases."
|
|||
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)))))
|
||||
(cons function
|
||||
(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)
|
||||
|
@ -362,8 +368,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 ((library (find-function-library function lisp-only t)))
|
||||
(find-function-search-for-symbol function nil library)))
|
||||
(let ((func-lib (find-function-library function lisp-only t)))
|
||||
(find-function-search-for-symbol (car func-lib) nil (cdr func-lib))))
|
||||
|
||||
(defun find-function-read (&optional type)
|
||||
"Read and return an interned symbol, defaulting to the one near point.
|
||||
|
|
|
@ -507,16 +507,6 @@
|
|||
|
||||
menu))
|
||||
|
||||
(defun menu-bar-next-tag-other-window ()
|
||||
"Find the next definition of the tag already specified."
|
||||
(interactive)
|
||||
(find-tag-other-window nil t))
|
||||
|
||||
(defun menu-bar-next-tag ()
|
||||
"Find the next definition of the tag already specified."
|
||||
(interactive)
|
||||
(find-tag nil t))
|
||||
|
||||
(define-obsolete-function-alias
|
||||
'menu-bar-kill-ring-save 'kill-ring-save "24.1")
|
||||
|
||||
|
|
|
@ -570,18 +570,26 @@ It can be quoted, or be inside a quoted form."
|
|||
(`apropos
|
||||
(elisp--xref-find-apropos id))))
|
||||
|
||||
(defun elisp--xref-identifier-file (type sym)
|
||||
(pcase type
|
||||
(`defun (when (fboundp sym)
|
||||
(find-function-library sym)))
|
||||
(`defvar (when (boundp sym)
|
||||
(or (symbol-file sym 'defvar)
|
||||
(help-C-file-name sym 'var))))
|
||||
(`feature (when (featurep sym)
|
||||
(ignore-errors
|
||||
(find-library-name (symbol-name sym)))))
|
||||
(`defface (when (facep sym)
|
||||
(symbol-file sym 'defface)))))
|
||||
(defun elisp--xref-identifier-location (type sym)
|
||||
(let ((file
|
||||
(pcase type
|
||||
(`defun (when (fboundp sym)
|
||||
(let ((fun-lib
|
||||
(find-function-library sym)))
|
||||
(setq sym (car fun-lib))
|
||||
(cdr fun-lib))))
|
||||
(`defvar (when (boundp sym)
|
||||
(or (symbol-file sym 'defvar)
|
||||
(help-C-file-name sym 'var))))
|
||||
(`feature (when (featurep sym)
|
||||
(ignore-errors
|
||||
(find-library-name (symbol-name sym)))))
|
||||
(`defface (when (facep sym)
|
||||
(symbol-file sym 'defface))))))
|
||||
(when file
|
||||
(when (string-match-p "\\.elc\\'" file)
|
||||
(setq file (substring file 0 -1)))
|
||||
(xref-make-elisp-location sym type file))))
|
||||
|
||||
(defun elisp--xref-find-definitions (symbol)
|
||||
(save-excursion
|
||||
|
@ -589,11 +597,7 @@ It can be quoted, or be inside a quoted form."
|
|||
(dolist (type '(feature defface defvar defun))
|
||||
(let ((loc
|
||||
(condition-case err
|
||||
(let ((file (elisp--xref-identifier-file type symbol)))
|
||||
(when file
|
||||
(when (string-match-p "\\.elc\\'" file)
|
||||
(setq file (substring file 0 -1)))
|
||||
(xref-make-elisp-location symbol type file)))
|
||||
(elisp--xref-identifier-location type symbol)
|
||||
(error
|
||||
(xref-make-bogus-location (error-message-string err))))))
|
||||
(when loc
|
||||
|
|
Loading…
Add table
Reference in a new issue