diff options
| author | Dmitry Gutov | 2015-05-05 15:11:14 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2015-05-05 15:11:14 +0300 |
| commit | fbe7fb054755b9bfe1375691d3c774cb84236859 (patch) | |
| tree | 617eae11afd598eb56df23620bf9666215cf1b7f | |
| parent | 6337f2434e3385d4d35240789cdcc9037be7bd01 (diff) | |
| download | emacs-fbe7fb054755b9bfe1375691d3c774cb84236859.tar.gz emacs-fbe7fb054755b9bfe1375691d3c774cb84236859.zip | |
Only skip some variables that have function counterparts
* lisp/progmodes/elisp-mode.el (elisp--xref-identifier-location):
Only skip minor-mode-named variable if it's defined in a Lisp
file, and it's in minor-mode-list (bug#20506).
* test/automated/elisp-mode-tests.el
(elisp-xref-finds-both-function-and-variable)
(elisp-xref-finds-only-function-for-minor-mode): New tests.
| -rw-r--r-- | lisp/progmodes/elisp-mode.el | 16 | ||||
| -rw-r--r-- | test/automated/elisp-mode-tests.el | 24 |
2 files changed, 34 insertions, 6 deletions
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 40561515ed2..f085dcfbef3 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el | |||
| @@ -604,12 +604,16 @@ It can be quoted, or be inside a quoted form." | |||
| 604 | (setq sym (car fun-lib)) | 604 | (setq sym (car fun-lib)) |
| 605 | (cdr fun-lib)))) | 605 | (cdr fun-lib)))) |
| 606 | (`defvar (and (boundp sym) | 606 | (`defvar (and (boundp sym) |
| 607 | ;; Don't show minor modes twice. | 607 | (let ((el-file (symbol-file sym 'defvar))) |
| 608 | ;; TODO: If TYPE ever becomes dependent on the | 608 | (if el-file |
| 609 | ;; context, move this check outside. | 609 | (and |
| 610 | (not (fboundp sym)) | 610 | ;; Don't show minor modes twice. |
| 611 | (or (symbol-file sym 'defvar) | 611 | ;; TODO: If TYPE ever becomes dependent on the |
| 612 | (help-C-file-name sym 'var)))) | 612 | ;; context, move this check outside. |
| 613 | (not (and (fboundp sym) | ||
| 614 | (memq sym minor-mode-list))) | ||
| 615 | el-file) | ||
| 616 | (help-C-file-name sym 'var))))) | ||
| 613 | (`feature (and (featurep sym) | 617 | (`feature (and (featurep sym) |
| 614 | ;; Skip when a function with the same name | 618 | ;; Skip when a function with the same name |
| 615 | ;; is defined, because it's probably in the | 619 | ;; is defined, because it's probably in the |
diff --git a/test/automated/elisp-mode-tests.el b/test/automated/elisp-mode-tests.el index bfecfe7dc6b..7af6dfcdc03 100644 --- a/test/automated/elisp-mode-tests.el +++ b/test/automated/elisp-mode-tests.el | |||
| @@ -22,6 +22,9 @@ | |||
| 22 | ;;; Code: | 22 | ;;; Code: |
| 23 | 23 | ||
| 24 | (require 'ert) | 24 | (require 'ert) |
| 25 | (require 'xref) | ||
| 26 | |||
| 27 | ;;; Completion | ||
| 25 | 28 | ||
| 26 | (defun elisp--test-completions () | 29 | (defun elisp--test-completions () |
| 27 | (let ((data (elisp-completion-at-point))) | 30 | (let ((data (elisp-completion-at-point))) |
| @@ -101,5 +104,26 @@ | |||
| 101 | (should (member "backup-buffer" comps)) | 104 | (should (member "backup-buffer" comps)) |
| 102 | (should-not (member "backup-inhibited" comps))))) | 105 | (should-not (member "backup-inhibited" comps))))) |
| 103 | 106 | ||
| 107 | ;;; Navigation | ||
| 108 | |||
| 109 | (ert-deftest elisp-xref-finds-both-function-and-variable () | ||
| 110 | ;; "system-name" is both: a variable and a function | ||
| 111 | (let ((defs (elisp-xref-find 'definitions "system-name"))) | ||
| 112 | (should (= (length defs) 2)) | ||
| 113 | (should (string= (xref--xref-description (nth 0 defs)) | ||
| 114 | "(defun system-name)")) | ||
| 115 | (should (string= (xref--xref-description (nth 1 defs)) | ||
| 116 | "(defvar system-name)"))) | ||
| 117 | ;; It's a minor mode, but the variable is defined in buffer.c | ||
| 118 | (let ((defs (elisp-xref-find 'definitions "abbrev-mode"))) | ||
| 119 | (should (= (length defs) 2)))) | ||
| 120 | |||
| 121 | (ert-deftest elisp-xref-finds-only-function-for-minor-mode () | ||
| 122 | ;; Both variable and function are defined in the same place. | ||
| 123 | (let ((defs (elisp-xref-find 'definitions "visible-mode"))) | ||
| 124 | (should (= (length defs) 1)) | ||
| 125 | (should (string= (xref--xref-description (nth 0 defs)) | ||
| 126 | "(defun visible-mode)")))) | ||
| 127 | |||
| 104 | (provide 'elisp-mode-tests) | 128 | (provide 'elisp-mode-tests) |
| 105 | ;;; elisp-mode-tests.el ends here | 129 | ;;; elisp-mode-tests.el ends here |