Fix which-function error in 'lua-ts-mode' (bug#70515)

* lisp/progmodes/lua-ts-mode.el (lua-ts-mode): Remove incorrect
usage of 'which-func-functions'.
* test/lisp/progmodes/lua-ts-mode-tests.el
(lua-ts-test-which-function): Add test.
* test/lisp/progmodes/lua-ts-mode-resources/which-function.lua:
New file.
This commit is contained in:
john muhl 2024-04-20 21:19:27 -05:00 committed by Eli Zaretskii
parent a45ae6bce9
commit c493f28cc9
3 changed files with 15 additions and 4 deletions

View file

@ -764,7 +764,7 @@ Calls REPORT-FN directly."
"vararg_expression"))))
(text "comment"))))
;; Imenu/Outline.
;; Imenu/Outline/Which-function.
(setq-local treesit-simple-imenu-settings
`(("Requires"
"\\`function_call\\'"
@ -776,9 +776,6 @@ Calls REPORT-FN directly."
lua-ts--named-function-p
nil)))
;; Which-function.
(setq-local which-func-functions (treesit-defun-at-point))
;; Align.
(setq-local align-indent-before-aligning t)

View file

@ -0,0 +1,3 @@
local function f(x)
print(x)
end

View file

@ -23,6 +23,7 @@
(require 'ert-font-lock)
(require 'ert-x)
(require 'treesit)
(require 'which-func)
(ert-deftest lua-ts-test-indentation ()
(skip-unless (treesit-ready-p 'lua))
@ -37,6 +38,16 @@
(let ((treesit-font-lock-level 4))
(ert-font-lock-test-file (ert-resource-file "font-lock.lua") 'lua-ts-mode)))
(ert-deftest lua-ts-test-which-function ()
(skip-unless (treesit-ready-p 'lua))
(with-temp-buffer
(insert-file-contents (ert-resource-file "which-function.lua"))
(lua-ts-mode)
(which-function-mode)
(goto-char (point-min))
(should (equal "f" (which-function)))
(which-function-mode -1)))
(provide 'lua-ts-mode-tests)
;;; lua-ts-mode-tests.el ends here