[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: regexp / replacement for variable
From: |
Kin Cho |
Subject: |
Re: regexp / replacement for variable |
Date: |
21 Feb 2004 16:41:41 -0800 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
Instead of string matching, it is easier in this case to use
file-name-extension and file-name-sans-extension.
-kin
Jan Misol <misol@liblss.org> writes:
> 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