From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan =?iso-8859-1?Q?Reich=F6r?= Newsgroups: gmane.emacs.help Subject: Re: generate methods body (.cpp) from header (.hh) Date: Wed, 15 Jun 2005 22:01:18 +0200 Organization: UTA Telekom AG (Customer) Message-ID: <87u0jze6ep.fsf@utanet.at> References: <42add26f$0$31801$ba624c82@nntp06.dk.telia.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1118865666 3566 80.91.229.2 (15 Jun 2005 20:01:06 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 15 Jun 2005 20:01:06 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 15 22:01:05 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Die3B-0007Pg-GY for geh-help-gnu-emacs@m.gmane.org; Wed, 15 Jun 2005 21:59:49 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Die8S-0001zY-8V for geh-help-gnu-emacs@m.gmane.org; Wed, 15 Jun 2005 16:05:16 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!newscore.univie.ac.at!newsfeed.utanet.at!newsspool.utanet.at!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 51 Original-NNTP-Posting-Host: linzu1-209-1.utaonline.at Original-X-Trace: newsreader1.utanet.at 1118865797 11663 212.152.209.1 (15 Jun 2005 20:03:17 GMT) Original-X-Complaints-To: abuse@uta.at Original-NNTP-Posting-Date: 15 Jun 2005 20:03:17 GMT User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:0MkzOJUllaKLfVCS/jdSwCThiOM= Original-Xref: shelby.stanford.edu gnu.emacs.help:132021 Original-To: help-gnu-emacs@gnu.org 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:27491 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:27491 Khuong Dinh Pham writes: > Where can I find a script where I can generate the methods body from the > prototypes define the headers? > > Thx in advance I use the following function to do this: (defun c++-convert-to-method-body () "Take a function prototype from the class definition and convert it to the implementation body" (interactive) (let ((class-name) (doit)) (save-excursion (back-to-indentation) (setq doit (looking-at ".+(.*); *$"))) (if doit (progn (save-excursion (re-search-backward "^[^ \t].+\\(\\<\\w+\\>*::\\)") (setq class-name (match-string-no-properties 1))) (back-to-indentation) (when (looking-at "virtual") (message class-name) (delete-region (match-beginning 0) (match-end 0))) (beginning-of-line) (re-search-forward "(") (re-search-backward "[ \t]") ;;(forward-char 1) (delete-horizontal-space) (insert " ") (insert class-name) (end-of-line) (delete-region (point) (- (point) 1)) (indent-according-to-mode) (insert " {\n\n}\n") (next-line 1)) (message "This line does not contain a valid method declaration")))) (define-key c++-mode-map [(control c) ?e] 'c++-convert-to-method-body) Now I copy the function definition from the header file to my cpp file and hit C-c e. The function works for most of the method definitions that I use. Stefan.