all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Making code more Emacs Lisp-like
@ 2009-11-02 15:19 Sarir Khamsi
  2009-11-02 20:05 ` Joseph Brenner
  0 siblings, 1 reply; 4+ messages in thread
From: Sarir Khamsi @ 2009-11-02 15:19 UTC (permalink / raw)
  To: help-gnu-emacs

I wrote this function

(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
    (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 "*"
    (set-mark (+ (point) 1))              ; save the current position
    (beginning-of-line)
    (kill-region (point) (mark))
    (c-indent-command))
  (next-line 1))

to take a region that containers C++ code for member variable
declarations and convert it to a constructor's member init list. Is
there a better (or a more ELisp) way than this approach? Thanks.

Sarir

-- 
Sarir Khamsi
software guy
sarir.khamsi@raytheon.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-03  0:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-02 15:19 Making code more Emacs Lisp-like Sarir Khamsi
2009-11-02 20:05 ` Joseph Brenner
2009-11-02 22:17   ` Sarir Khamsi
2009-11-03  0:39     ` Joseph Brenner

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.