From f4d09165ab78d09e97dbf0ac9402d43de7a7c7cd Mon Sep 17 00:00:00 2001 From: john muhl Date: Sat, 20 Apr 2024 21:19:27 -0500 Subject: [PATCH] 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. --- lisp/progmodes/lua-ts-mode.el | 5 +---- .../lua-ts-mode-resources/which-function.lua | 3 +++ test/lisp/progmodes/lua-ts-mode-tests.el | 11 +++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 test/lisp/progmodes/lua-ts-mode-resources/which-function.lua diff --git a/lisp/progmodes/lua-ts-mode.el b/lisp/progmodes/lua-ts-mode.el index 45ea8ec9a81..06663e5bd0e 100644 --- a/lisp/progmodes/lua-ts-mode.el +++ b/lisp/progmodes/lua-ts-mode.el @@ -764,7 +764,7 @@ lua-ts-mode "vararg_expression")))) (text "comment")))) - ;; Imenu/Outline. + ;; Imenu/Outline/Which-function. (setq-local treesit-simple-imenu-settings `(("Requires" "\\`function_call\\'" @@ -776,9 +776,6 @@ lua-ts-mode 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) diff --git a/test/lisp/progmodes/lua-ts-mode-resources/which-function.lua b/test/lisp/progmodes/lua-ts-mode-resources/which-function.lua new file mode 100644 index 00000000000..621d818461c --- /dev/null +++ b/test/lisp/progmodes/lua-ts-mode-resources/which-function.lua @@ -0,0 +1,3 @@ +local function f(x) + print(x) +end diff --git a/test/lisp/progmodes/lua-ts-mode-tests.el b/test/lisp/progmodes/lua-ts-mode-tests.el index 565e6f91dbd..a7b637d18d1 100644 --- a/test/lisp/progmodes/lua-ts-mode-tests.el +++ b/test/lisp/progmodes/lua-ts-mode-tests.el @@ -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 @@ lua-ts-test-font-lock (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 -- 2.41.0