[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Insert appropriate line-end character (like ';' for C*)

From: Josh
Subject: Re: Insert appropriate line-end character (like ';' for C*)
Date: Wed, 11 Jun 2008 12:09:58 -0700 (PDT)
User-agent: G2/1.0

On Jun 11, 12:17 am, David Hansen <address@hidden> wrote:
> On Tue, 10 Jun 2008 15:11:07 -0700 (PDT) Josh <address@hidden> wrote:
> > I think I've seen this behavior in Emacs somewhere, but I can't
> > remember where and I'm either using the wrong terms when searching or
> > I'm looking in the wrong places because I can't find anything about
> > it. What I'm looking for is a emacs command that inserts the
> > appropriate end-of-line character based on mode. For example, if
> > you're in c-mode or java-mode or whatever it would insert a ';'.
> > Ideally it would be context aware so that if you were in python-mode
> > it would add a ':' where appropriate, but not elsewhere (and even a
> > ',' if you're making a list), but that's not essential.
> > Does this already exist? If not, does anyone have any pointers on how
> > I could go about writing it? The only part I can't figure out is how
> > to determine what the right character is.
> `;' is not a "line-end" character in C but a "end-of-statement"
> character.  Not even a full featured C parser can know if you want to
> continue the statement on the next line or not:
> foo = bar ()
>         && baz ();
> David

Ok, end of statement is what I was looking for. Thanks.

I know that emacs can't possibly know what my intention is, but it
_can_ know what the appropriate end-of-statement character is for the
current context. All I'm looking for is a command that will insert
that character; I'll take care of making sure it's inserted at the
appropriate time myself.

To be more clear, I'm trying to replecate a behavior in TextMate. In
TextMate, if you hit command-shift-return it adds the context-
appropriate end-of-statement character to the end of the current line,
creates a new line below it, and indents that new line. I can already
make Emacs do everything other than insert the end-of-statement
character, but that's only because I don't know how to programatically
determine what the correct character is.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]