2010-09-15

emacs formatter for all langs

hi Ilya,

On Sep 15, 2:28 am, Ilya Zakharevich wrote:
> I want a certain keypress act as forward-sexp in "programming
> language" modes, and as forward-sentence (sp?) in other modes
> (likewise for go-to-function-begin (sp?) and forward-paragraph (sp?)).
>
> So there must be some code which decides "which type" is the given
> major mode.  I would prefer the bulk of the decision to be made
> programmatically, THEN let the user override if the auto-choice was
> wrong.  Anyone with ideas how to do this?

a fool's answer: wouldn't just search for all the [] and {} heuristic works pretty much?

most top 10 langs follow c-like syntax, so am guessing checking some () {} would work out...

> P.S.  In addition to sexp/sentence and function/paragraph, are there
>       other "merges" one can do to do navigation?

i have similar need... i don't like forward/backward-paragraph in programing mode. Their behavior is unpredictable. I instead defined forward/backward-block, which is delimited by 2 empty lines. So, when i use the key, i'm sure to land on the next/prev “block”.

there are 2 other thoughts similar to this... one is a desire to have a formatting command that works for any lang. e.g. you press a button, and the curren block, or region, or buffer, gets formatted, in any lang, to a user set preference. No longer the pains to align code or press tabs, per line. (there are tools for this in different lang... usually called something-lint.)

• 〈A Simple Lisp Code Formatter〉
http://xahlee.org/emacs/lisp_formatter.html

... also, it's a fantasy of mine for C-h f to work in any lang. If info file doc for the lang doesn't exist, just send user to web browser of the lang's doc on that func. Wrote up more here http://xahlee.org/emacs/emacs_lookup_ref.html

i guess the idea is than many nice things in emacs-lisp-mode can be brought out to all langs, at least the top 10 major langs.

currently, i think each lang mode may implement some of this feature, but the keybinding is different, behavior is different, degree of support is different...

Xah ∑ xahlee.org ☄

No comments:

Post a Comment