all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Converting C++ data members to a ctor init list
@ 2011-04-13 20:30 Sarir Khamsi
  0 siblings, 0 replies; only message in thread
From: Sarir Khamsi @ 2011-04-13 20:30 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-04-13 20:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-13 20:30 Converting C++ data members to a ctor init list Sarir Khamsi

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.