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

[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$"       . "template.sh")
          ("\\.pl$"       . "template.pl")))
 
Now all my new *.pl files look like whatever .templates/template.pl looks like.

Jan Misol <misol@liblss.org> 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_


#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


_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnu-emacs


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

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