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.
This commit is contained in:
parent
c163fd9260
commit
bb4209a5a5
2 changed files with 14 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -976,6 +976,17 @@ evaluation of BODY."
|
|||
(should (equal (elisp--xref-infer-namespace p6) 'maybe-variable))
|
||||
(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"
|
||||
|
|
Loading…
Add table
Reference in a new issue