From 381c0bfaf2104295f25c4cc0ea68e881ed37170e Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Mon, 29 Dec 2014 04:21:51 +0200 Subject: [PATCH] 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. --- lisp/ChangeLog | 13 +++++++++++++ lisp/emacs-lisp/find-func.el | 28 +++++++++++++++++----------- lisp/menu-bar.el | 10 ---------- lisp/progmodes/elisp-mode.el | 38 +++++++++++++++++++++----------------- 4 files changed, 51 insertions(+), 38 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 37f3892e2cb..1d2aa9b96a0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,16 @@ +2014-12-29 Dmitry Gutov + + 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 * comint.el (comint-history-isearch-message): Use field-beginning diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index e1586a96716..3131be09eb1 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -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. diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 74a807095dc..c5f587eb719 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -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") diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index ac216d99cce..c6cab1257a5 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -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 -- 2.11.4.GIT