-
Notifications
You must be signed in to change notification settings - Fork 93
Avoid indentation errors after 'end'. #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid indentation errors after 'end'. #41
Conversation
This is, if not a fix, a workaround for half of elixir-editors#18. In my elixir files this produces no indentation errors; maybe you can test this against your setup and see if it doesn't raise any red flags for you. I don't know enough smie (yet), to look after the statement indentation error, that is the other error reported in elixir-editors#18.
I'm currently digging into smie and elixir-smie.el to get the second problem solved (wrong indentation after virtual The solution with @tonini I saw that there are a couple of test cases regarding indentation, but a target |
Just sneaking in to say I love that you're taking this on, Tom! (: I'm happy to walk you through running tests on emacs-elixir! They're ~undocumented at the moment (so sorry for that!). To run the full elixir-mode test suite, you can run |
Also, I should add - feel free to make more tests (even if they're expected-failing atm)! The suite is very very basic, and the reason it doesn't catch most of the errors is that I just haven't written enough code with elixir-mode yet. S-: |
Cool, Thanks tests are running (I had to add the emacs-elixir directory to More tests when I have something to test :) |
So while I was messing with this same code region myself I found that replacing this line with the followingmade an additional test pass (up to 19 now, with the two I've added): ("def" non-block-expr "do" statements "end") It also fixed the specific example of the problem described in #18 . However it's still broken if you try to add a declaration in module scope ( |
With that change and with a module-level declaration... Good: defmodule FooBar do
use Baz
def foo do
if true, do: IO.puts "yay"
20
end
def bar do
if true, do: IO.puts "yay"
20
end
end Bad: defmodule FooBar do
use Baz
def foo do
if true, do: IO.puts "yay"
20
end
def bar do
if true, do: IO.puts "yay"
20
end
end And it's not just the blank line that is creating the issue. If I remove the declaration, it's really fine, even with extra blanks: defmodule FooBar do
def foo do
if true, do: IO.puts "yay"
20
end
def bar do
if true, do: IO.puts "yay"
20
end
end I suspect but don't know that defmodule FooBar do
garbage
things
that
mean
nothing
def foo do
if true, do: IO.puts "yay"
20
end
def bar do
if true, do: IO.puts "yay"
20
end
end So maybe having like |
One final behavior: defmodule FooBar do
def foo do
if true, do: IO.puts "yay"
20
end
def bar do
if true, do: IO.puts "yay"
20
end
def ban do
1 + 1
end
end So weird. I don't grok why the third method in line breaks indentation. |
Cool. I'm in the process of groking the process and hope that solving/understanding the virtual I so hope this isn't a wild goose chase :) |
With the The problem with indentation errors after newlines/comments is that consecutive newlines/comments aren't really ignored resp. treated as one - consider the following case
(| beeing the cursor ) the last token considered here is the injected
The last token considered here is Or am I going astray somehow (digging vertically in in something unknown leaves much out of focus :). |
@tonini @antifuchs Are there any plans for progress on this PR? It's been almost 3 weeks and this syntactic breakage prevents me from using my primary editor for Elixir. I don't mind vim but obviously I'd greatly prefer to use Emacs. |
Is there anything I can do to help progress on this PR? Please let me know, I will be quite happy to help. |
I don't have time to play with elixir and the tools ATM. I'm pretty sure the problem is the implicit ';' -- the smie grammar looks correct, but nevertheless produces the described (#41 (comment)) discrepancy. If someone with a bit more knowledge could investigate that angle to see if it's nonsense or not, that would reduce the (perceived) costs for me to make time to look further into it. |
@tomterl I understand. I have spent several evenings trying to get to the bottom of this issue myself. The code here looks like it fits the profile of these double-newline indentation errors, but I have a lot of trouble forming a good picture of the logic in my head. I hope my previous comment didn't come across as nagging. |
Fixed in #48 |
This is, if not a fix, a workaround for half of #18. In my elixir files
this produces no indentation errors; maybe you can test this against
your setup and see if it doesn't raise any red flags for you.
I don't know enough smie (yet), to look after the statement indentation
error, that is the other error reported in #18.