help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

regexp / replacement for variable


From: Jan Misol
Subject: regexp / replacement for variable
Date: Sun, 22 Feb 2004 00:08:54 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040208

I'm new to elisp but I want my beloved editor
to generate the standard c-header stuff when creating
a new .h/.hpp header.

c-x c-f test.h

should automatically insert:

  #ifndef _TEST_H_
  #ifndef _TEST_H_


  #endif

depending on the given filename.

I put the following to my .emacs file:

  (defun new-c-header ()
    "Insert c-header skeleton."
    (interactive "")
    (progn
      (setq bname (upcase(buffer-name)))
      (insert
       (message "#ifndef %s\n\#define %s\n\n#endif"
          bname bname))))

Apart from knowing that "message" might not be the right
choice here, I don't know how to modify the value of bname!?
"replace-regexp" doesn't seem to be the what I'm looking for.

(and how could the new-c-header() be invoked by creating a
new .h/.cpp file?)

jan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]