From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Josh Newsgroups: gmane.emacs.help Subject: Re: Insert appropriate line-end character (like ';' for C*) Date: Wed, 11 Jun 2008 12:09:58 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <333b2bc9-8ad4-4f0e-b508-eb143fd9d2fe@c58g2000hsc.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1213213323 19823 80.91.229.12 (11 Jun 2008 19:42:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 11 Jun 2008 19:42:03 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 11 21:42:46 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1K6WD9-00020E-VR for geh-help-gnu-emacs@m.gmane.org; Wed, 11 Jun 2008 21:42:24 +0200 Original-Received: from localhost ([127.0.0.1]:50105 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K6WCM-00075k-EE for geh-help-gnu-emacs@m.gmane.org; Wed, 11 Jun 2008 15:41:34 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!e53g2000hsa.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 42 Original-NNTP-Posting-Host: 72.85.252.29 Original-X-Trace: posting.google.com 1213211398 20304 127.0.0.1 (11 Jun 2008 19:09:58 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 11 Jun 2008 19:09:58 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e53g2000hsa.googlegroups.com; posting-host=72.85.252.29; posting-account=altyoAkAAACZyvWAdscIIqznbtG0RJDD User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9) Gecko/2008060517 (Gentoo) Firefox/3.0,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:159387 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:54741 Archived-At: On Jun 11, 12:17=A0am, David Hansen wrote: > On Tue, 10 Jun 2008 15:11:07 -0700 (PDT) Josh 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. =A0Not even a full featured C parser can know if you want to > continue the statement on the next line or not: > > foo =3D bar () > =A0 =A0 =A0 =A0 && 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.