Skip to content
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

Decrease indentation when line begins with a right paren #80

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

d-torrance
Copy link
Member

As suggested in #77, we decrease the indentation when indenting a line that opens with a ), ], or }. We also revive the unused M2-electric-right-brace function so that we re-indent automatically when typing one of these characters.

Peek 2024-12-19 15-05

It wasn't called anywhere else.  Also add a docstring and simplify the
code.
If the first character in the current line is a right paren, then we
decrease the indentation.  But to offset this, we need to increase
the indentation when the first character in the previous line is a
right paren.

Also merge the otherwise unused function M2-next-line-indent-amount
into M2-this-line-indent-amount.
Its keybinding to "}" has been commented out for ages, but it will be
very useful for re-indenting lines that begin with a right paren.

In addition to "}", we also bind it to ")" and "]".  We also remove it
from the menu since it's useless without typing a specific key.
@d-torrance d-torrance requested a review from mahrud December 19, 2024 20:14
@mahrud
Copy link
Member

mahrud commented Dec 19, 2024

Amazing! In lieu of a review I will test drive this for a while and report back!

@mahrud
Copy link
Member

mahrud commented Dec 31, 2024

So far happy with this. As long as nobody else is opposed to this change, I'm happy to merge this.

@mahrud
Copy link
Member

mahrud commented Feb 23, 2025

Things are working okay, but I'm getting pretty annoyed when editing older code.

For instance say I start with an old code

f = x -> (
    2 * x
    )
<-- pointer here

Then I press enter to make a new line and add a new function, auto indent gives me:

f = x -> (
    2 * x
    )

    g = x -> (
    )

On the other hand, say I start fresh with:

f = x -> (
    x = 2 * x;) <-- pointer here before the parenthesis

Then I press enter to make a new line and add a new statement, this happens:

f = x -> (
    x = 2 * x;
return x) <-- pointer end up here, before the parenthesis

Now if I press tab I get:

f = x -> (
    x = 2 * x;
return x    ) <-- pointer end up here, before the parenthesis

Which isn't what I wanted ... I need to jump to beginning of the line then tab to indent it correctly.

Not totally sure if these are fixable, but you might know of another option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants