[Top][All Lists]

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

Re: regexp / replacement for variable

From: Kevin Dziulko
Subject: Re: regexp / replacement for variable
Date: Tue, 24 Feb 2004 05:31:01 -0800 (PST)

I find file templates easier.  I have this in my .emacs:
;; automaticlly start new files with specific templates
(autoload 'auto-insert "autoinsert")
     (add-hook 'find-file-not-found-hooks 'auto-insert)
     (setq auto-insert-query nil)
     (setq auto-insert-directory "myhomedir/.templates/")
     (setq auto-insert-alist
        '(("\\.sh$"       . "")
          ("\\.pl$"       . "")))
Now all my new *.pl files look like whatever .templates/ looks like.

Jan Misol <address@hidden> wrote:
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_


depending on the given filename.

I put the following to my .emacs file:

(defun new-c-header ()
"Insert c-header skeleton."
(interactive "")
(setq bname (upcase(buffer-name)))
(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?)


Help-gnu-emacs mailing list

Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
reply via email to

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