Commit 381c0bfa authored by Dmitry Gutov's avatar Dmitry Gutov

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.
parent ceed9dd1
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> 2014-12-29 Juri Linkov <juri@linkov.net>
* comint.el (comint-history-isearch-message): Use field-beginning * comint.el (comint-history-isearch-message): Use field-beginning
......
...@@ -312,9 +312,14 @@ The search is done in the source for library LIBRARY." ...@@ -312,9 +312,14 @@ The search is done in the source for library LIBRARY."
(cons (current-buffer) nil)))))))) (cons (current-buffer) nil))))))))
(defun find-function-library (function &optional lisp-only verbose) (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. signal an error.
If VERBOSE is non-nil, and FUNCTION is an alias, display a If VERBOSE is non-nil, and FUNCTION is an alias, display a
...@@ -336,13 +341,14 @@ message about the whole chain of aliases." ...@@ -336,13 +341,14 @@ message about the whole chain of aliases."
def (symbol-function (find-function-advised-original function)))) def (symbol-function (find-function-advised-original function))))
(if aliases (if aliases
(message "%s" aliases)) (message "%s" aliases))
(cond (cons function
((autoloadp def) (nth 1 def)) (cond
((subrp def) ((autoloadp def) (nth 1 def))
(if lisp-only ((subrp def)
(error "%s is a built-in function" function)) (if lisp-only
(help-C-file-name def 'subr)) (error "%s is a built-in function" function))
((symbol-file function 'defun))))) (help-C-file-name def 'subr))
((symbol-file function 'defun))))))
;;;###autoload ;;;###autoload
(defun find-function-noselect (function &optional lisp-only) (defun find-function-noselect (function &optional lisp-only)
...@@ -362,8 +368,8 @@ searched for in `find-function-source-path' if non-nil, otherwise ...@@ -362,8 +368,8 @@ searched for in `find-function-source-path' if non-nil, otherwise
in `load-path'." in `load-path'."
(if (not function) (if (not function)
(error "You didn't specify a function")) (error "You didn't specify a function"))
(let ((library (find-function-library function lisp-only t))) (let ((func-lib (find-function-library function lisp-only t)))
(find-function-search-for-symbol function nil library))) (find-function-search-for-symbol (car func-lib) nil (cdr func-lib))))
(defun find-function-read (&optional type) (defun find-function-read (&optional type)
"Read and return an interned symbol, defaulting to the one near point. "Read and return an interned symbol, defaulting to the one near point.
......
...@@ -507,16 +507,6 @@ ...@@ -507,16 +507,6 @@
menu)) 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 (define-obsolete-function-alias
'menu-bar-kill-ring-save 'kill-ring-save "24.1") 'menu-bar-kill-ring-save 'kill-ring-save "24.1")
......
...@@ -570,18 +570,26 @@ It can be quoted, or be inside a quoted form." ...@@ -570,18 +570,26 @@ It can be quoted, or be inside a quoted form."
(`apropos (`apropos
(elisp--xref-find-apropos id)))) (elisp--xref-find-apropos id))))
(defun elisp--xref-identifier-file (type sym) (defun elisp--xref-identifier-location (type sym)
(pcase type (let ((file
(`defun (when (fboundp sym) (pcase type
(find-function-library sym))) (`defun (when (fboundp sym)
(`defvar (when (boundp sym) (let ((fun-lib
(or (symbol-file sym 'defvar) (find-function-library sym)))
(help-C-file-name sym 'var)))) (setq sym (car fun-lib))
(`feature (when (featurep sym) (cdr fun-lib))))
(ignore-errors (`defvar (when (boundp sym)
(find-library-name (symbol-name sym))))) (or (symbol-file sym 'defvar)
(`defface (when (facep sym) (help-C-file-name sym 'var))))
(symbol-file sym 'defface))))) (`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) (defun elisp--xref-find-definitions (symbol)
(save-excursion (save-excursion
...@@ -589,11 +597,7 @@ It can be quoted, or be inside a quoted form." ...@@ -589,11 +597,7 @@ It can be quoted, or be inside a quoted form."
(dolist (type '(feature defface defvar defun)) (dolist (type '(feature defface defvar defun))
(let ((loc (let ((loc
(condition-case err (condition-case err
(let ((file (elisp--xref-identifier-file type symbol))) (elisp--xref-identifier-location type symbol)
(when file
(when (string-match-p "\\.elc\\'" file)
(setq file (substring file 0 -1)))
(xref-make-elisp-location symbol type file)))
(error (error
(xref-make-bogus-location (error-message-string err)))))) (xref-make-bogus-location (error-message-string err))))))
(when loc (when loc
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment