]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix which-function error in 'lua-ts-mode' (bug#70515)
authorjohn muhl <jm@pub.pink>
Sun, 21 Apr 2024 02:19:27 +0000 (21:19 -0500)
committerEshel Yaron <me@eshelyaron.com>
Thu, 25 Apr 2024 16:46:56 +0000 (18:46 +0200)
* 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.

(cherry picked from commit c493f28cc948ac4aef9c262345a608b3c7d413a4)

lisp/progmodes/lua-ts-mode.el
test/lisp/progmodes/lua-ts-mode-resources/which-function.lua [new file with mode: 0644]
test/lisp/progmodes/lua-ts-mode-tests.el

index 45ea8ec9a81d54cce2758c0fdd4aebc1d573d1bf..06663e5bd0ea35c0ee23560ff0e03e844d0651c6 100644 (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)
 
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 (file)
index 0000000..621d818
--- /dev/null
@@ -0,0 +1,3 @@
+local function f(x)
+    print(x)
+end
index 565e6f91dbd21d68e3273bd9b1766b352c39f5a5..a7b637d18d11b8a7c077ddf372663de97f7414b1 100644 (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))
   (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