dykstrom / basic-mode

Emacs major mode for editing BASIC code
GNU General Public License v3.0
7 stars 10 forks source link

Fix indentation when decrease keyword is not at bol #8

Closed pederkl closed 6 years ago

pederkl commented 6 years ago

Basic has : as a statement separator. The keywords in basic-decrease-indent-keywords-bol should be considered when they come directly after a colon as well as when they occur at the beginning of line.

Delay loops are commonly written on one line in C64 basic: for x = 1 to delay: next x

It was annoying to have that construct increase the indentation of subsequenct lines.

dykstrom commented 6 years ago

Aah, the good old days, when you knew which processor you were running on, and there were no multi-cores and threads that mess with execution order...

I think I have seen that problem, but I thought it was a margin case, so I did not care to fix it. But it is good that you have fixed it now! There is one setup that still does not work. It did not work before either, so its not your fault, but if you want you can try to fix it. ;-) If you have a loop in a loop like this:

do for x = 1 to delay: next x loop

The loop statement will not be correctly indented, or rather outdented.

pederkl commented 6 years ago

Aah, the good old days, when you knew which processor you were running on, and there were no multi-cores and threads that mess with execution order…

Yeah, "good". I feel dirty every time I write a delay loop like that, but they're very common in published code (old computer mags).

There is one setup that still does not work. It did not work before either, so its not your fault, but if you want you can try to fix it. ;-)

It's not that I don't want to, but work has been crazy the last few weeks, and show no signs of letting up. Also, there seems to be some kind of festivities coming up later this month that my family keeps demanding I partake in the preparations for. This leaves less time for recreational hacking than I would like.

If you have a loop in a loop like this:

do for x = 1 to delay: next x loop

The loop statement will not be correctly indented, or rather outdented.

Right, I think I see why. basic-{increase,decrease}-indent-p can't be simple predicates, I think, because one call can signal the need for multiple indent levels. They need to return an integer signalling how many levels to increase/decrease (and lose their -p-suffix).

I won't have time to look at this in the forseeable future, unfortunately.

Thanks for merging, and merry x-mas.

...Peder... -- Sløv uten dop.

dykstrom commented 6 years ago

No problem. I will fix the indentation problem some time when I have time. I should probably create an issue for it to not forget it. Your analysis is probably correct.

For your information, I also have another contributor, working on a POC for making it easier to configure basic-mode different BASIC dialects. So maybe in the future, there will be a sub mode called basic-c64-mode, highlighting only keywords for C64 BASIC etc.

God Jul och Gott Nytt År!