Subject: Re: bug#67152: [PATCH] Fix flymake integration in lua-ts-mode

From: [email-masked]
Date: Tue, 14 Nov 2023 18:08:28 +0000

November 14, 2023 at 2:26 PM, "João Távora" <[email-masked]> wrote:

> Oh no! Silly me, this isn't flymake.el at all!! I saw a fragment
> of a loop and thought it was my code :-), i.e. a framework problem.

Right. The problem is the code in lua-ts-mode. Here is the full
recipe just in case (you need the tree-sitter-lua grammar and
luacheck in PATH or set lua-ts-luacheck-program):

  src/emacs test.lua --init-directory=.
  M-x lua-ts-mode

  # test.lua
  print(1)
  print(2

  # init.el
  (add-hook 'lua-ts-mode-hook #'flymake-mode)
  (add-to-list 'treesit-extra-load-path "~/.guix-profile/lib/tree-sitter")
  (setopt lua-ts-luacheck-program "~/.luarocks/bin/luacheck")
  (toggle-debug-on-error)

The error only shows up when the highlighted region is on the
last line.

> Well, then in this case, I think it should be OK,

Thanks for confirming.

> though users should test.

What kind of test do you mean?

> Backends are indeed expected to call flymake-diag-region to
> get the region to highlight, as the manual and docstrings explain
>  (I think).

I agree the docs are clear. I even used the example from the
manual as a template. Now I can’t remember why I originally
deviated from it on the region handling but I’m sure it was
caused by a misunderstanding on my part.