Macaulay2 / M2-emacs

Macaulay2 emacs files
GNU General Public License v3.0
5 stars 3 forks source link

Indentation updates #52

Closed d-torrance closed 10 months ago

d-torrance commented 11 months ago

This is an improved version of #18, which was eventually reverted (#22). The proposal is to keep the same basic behavior of indentation in M2-mode, but with a few improvements:

d-torrance commented 11 months ago

I'm not quite happy with this yet -- using this-command to detect whether we just started a new line doesn't seem correct. Converting to a draft for now.

d-torrance commented 11 months ago

I'm happy with this now.

When the user specifically presses Tab (which is bound to indent-for-tab-command in M2-mode and org-cycle when looking at a Macaulay2 source block in Org Mode -- but more commands can be added by customizing M2-insert-tab-commands), we get the classic M2-electric-tab behavior of inserting spaces when on a blank line or to the right of some text.

But when M2-electric-tab is called from any other command (e.g., from newline, newline-and-indent, org-return, etc.), we indent based on the depth of the parentheses, matching the behavior of M2-newline-and-indent.