[Top][All Lists]

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

Re: auto-insert-mode: define-auto-insert condition problem

From: Kevin Rodgers
Subject: Re: auto-insert-mode: define-auto-insert condition problem
Date: Tue, 19 Feb 2013 08:35:23 -0700
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv: Gecko/20120306 Thunderbird/3.1.20

On 2/15/13 1:08 AM, Zhiming Wang wrote:
To use the auto insert mode, I have the following lines in my .emacs file:

(require 'autoinsert)
(setq auto-insert-directory "~/.mytemplates")
(setq auto-insert-query nil)
(define-auto-insert "\.c" "c.c")
(define-auto-insert "\.tex" "latex.tex")
;;; other templates...

This works fine when I create .c file, .tex file, etc. However, when I create 
files with extensions beginning with .c, .tex, etc. templates are also loaded. 
For instance, when creating foo.cpp, the c.c template is automatically loaded, 
which is not expected. Noticing this behavior I tried .text, and latex.tex 
template is loaded.

So, is there any way to strengthen the define-auto-insert CONDITION so that 
auto insert is activated only upon the exact extensions?

"\.c" should be "\\.c\\'" and "\.tex" should be "\\.tex\\'"


P.S. Here is the documentation of define-auto-insert in 23.4.1:

define-auto-insert is a compiled Lisp function in `autoinsert.el'.

(define-auto-insert CONDITION ACTION&optional AFTER)

Associate CONDITION with (additional) ACTION in `auto-insert-alist'.
Optional AFTER means to insert action after all existing actions for CONDITION,
or if CONDITION had no actions, after all other CONDITIONs.

Kevin Rodgers
Denver, Colorado, USA

reply via email to

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