From: "Stefan Reichör" <stefan@xsteve.at>
Subject: Re: generate methods body (.cpp) from header (.hh)
Date: Wed, 15 Jun 2005 22:01:18 +0200 [thread overview]
Message-ID: <87u0jze6ep.fsf@utanet.at> (raw)
In-Reply-To: 42add26f$0$31801$ba624c82@nntp06.dk.telia.net
Khuong Dinh Pham <khuongdp@gmail.com> 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.
next prev parent reply other threads:[~2005-06-15 20:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-13 18:37 generate methods body (.cpp) from header (.hh) Khuong Dinh Pham
2005-06-15 20:01 ` Stefan Reichör [this message]
2005-06-15 20:58 ` Adam Duck
[not found] ` <mailman.127.1118869248.2857.help-gnu-emacs@gnu.org>
2005-06-18 6:26 ` Klaus Berndl
2005-06-20 12:34 ` Eric Ludlam
2005-06-21 8:11 ` Felix
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87u0jze6ep.fsf@utanet.at \
--to=stefan@xsteve.at \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).