|
From: | Stefan Reichör |
Subject: | Re: generate methods body (.cpp) from header (.hh) |
Date: | Wed, 15 Jun 2005 22:01:18 +0200 |
User-agent: | Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
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.
[Prev in Thread] | Current Thread | [Next in Thread] |