dykstrom / basic-mode

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

Fix indentation with tabs #12

Closed Spauldo closed 3 years ago

Spauldo commented 5 years ago

Let me know if there are changes you need made.

Spauldo commented 5 years ago

This is for issue #11

dykstrom commented 5 years ago

Your change fixes the indentation with tabs and mixed tabs and spaces for the case without line numbers. And it makes the code shorter! However, it does not completely fix the indentation with tabs for the case with line numbers. Not that it worked before, though.

For example, if you customize basic-line-number-cols to 7 you will see strange indentation if you reformat the code.

If you want to try and fix that, please have a go. Otherwise, I think I will merge your PR anyway, as it fixes part of the problem, and does not break anything else that I can see.

Spauldo commented 5 years ago

I'll take a look at it and see what I can figure out. I've noticed that even with the changes I made there are some issues with indentation in some of the procedures I work on, so I need to tweak it some more anyway.

If you can post some code that uses line numbers and exhibits the problem, I'll try to get that working too.

dykstrom commented 5 years ago

Ok, so here is some code with indentation problems. I started with code indented with spaces, set indent-tabs-mode to t, customized basic-line-number-cols to 5, and typed C-c C-f to reformat the file. Have fun! :-)

  10 if x < 3 then
  20    if y > 2 then
  30       x = 2
  40      y = 3
  50     for x := 0 to 5 do
  60        if z > 0 then
  70           if q > 0 then
  80              print
  90         endif
 100    endif
 110    print
 120 next x
 130 endif
 140 endif
Spauldo commented 5 years ago

Thanks for posting the code, I'll check it out this week and see what I can figure out.

dykstrom commented 5 years ago

Hi, do you think you will have time to fix the problems I found before, or are you done working on basic-mode for now? I have some changes I want to include in basic-mode, and I'm thinking that I should merge your PR first. Or as an alternative, I could just make my changes, and you merge them into your PR if you want to do more work. Cheers, Johan

Spauldo commented 5 years ago

Bah, sorry it took so long to reply to your email. I've been in Greenland finishing out a project, and they don't have reliable internet there.

I wanted to talk to you about this actually. I'm going off of memory here

I did some digging around with the line number thing and got it to indent reliably with line numbers, although it wasn't really ready for commit. The problem is that old-style BASIC is kind of like FORTRAN, in the sense that you don't actually require whitespace between keywords. Example:

30 IFX>30THENGOTO50

This is a fundamental difference from the more modern BASICs, and to fully support it you'd need some rather drastic changes to the parser - so much so, I'd actually recommend either ripping out the line number support altogether and creating a separate major mode for it, or creating separate minor modes for each highlighting and indentation style.

My schedule is going to be really packed for the rest of the year, so I won't really be able to contribute much. If you like, I can update my repository with what I have next week once I get back to the office. IIRC, the current state of my repository has a bunch of cleanup stuff that you might not want (mostly stuff to make flycheck's elint happy).

On Thu, Aug 29, 2019 at 6:11 AM Johan Dykström notifications@github.com wrote:

Hi, do you think you will have time to fix the problems I found before, or are you done working on basic-mode for now? I have some changes I want to include in basic-mode, and I'm thinking that I should merge your PR first. Or as an alternative, I could just make my changes, and you merge them into your PR if you want to do more work. Cheers, Johan

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dykstrom/basic-mode/pull/12?email_source=notifications&email_token=ABWSBXEWJVZYBUODEMMNZULQG6VE5A5CNFSM4GH7XH7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5OEALA#issuecomment-526139436, or mute the thread https://github.com/notifications/unsubscribe-auth/ABWSBXHPGMU27UBZBFX4MK3QG6VE5ANCNFSM4GH7XH7A .

dykstrom commented 3 years ago

Hi, I'm very sorry for the very long time this PR has been just waiting. I apologize for not doing anything for all this time! I know that the issue is not completely solved, but the changes you made fixed the problem for the non-line number case, and that will have to be good enough. I'm merging this now so that basic-mode users can benefit from your improvements.

I can see the problem you describe with old Basic dialects and whitespace, and that it will require significant changes to basic-mode to support this. I'm afraid that the changes needed are beyond my skill and available time, so I will not do anything in that area, at least not now. I saw someone had created a basic-ide minor mode targeted at C64 Basic, so maybe that is the way to go if anyone wants to extend basic-mode.