From: Sarir Khamsi <sarir.khamsi@raytheon.com>
To: help-gnu-emacs@gnu.org
Subject: Converting C++ data members to a ctor init list
Date: Wed, 13 Apr 2011 13:30:39 -0700 [thread overview]
Message-ID: <w529lizdj3m8.fsf@raytheon.com> (raw)
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
reply other threads:[~2011-04-13 20:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=w529lizdj3m8.fsf@raytheon.com \
--to=sarir.khamsi@raytheon.com \
--cc=help-gnu-emacs@gnu.org \
/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).