jschaf / powershell.el

An Emacs mode for editing and running Microsoft PowerShell code.
93 stars 30 forks source link

Add and fix auto indent using electric-pair and also remove tab key bind #22

Closed kiennq closed 6 years ago

kiennq commented 6 years ago

Adding electric-pair support so when user types brackets, it will automatically be indented. Moreover, the current indent detecting logic has flaw, the "\s-" regex also matches newline. Therefore, when types anything before closing parent, the indentation will be wrong (promote one level). For example

function a
{
    DoSomethingAndPressEnter()
| // ----> The cursor will be here
}

it should be

function a
{
    DoSomethingAndPressEnter()
    | // ----> The cursor should be here
}

This PR fixes that too.

Also, Emacs advises that TAB key should not be rebind unless necessary (docs for indent-line-function), I removed the tab key rebinding too.

jschaf commented 6 years ago

Thank you for the commit.