Closed Spauldo closed 3 years ago
It seems as if having indent-tabs-mode
set to t
is what causes the bug - basic-calculate-indent
returns a 1
instead of 8
. Setting indent-tabs-mode
to nil
fixes the problem.
Granted, that's probably what I want to set it to anyway for the work I'm doing (where the code already in place is indented by 2 spaces), but it doesn't seem too hard to make this work even with tabs. I'll make a pull request for the changes I've made. I haven't tested things like line numbers (the particular version of BASIC I'm using doesn't use them), so let me know if it screws something else up.
Thank you for finding (and fixing!) this problem! I will look into your PR as soon as I have time. If you have any other ideas on how to improve basic-mode, feel free to suggest them, or make a pull request.
Just an update, I am still going to work on this. I have a heap of work-related Common LISP code I have to deal with first, and that's got me about LISPed out.
At least it's a lot more fun than the work-related BASIC I was working on earlier that prompted the original pull request. Hundreds of lines of nested IF THEN/ELSE stuff that was improperly indented, and the FactoryLink "IDE" (if you can call it that) had no automatic indentation feature - hence Emacs.
You can take your time. I'm not doing anything to basic-mode at the moment. Interesting stuff you do at work, LISP and BASIC. But I guess the tool support is not what you are used to, if you come from the Java or C# world.
Solved by #12
Starting with
emacs -Q
and then usingload-file
to load the 20180919.1752 version of basic-mode from Melpa, indentation of nested if statements does not seem to work correctly.The first if statement will indent fine, but the second will not. I'll give an example - I typed this into an empty buffer without using any movement keys or backspacing:
This it how it autoindented. Running
indent-region
with the text marked does not change it. Removing all indentation and then runningindent-region
on the marked text gives me the same thing, but without they = 3
line indented.I'll examine the code later (I'm going to have to modify it quite a bit for the BASIC dialect I'm working with anyway), but I figured I'd give you a heads up that something was up with it.