Hi,
Attached is a function for SLIME which when run automatically balances all open sexps at point. It is similar to ILISP's CLOSE-ALL-LISP, which is bound to C-c ] or M-], I think, but smaller and easier to understand.
It is a little smarter than C-<Ret> in slime-repl, handles comments, reformats trailing right parens into one line, and DWIM when a region is active.
Strings are not yet handled because it can be quite costly, I think.
Take it if you like it :) (License is same as SLIME.)
Cheers, Michael
Hi Michael,
It is a little smarter than C-<Ret> in slime-repl, handles comments, reformats trailing right parens into one line, and DWIM when a region is active.
Is the DWIM part mostly for use with (the blasphemous :-)) transient-mark-mode? In my setup (which I think is the default) the mark is pretty much always active, so this command generally operates on the region.
Should we conditionalize the narrow-to-region call on transient-mark-mode?
Cheers, Luke
* Luke Gorrie luke@bluetail.com [2004-01-19T12:24+0100]:
Is the DWIM part mostly for use with (the blasphemous :-)) transient-mark-mode?
Mostly yes ;-P
Should we conditionalize the narrow-to-region call on transient-mark-mode?
Sure. Since I have no idea what has to be done with with transient-mark-mode off, can you have a look?
Cheers, Michael
Michael Weber michaelw+slime@foldr.org writes:
- Luke Gorrie luke@bluetail.com [2004-01-19T12:24+0100]:
Is the DWIM part mostly for use with (the blasphemous :-)) transient-mark-mode?
Mostly yes ;-P
Actually I think I'm missing what the "WIM" part is. It seems like this command should always operate on the region between the point and the previous "top-level" line (with text in column 0).
No?
* Luke Gorrie luke@bluetail.com [2004-01-19T14:31+0100]:
Actually I think I'm missing what the "WIM" part is. It seems like this command should always operate on the region between the point and the previous "top-level" line (with text in column 0).
That should be the default behavior, yes.
However, in transient-mark-mode I can restrict it to whatever region I wish for. This is useful for balancing sublists instead of the whole "top-level" sexp.
But I am not religious about it. Rip this part (upto ";; skip over [...]") out, if you like.
Cheers, Michael
Michael Weber michaelw+slime@foldr.org writes:
However, in transient-mark-mode I can restrict it to whatever region I wish for. This is useful for balancing sublists instead of the whole "top-level" sexp.
Right, sublists is the case I missed. I've committed this command now, bound to `C-c C-]'.
However, I couldn't figure out how to detect transient-mark-mode on XEmacs, so I switched it to use a prefix argument to restrict to the region. So `C-u C-c C-]' can be used to close subforms.
I suspect that XEmacs has made transient-mark-mode mandatory. In my XEmacs, apropos for 'transient' matches nothing, yet it behaves as if it's in transient-mark-mode. Can anyone confirm?
(I don't like transient-mark-mode because it seems like a barrier to developing the 6th-sense of always knowing where the mark is and has recently been, as is needed to make best use of the mark-ring. Making it mandatory is just the sort of awful thing XEmacs would do ;-))
Cheers, Luke
Luke Gorrie wrote:
[...]
However, I couldn't figure out how to detect transient-mark-mode on XEmacs, so I switched it to use a prefix argument to restrict to the region. So `C-u C-c C-]' can be used to close subforms.
I suspect that XEmacs has made transient-mark-mode mandatory. In my XEmacs, apropos for 'transient' matches nothing, yet it behaves as if it's in transient-mark-mode. Can anyone confirm?
XEmacs calls transient-mark-mode zmacs-region(s) iirc, or at least, something very similar. Which is why you didn't find it :).
(I don't like transient-mark-mode because it seems like a barrier to developing the 6th-sense of always knowing where the mark is and has recently been, as is needed to make best use of the mark-ring. Making it mandatory is just the sort of awful thing XEmacs would do ;-))
No comment :)