From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kin Cho Newsgroups: gmane.emacs.help Subject: Re: regexp / replacement for variable Date: 21 Feb 2004 16:41:41 -0800 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <7ir7wo3pyy.fsf@neoscale.com> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1077410790 28154 80.91.224.253 (22 Feb 2004 00:46:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 22 Feb 2004 00:46:30 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 22 01:46:24 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 1AuhlH-0006Gf-00 for ; Sun, 22 Feb 2004 01:46:24 +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 1Auhl2-0007uP-Hy for geh-help-gnu-emacs@m.gmane.org; Sat, 21 Feb 2004 19:46:08 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!12.24.46.85!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 42 Original-NNTP-Posting-Host: 12.24.46.85 Original-X-Trace: news.uni-berlin.de 1077410503 50924265 I 12.24.46.85 ([151019]) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Original-Xref: shelby.stanford.edu gnu.emacs.help:121108 Original-To: help-gnu-emacs@gnu.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:17058 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:17058 Instead of string matching, it is easier in this case to use file-name-extension and file-name-sans-extension. -kin Jan Misol 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