diff options
| author | Dmitry Gutov | 2014-12-29 04:21:51 +0200 |
|---|---|---|
| committer | Dmitry Gutov | 2014-12-29 04:21:51 +0200 |
| commit | 381c0bfaf2104295f25c4cc0ea68e881ed37170e (patch) | |
| tree | d26c236ee7585b6a53f2836c24b331fa7cf2a091 | |
| parent | ceed9dd191c6739489f4ba78d82c21e162f5e95d (diff) | |
| download | emacs-381c0bfaf2104295f25c4cc0ea68e881ed37170e.tar.gz emacs-381c0bfaf2104295f25c4cc0ea68e881ed37170e.zip | |
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.
| -rw-r--r-- | lisp/ChangeLog | 13 | ||||
| -rw-r--r-- | lisp/emacs-lisp/find-func.el | 28 | ||||
| -rw-r--r-- | lisp/menu-bar.el | 10 | ||||
| -rw-r--r-- | 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 @@ | |||
| 1 | 2014-12-29 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | Unbreak jumping to an alias's definition. | ||
| 4 | |||
| 5 | * emacs-lisp/find-func.el (find-function-library): Return a pair | ||
| 6 | (ORIG-FUNCTION . LIBRARY) instead of just its second element. | ||
| 7 | (find-function-noselect): Use it. | ||
| 8 | |||
| 9 | * progmodes/elisp-mode.el (elisp--xref-identifier-file): Rename to | ||
| 10 | `elisp--xref-identifier-location', incorporate logic from | ||
| 11 | `elisp--xref-find-definitions', use the changed | ||
| 12 | `find-function-library' return value. | ||
| 13 | |||
| 1 | 2014-12-29 Juri Linkov <juri@linkov.net> | 14 | 2014-12-29 Juri Linkov <juri@linkov.net> |
| 2 | 15 | ||
| 3 | * comint.el (comint-history-isearch-message): Use field-beginning | 16 | * 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." | |||
| 312 | (cons (current-buffer) nil)))))))) | 312 | (cons (current-buffer) nil)))))))) |
| 313 | 313 | ||
| 314 | (defun find-function-library (function &optional lisp-only verbose) | 314 | (defun find-function-library (function &optional lisp-only verbose) |
| 315 | "Return the library FUNCTION is defined in. | 315 | "Return the pair (ORIG-FUNCTION . LIBRARY) for FUNCTION. |
| 316 | 316 | ||
| 317 | If FUNCTION is a built-in function and LISP-ONLY is non-nil, | 317 | ORIG-FUNCTION is the original name, after removing all advice and |
| 318 | resolving aliases. LIBRARY is an absolute file name, a relative | ||
| 319 | file name inside the C sources directory, or a name of an | ||
| 320 | autoloaded feature. | ||
| 321 | |||
| 322 | If ORIG-FUNCTION is a built-in function and LISP-ONLY is non-nil, | ||
| 318 | signal an error. | 323 | signal an error. |
| 319 | 324 | ||
| 320 | If VERBOSE is non-nil, and FUNCTION is an alias, display a | 325 | If VERBOSE is non-nil, and FUNCTION is an alias, display a |
| @@ -336,13 +341,14 @@ message about the whole chain of aliases." | |||
| 336 | def (symbol-function (find-function-advised-original function)))) | 341 | def (symbol-function (find-function-advised-original function)))) |
| 337 | (if aliases | 342 | (if aliases |
| 338 | (message "%s" aliases)) | 343 | (message "%s" aliases)) |
| 339 | (cond | 344 | (cons function |
| 340 | ((autoloadp def) (nth 1 def)) | 345 | (cond |
| 341 | ((subrp def) | 346 | ((autoloadp def) (nth 1 def)) |
| 342 | (if lisp-only | 347 | ((subrp def) |
| 343 | (error "%s is a built-in function" function)) | 348 | (if lisp-only |
| 344 | (help-C-file-name def 'subr)) | 349 | (error "%s is a built-in function" function)) |
| 345 | ((symbol-file function 'defun))))) | 350 | (help-C-file-name def 'subr)) |
| 351 | ((symbol-file function 'defun)))))) | ||
| 346 | 352 | ||
| 347 | ;;;###autoload | 353 | ;;;###autoload |
| 348 | (defun find-function-noselect (function &optional lisp-only) | 354 | (defun find-function-noselect (function &optional lisp-only) |
| @@ -362,8 +368,8 @@ searched for in `find-function-source-path' if non-nil, otherwise | |||
| 362 | in `load-path'." | 368 | in `load-path'." |
| 363 | (if (not function) | 369 | (if (not function) |
| 364 | (error "You didn't specify a function")) | 370 | (error "You didn't specify a function")) |
| 365 | (let ((library (find-function-library function lisp-only t))) | 371 | (let ((func-lib (find-function-library function lisp-only t))) |
| 366 | (find-function-search-for-symbol function nil library))) | 372 | (find-function-search-for-symbol (car func-lib) nil (cdr func-lib)))) |
| 367 | 373 | ||
| 368 | (defun find-function-read (&optional type) | 374 | (defun find-function-read (&optional type) |
| 369 | "Read and return an interned symbol, defaulting to the one near point. | 375 | "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 @@ | |||
| 507 | 507 | ||
| 508 | menu)) | 508 | menu)) |
| 509 | 509 | ||
| 510 | (defun menu-bar-next-tag-other-window () | ||
| 511 | "Find the next definition of the tag already specified." | ||
| 512 | (interactive) | ||
| 513 | (find-tag-other-window nil t)) | ||
| 514 | |||
| 515 | (defun menu-bar-next-tag () | ||
| 516 | "Find the next definition of the tag already specified." | ||
| 517 | (interactive) | ||
| 518 | (find-tag nil t)) | ||
| 519 | |||
| 520 | (define-obsolete-function-alias | 510 | (define-obsolete-function-alias |
| 521 | 'menu-bar-kill-ring-save 'kill-ring-save "24.1") | 511 | 'menu-bar-kill-ring-save 'kill-ring-save "24.1") |
| 522 | 512 | ||
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." | |||
| 570 | (`apropos | 570 | (`apropos |
| 571 | (elisp--xref-find-apropos id)))) | 571 | (elisp--xref-find-apropos id)))) |
| 572 | 572 | ||
| 573 | (defun elisp--xref-identifier-file (type sym) | 573 | (defun elisp--xref-identifier-location (type sym) |
| 574 | (pcase type | 574 | (let ((file |
| 575 | (`defun (when (fboundp sym) | 575 | (pcase type |
| 576 | (find-function-library sym))) | 576 | (`defun (when (fboundp sym) |
| 577 | (`defvar (when (boundp sym) | 577 | (let ((fun-lib |
| 578 | (or (symbol-file sym 'defvar) | 578 | (find-function-library sym))) |
| 579 | (help-C-file-name sym 'var)))) | 579 | (setq sym (car fun-lib)) |
| 580 | (`feature (when (featurep sym) | 580 | (cdr fun-lib)))) |
| 581 | (ignore-errors | 581 | (`defvar (when (boundp sym) |
| 582 | (find-library-name (symbol-name sym))))) | 582 | (or (symbol-file sym 'defvar) |
| 583 | (`defface (when (facep sym) | 583 | (help-C-file-name sym 'var)))) |
| 584 | (symbol-file sym 'defface))))) | 584 | (`feature (when (featurep sym) |
| 585 | (ignore-errors | ||
| 586 | (find-library-name (symbol-name sym))))) | ||
| 587 | (`defface (when (facep sym) | ||
| 588 | (symbol-file sym 'defface)))))) | ||
| 589 | (when file | ||
| 590 | (when (string-match-p "\\.elc\\'" file) | ||
| 591 | (setq file (substring file 0 -1))) | ||
| 592 | (xref-make-elisp-location sym type file)))) | ||
| 585 | 593 | ||
| 586 | (defun elisp--xref-find-definitions (symbol) | 594 | (defun elisp--xref-find-definitions (symbol) |
| 587 | (save-excursion | 595 | (save-excursion |
| @@ -589,11 +597,7 @@ It can be quoted, or be inside a quoted form." | |||
| 589 | (dolist (type '(feature defface defvar defun)) | 597 | (dolist (type '(feature defface defvar defun)) |
| 590 | (let ((loc | 598 | (let ((loc |
| 591 | (condition-case err | 599 | (condition-case err |
| 592 | (let ((file (elisp--xref-identifier-file type symbol))) | 600 | (elisp--xref-identifier-location type symbol) |
| 593 | (when file | ||
| 594 | (when (string-match-p "\\.elc\\'" file) | ||
| 595 | (setq file (substring file 0 -1))) | ||
| 596 | (xref-make-elisp-location symbol type file))) | ||
| 597 | (error | 601 | (error |
| 598 | (xref-make-bogus-location (error-message-string err)))))) | 602 | (xref-make-bogus-location (error-message-string err)))))) |
| 599 | (when loc | 603 | (when loc |