From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Slawomir Nowaczyk Newsgroups: gmane.emacs.help Subject: Re: A true challenge for Emac and Elisp hackers - at Least I think so Date: Wed, 12 Oct 2005 16:04:28 +0200 Message-ID: <20051012155338.23DF.SLAWOMIR.NOWACZYK.847@student.lu.se> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1129125970 23702 80.91.229.2 (12 Oct 2005 14:06:10 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 12 Oct 2005 14:06:10 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 12 16:06:01 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EPhDy-00052E-6Q for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Oct 2005 16:04:54 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EPhDx-0000ym-IF for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Oct 2005 10:04:53 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EPhDj-0000yh-7W for help-gnu-emacs@gnu.org; Wed, 12 Oct 2005 10:04:39 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EPhDh-0000yV-JA for help-gnu-emacs@gnu.org; Wed, 12 Oct 2005 10:04:39 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EPhDh-0000yS-GB for help-gnu-emacs@gnu.org; Wed, 12 Oct 2005 10:04:37 -0400 Original-Received: from [130.235.16.11] (helo=himmelsborg.cs.lth.se) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EPhDh-0002ei-2b for help-gnu-emacs@gnu.org; Wed, 12 Oct 2005 10:04:37 -0400 Original-Received: from [127.0.0.1] (slawek@dain [130.235.16.76]) by himmelsborg.cs.lth.se (8.12.11/8.12.11/perf-jw-tr) with ESMTP id j9CE4Zjk010493 for ; Wed, 12 Oct 2005 16:04:35 +0200 (CEST) Original-To: help-gnu-emacs@gnu.org In-Reply-To: X-Esmandil_Citation: done X-Mailer-Plugin: Popup Memopad for Becky!2 Ver.0.02 Rev.2 X-Mailer: Becky! ver. 2.21.04 [en] 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:30168 Archived-At: On Wed, 12 Oct 2005 15:29:54 +0200 Matthieu Moy wrote: #> Slawomir Nowaczyk writes: #> #> > 2) Write a function which does what you want and bind it to RET key #> > *) the function should check if buffer name ends with *.c #> #> Better: bind this function only in c-mode and c++-mode. No test needed #> in the command itself. Well, my system reports c++-mode for *.h files as well. Original poster specifically asked the function to apply to *.c files only. #> > *) the function should get current line contents (think of #> > functions buffer-substring, point, beginning-of-line, etc.) #> #> and C-h f looking-at RET. You don't even need to get it in a string. docstring for looking-at suggests it looks at text after point, while the needed one seems to be before the point. Sure you can move to the beginning of line first, but then I fail to see the benefit... #> (if (save-excursion #> (beginning-of-line) #> (looking-at ".*return;")) ; adapt ... #> ... #> ...) (if (string-match ".*return;" (buffer-substring (line-beginning-position) (point))) ... ...) Well, OK, your version is shorter :) #> > And also, try "C-h i C-s elisp RET" :) #> C-h i m eli TAB RET ;-). Ah, yes, I always forget this one... Thanks :) -- Best wishes, Slawomir Nowaczyk ( slawomir.nowaczyk.847@student.lu.se ) The greatest enemy of a good plan is the dream of a perfect plan.