emacs-diffs
[Top][All Lists]
Advanced

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

emacs-28 bb4209a: Fix xref elisp identifier namespace mistake


From: Mattias Engdegård
Subject: emacs-28 bb4209a: Fix xref elisp identifier namespace mistake
Date: Mon, 18 Oct 2021 11:28:06 -0400 (EDT)

branch: emacs-28
commit bb4209a5a5337f9c09c4ebb2a65415a41361d8da
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Fix xref elisp identifier namespace mistake
    
    Pressing `M-.` on ALPHA in
    
      (let ((ALPHA BETA)) ...)
    
    would incorrectly search for ALPHA as a function rather than a variable.
    
    * lisp/progmodes/elisp-mode.el (elisp--xref-infer-namespace): Fix logic.
    * test/lisp/progmodes/elisp-mode-tests.el
    (elisp-mode-infer-namespace): Add test case.
---
 lisp/progmodes/elisp-mode.el            |  6 +++---
 test/lisp/progmodes/elisp-mode-tests.el | 11 +++++++++++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 10a3794..9522055 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -877,17 +877,17 @@ namespace but with lower confidence."
         ;;             ^ index K   ^ index J   ^ index I
         (let* ((i (elisp--xref-list-index))
                (i-head (looking-at-sym))
-               (i-paren (and i-head (eq (char-before) ?\()
+               (i-paren (and i (eq (char-before) ?\()
                              (progn (backward-char) t)))
                (i-quoted (and i-paren (memq (char-before) '(?\' ?`))))
                (j (and i-paren (elisp--xref-list-index)))
                (j-head (and j (looking-at-sym)))
-               (j-paren (and j-head (eq (char-before) ?\()
+               (j-paren (and j (eq (char-before) ?\()
                              (progn (backward-char) t)))
                (j-quoted (and j-paren (memq (char-before) '(?\' ?`))))
                (k (and j-paren (elisp--xref-list-index)))
                (k-head (and k (looking-at-sym)))
-               (k-paren (and k-head (eq (char-before) ?\()
+               (k-paren (and k (eq (char-before) ?\()
                              (progn (backward-char) t)))
                (k-quoted (and k-paren (memq (char-before) '(?\' ?`)))))
           (cond
diff --git a/test/lisp/progmodes/elisp-mode-tests.el 
b/test/lisp/progmodes/elisp-mode-tests.el
index 400c76c..f887bb1 100644
--- a/test/lisp/progmodes/elisp-mode-tests.el
+++ b/test/lisp/progmodes/elisp-mode-tests.el
@@ -977,6 +977,17 @@ evaluation of BODY."
     (should (equal (elisp--xref-infer-namespace p7) 'variable)))
 
   (elisp-mode-test--with-buffer
+      (concat "(let (({p1}alpha {p2}beta)\n"
+              "      ({p3}gamma ({p4}delta {p5}epsilon)))\n"
+              "  ({p6}zeta))\n")
+    (should (equal (elisp--xref-infer-namespace p1) 'variable))
+    (should (equal (elisp--xref-infer-namespace p2) 'variable))
+    (should (equal (elisp--xref-infer-namespace p3) 'variable))
+    (should (equal (elisp--xref-infer-namespace p4) 'function))
+    (should (equal (elisp--xref-infer-namespace p5) 'maybe-variable))
+    (should (equal (elisp--xref-infer-namespace p6) 'function)))
+
+  (elisp-mode-test--with-buffer
       (concat "(defun {p1}alpha () {p2}beta)\n"
               "(defface {p3}gamma ...)\n"
               "(defvar {p4}delta {p5}epsilon)\n"



reply via email to

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