From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sarir Khamsi Newsgroups: gmane.emacs.help Subject: Converting C++ data members to a ctor init list Date: Wed, 13 Apr 2011 13:30:39 -0700 Organization: Raytheon Company Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1306267638 11323 80.91.229.12 (24 May 2011 20:07:18 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 24 May 2011 20:07:18 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 24 22:07:14 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QOxsn-000596-8A for geh-help-gnu-emacs@m.gmane.org; Tue, 24 May 2011 22:07:13 +0200 Original-Received: from localhost ([::1]:52508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOxsm-00077g-Mh for geh-help-gnu-emacs@m.gmane.org; Tue, 24 May 2011 16:07:12 -0400 Original-Path: usenet.stanford.edu!postnews.google.com!news1.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bos-service1.raytheon.com!bos-service2b.ext.ray.com.POSTED!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (windows-nt) Cancel-Lock: sha1:hdifsHbqFDcgZi+fwUlnABBghZI= Original-Lines: 31 Original-NNTP-Posting-Host: 147.24.107.242 Original-X-Complaints-To: news@ext.ray.com Original-X-Trace: bos-service2b.ext.ray.com 1302726649 147.24.107.242 (Wed, 13 Apr 2011 20:30:49 UTC) Original-NNTP-Posting-Date: Wed, 13 Apr 2011 20:30:49 UTC Original-Xref: usenet.stanford.edu gnu.emacs.help:186674 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:81045 Archived-At: I have some elisp code that converts a C++ data member declaration to a constructor's member initialization list. It kinda brute force so I'm looking for suggestions on making it "more better" or more lispy. :-) (defun sk-convert-to-ctor-init-list () "Convert a C++ member variable declaration to a ctor init list line. To use this, copy all member variable declarations into the constructor's member initialization list area and execute this command on each line. At the end of this command, it moves you to the next line setting it up for a key binding." (interactive) (save-excursion (save-match-data (comment-kill 1) ; delete the comment on the line, if there is one (previous-line) (delete-blank-lines) (end-of-line) (delete-horizontal-space) ; delete whitespace at end of line (backward-delete-char-untabify 1) ; delete the ";" (insert "(),") (search-backward-regexp "[\t *&]") ; look for whitespace, "&" or "*" (let ((beg (+ 1 (point)))) ; set start 1 char forward (beginning-of-line) (delete-region beg (point))) (c-indent-command))) (next-line 1)) Comments are welcome. Thanks. Sarir -- Sarir Khamsi sarir.khamsi@raytheon.com