Ok, I think we might have an easy solution here that will help out a
great deal for a large number of cases.
When the cursor is at the end of a line, and the user runs this command
(maybe call it "ParenMatchIndent"), here's the pseudo-macro/code for what
it would do:
~~~
if the previous character is a close-paren:
PushPrefs
move the cursor one place to the left (MoveLeft)
go to matching paren (MatchBracket)
note the column number at which we are now located
go back (MatchBracket)
move cursor right one place (MoveRight)
shut off AutoIndent
Return (^m)
indent to column we noted earlier
PopPrefs
otherwise:
Return (^m)
~~~
Here's some of the situations where that ParenMatchIndent command
would be most useful (prev cursor location shown by caret, resulting
cursor location shown by "@"):
~~~
(+ (some-func 1
2
3)^
@
~~~
Perfect. Here's more:
~~~
(some-func (func-a 1)^
@
(some-func (func-a 1
2)^
@
(func-a (func-b (func-c 1))^
@
(defn some-func
[x]
(let [...]
(something
(this-and-that 1
2))))^
@
~~~
This one:
~~~
(defn foo
"some docstring"
[arg1 arg2]
(let [a (* arg1 arg2)^
@
~~~
isn't so bad. We *want* the cursor to land under the "a", but
ParenMatchIndent would get us pretty close. Using the usual
auto-indent (typically enabled (for me anyway)) would do ok
here too.
This:
~~~
(defn foo
[a b]
(let [a ( ... )
b ( .......... )]^
~~~
is one where a ParenMatchIndent wouldn't help us, since the line
we're on doesn't end in a close-paren.
***
(For me, I'd probably use ^j for ParenMatchIndent and alt-j to jump
to line number, leaving "goto column num" available only via the menu.)
What do you think?
---John