From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Hansen Newsgroups: gmane.emacs.help Subject: Re: Insert appropriate line-end character (like ';' for C*) Date: Wed, 11 Jun 2008 06:17:31 +0200 Organization: disorganized Message-ID: <87tzg0k3l0.fsf@localhorst.mine.nu> References: <333b2bc9-8ad4-4f0e-b508-eb143fd9d2fe@c58g2000hsc.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1213158229 30530 80.91.229.12 (11 Jun 2008 04:23:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 11 Jun 2008 04:23:49 +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 06:24:32 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 1K6Hsu-00079V-AU for geh-help-gnu-emacs@m.gmane.org; Wed, 11 Jun 2008 06:24:32 +0200 Original-Received: from localhost ([127.0.0.1]:60244 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K6Hs6-0001Ib-PF for geh-help-gnu-emacs@m.gmane.org; Wed, 11 Jun 2008 00:23:42 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K6Hrk-0001Ey-ML for help-gnu-emacs@gnu.org; Wed, 11 Jun 2008 00:23:20 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K6Hrk-0001Dz-5E for help-gnu-emacs@gnu.org; Wed, 11 Jun 2008 00:23:20 -0400 Original-Received: from [199.232.76.173] (port=33319 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K6Hrj-0001Df-Ns for help-gnu-emacs@gnu.org; Wed, 11 Jun 2008 00:23:19 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:60573 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1K6Hrj-0001wN-Kh for help-gnu-emacs@gnu.org; Wed, 11 Jun 2008 00:23:19 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1K6Hrh-00086j-Do for help-gnu-emacs@gnu.org; Wed, 11 Jun 2008 04:23:17 +0000 Original-Received: from e178037057.adsl.alicedsl.de ([85.178.37.57]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 11 Jun 2008 04:23:17 +0000 Original-Received: from david.hansen by e178037057.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 11 Jun 2008 04:23:17 +0000 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Lines: 25 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: e178037057.adsl.alicedsl.de Mail-Copies-To: nobody User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:f/QGNBQQs3IegiOdO4MVHqHKPYY= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) 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:54716 Archived-At: 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. 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