all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Josh <josh@dydxtech.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Insert appropriate line-end character (like ';' for C*)
Date: Wed, 11 Jun 2008 12:09:58 -0700 (PDT)	[thread overview]
Message-ID: <acf8dbd1-ebac-412f-9c5b-f5b343f8502d@e53g2000hsa.googlegroups.com> (raw)
In-Reply-To: mailman.13053.1213158202.18990.help-gnu-emacs@gnu.org

On Jun 11, 12:17 am, David Hansen <david.han...@gmx.net> wrote:
> On Tue, 10 Jun 2008 15:11:07 -0700 (PDT) Josh <j...@dydxtech.com> 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.


  parent reply	other threads:[~2008-06-11 19:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-10 22:11 Insert appropriate line-end character (like ';' for C*) Josh
2008-06-11  4:17 ` David Hansen
     [not found] ` <mailman.13053.1213158202.18990.help-gnu-emacs@gnu.org>
2008-06-11 19:09   ` Josh [this message]
2008-06-11 20:20     ` Thien-Thi Nguyen
2008-06-11 20:58     ` David Hansen
2008-06-11 22:03     ` Jason Rumney
2008-06-12 18:30       ` Josh
2008-06-12 19:21         ` David Hansen
     [not found]         ` <mailman.13154.1213298609.18990.help-gnu-emacs@gnu.org>
2008-06-13 18:37           ` Josh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=acf8dbd1-ebac-412f-9c5b-f5b343f8502d@e53g2000hsa.googlegroups.com \
    --to=josh@dydxtech.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.