From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Dziulko Newsgroups: gmane.emacs.help Subject: Re: regexp / replacement for variable Date: Tue, 24 Feb 2004 05:31:01 -0800 (PST) Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <20040224133101.74784.qmail@web41806.mail.yahoo.com> References: <4037E506.6030701@liblss.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0551538903==" X-Trace: sea.gmane.org 1077631265 13569 80.91.224.253 (24 Feb 2004 14:01:05 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 24 Feb 2004 14:01:05 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Feb 24 15:00:57 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Avd7I-00031W-00 for ; Tue, 24 Feb 2004 15:00:56 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1AvciZ-0002Ve-HW for geh-help-gnu-emacs@m.gmane.org; Tue, 24 Feb 2004 08:35:23 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1Avcho-0002T3-LM for help-gnu-emacs@gnu.org; Tue, 24 Feb 2004 08:34:36 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1AvchG-0002IJ-H3 for help-gnu-emacs@gnu.org; Tue, 24 Feb 2004 08:34:34 -0500 Original-Received: from [66.218.93.140] (helo=web41806.mail.yahoo.com) by monty-python.gnu.org with smtp (Exim 4.30) id 1AvceT-0001jw-Tl for help-gnu-emacs@gnu.org; Tue, 24 Feb 2004 08:31:10 -0500 Original-Received: from [192.68.108.35] by web41806.mail.yahoo.com via HTTP; Tue, 24 Feb 2004 05:31:01 PST Original-To: help-gnu-emacs@gnu.org In-Reply-To: <4037E506.6030701@liblss.org> X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:17134 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:17134 --===============0551538903== Content-Type: multipart/alternative; boundary="0-254583485-1077629461=:73978" --0-254583485-1077629461=:73978 Content-Type: text/plain; charset=us-ascii 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 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. --0-254583485-1077629461=:73978 Content-Type: text/html; charset=us-ascii
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 creat ing 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. --0-254583485-1077629461=:73978-- --===============0551538903== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Help-gnu-emacs mailing list Help-gnu-emacs@gnu.org http://mail.gnu.org/mailman/listinfo/help-gnu-emacs --===============0551538903==--