(setq sym (car fun-lib))
(cdr fun-lib))))
(`defvar (and (boundp sym)
- ;; Don't show minor modes twice.
- ;; TODO: If TYPE ever becomes dependent on the
- ;; context, move this check outside.
- (not (fboundp sym))
- (or (symbol-file sym 'defvar)
- (help-C-file-name sym 'var))))
+ (let ((el-file (symbol-file sym 'defvar)))
+ (if el-file
+ (and
+ ;; Don't show minor modes twice.
+ ;; TODO: If TYPE ever becomes dependent on the
+ ;; context, move this check outside.
+ (not (and (fboundp sym)
+ (memq sym minor-mode-list)))
+ el-file)
+ (help-C-file-name sym 'var)))))
(`feature (and (featurep sym)
;; Skip when a function with the same name
;; is defined, because it's probably in the
;;; Code:
(require 'ert)
+(require 'xref)
+
+;;; Completion
(defun elisp--test-completions ()
(let ((data (elisp-completion-at-point)))
(should (member "backup-buffer" comps))
(should-not (member "backup-inhibited" comps)))))
+;;; Navigation
+
+(ert-deftest elisp-xref-finds-both-function-and-variable ()
+ ;; "system-name" is both: a variable and a function
+ (let ((defs (elisp-xref-find 'definitions "system-name")))
+ (should (= (length defs) 2))
+ (should (string= (xref--xref-description (nth 0 defs))
+ "(defun system-name)"))
+ (should (string= (xref--xref-description (nth 1 defs))
+ "(defvar system-name)")))
+ ;; It's a minor mode, but the variable is defined in buffer.c
+ (let ((defs (elisp-xref-find 'definitions "abbrev-mode")))
+ (should (= (length defs) 2))))
+
+(ert-deftest elisp-xref-finds-only-function-for-minor-mode ()
+ ;; Both variable and function are defined in the same place.
+ (let ((defs (elisp-xref-find 'definitions "visible-mode")))
+ (should (= (length defs) 1))
+ (should (string= (xref--xref-description (nth 0 defs))
+ "(defun visible-mode)"))))
+
(provide 'elisp-mode-tests)
;;; elisp-mode-tests.el ends here