From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim X Newsgroups: gmane.emacs.help Subject: Re: Inserting standard text Date: Fri, 27 Apr 2007 09:51:39 +1000 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <877iryvgms.fsf@lion.rapttech.com.au> References: <1177579177.662475.118650@n15g2000prd.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1177634116 26199 80.91.229.12 (27 Apr 2007 00:35:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 27 Apr 2007 00:35:16 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Apr 27 02:35:15 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HhEQb-0006Bv-L4 for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Apr 2007 02:35:13 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HhEWO-0003WP-34 for geh-help-gnu-emacs@m.gmane.org; Thu, 26 Apr 2007 20:41:12 -0400 Original-Path: shelby.stanford.edu!newshub.stanford.edu!sn-xt-sjc-03!sn-xt-sjc-06!sn-post-sjc-02!sn-post-sjc-01!supernews.com!corp.supernews.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.95 (gnu/linux) Cancel-Lock: sha1:TVeFH4QWoS1o4iBfPHgDagJwM2k= Original-X-Complaints-To: abuse@supernews.com Original-Lines: 71 Original-Xref: shelby.stanford.edu gnu.emacs.help:147639 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:43242 Archived-At: anders writes: > Hi! > I have tryed to relace my development enviroment with Emacs, and i > have found it gives me > a lot of stuff i like. > > Becurse i am new maby my question i simple, i have read a beginners > book but missing some. > > I have debug text, that i tody in my old editor just press a key and > it insert this text. > > Wha't is the easys way to do this, ELISP + KEYDEF or,, > > I am develop in C under windows and compiling on a Solaris machine > any tips regarding whould be nice. > Emacs comes with two packages which may meet your needs, plus there are a number of add-on 'template' style packages out there. The two standard packages are skeleton mode and tempo mode. Each allows varying degrees of static and dynamic templates, which you can then bind to a key. For example, I use this to put a standard template at the beginning of my code files - ;;; (tempo-define-template "generic-header" '((format "%s" comment-start) " Filename: " (buffer-file-name) 'n (format "%s" comment-start) " Creation Date: " (format-time-string "%A, %d %B %Y %I:%M %p %Z") 'n (format "%s" comment-start) " Last Modified: " 'n (format "%s" comment-start) " Job: " (p "Job: ") 'n (format "%s" comment-start) " Author: Tim Cross " 'n (format "%s" comment-start) " Description:" 'n (format "%s" comment-start) 'n 'n)) I have this function bound to F6, so that I can insert it in a new file if needed. The template contains the name of the file (and location) the date it was created and a modified date that is automatically updated whenever the file is saved. I've defined other templates for various languages that will setup standard constructs in that language. Some of the templates, like the one above, also prompts for information that is put into the template when it is inserted. If you don't want/need this level of flexibility or don't feel confident about working with a bit of elisp, you can achieve a simple templating solution using just a template file and creating either a named keyboard macro or function that just inserts a template file into the current buffer. You should also check out abbrevs. Many modes create 'electric' functions that replace a bit of text with a simple template. For example, I think C mode uses a combination of abbrev mode and skeleton mode so that while in that mode, typeing 'if' can result in if ( ! ) { } where ! indicates where the pointer/cursor will be after typing 'if'. Tim -- tcross (at) rapttech dot com dot au