emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master fbe7fb0 1/2: Only skip some variables that have fun


From: Dmitry Gutov
Subject: [Emacs-diffs] master fbe7fb0 1/2: Only skip some variables that have function counterparts
Date: Tue, 05 May 2015 12:30:37 +0000

branch: master
commit fbe7fb054755b9bfe1375691d3c774cb84236859
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    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.
---
 lisp/progmodes/elisp-mode.el       |   16 ++++++++++------
 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 4056151..f085dcf 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."
                        (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
diff --git a/test/automated/elisp-mode-tests.el 
b/test/automated/elisp-mode-tests.el
index bfecfe7..7af6dfc 100644
--- a/test/automated/elisp-mode-tests.el
+++ b/test/automated/elisp-mode-tests.el
@@ -22,6 +22,9 @@
 ;;; Code:
 
 (require 'ert)
+(require 'xref)
+
+;;; Completion
 
 (defun elisp--test-completions ()
   (let ((data (elisp-completion-at-point)))
@@ -101,5 +104,26 @@
       (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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]