[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tempo-define-template : missing initial position in template
From: |
Christoph Conrad |
Subject: |
Re: tempo-define-template : missing initial position in template |
Date: |
Mon, 19 Nov 2001 09:59:38 +0100 |
User-agent: |
Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1 (i586-pc-linux-gnu) |
The following message is a courtesy copy of an article
that has been posted to comp.emacs as well.
> The dmacro package has the facility to define a position within
> the template which is the initial one after expanding the
> template.
I have defined some helpers for achieving that, see below. My GNU
Emacs is version 21.1. The initial position is defined with the
symbol '~ (should be read "home position").
What do you think about?
,----[ The code ]
| (defvar tempo-initial-pos nil
| "Initial postion in template after expansion")
|
| (defadvice tempo-insert( around tempo-insert-pos act )
| "Define initial position."
| (if (eq element '~)
| (setq tempo-initial-pos (point-marker))
| ad-do-it))
|
| (defadvice tempo-insert-template( around tempo-insert-template-pos act )
| "Set initial position when defined."
| (setq tempo-initial-pos nil)
| ad-do-it
| (when tempo-initial-pos
| (goto-char tempo-initial-pos)))
`----
,----[ Prevent insertion of expansion char ]
| (defadvice tempo-define-template
| ( after tempo-define-template-no-insert act )
| "Prevent insertion of the character which triggers expansion."
| (put (intern (concat "tempo-template-" name)) 'no-self-insert t))
`----
,----[ A test case ]
| (tempo-define-template "cco"
| '( "<code>" p ~
| (p "Text: " text)
| "</code>" p
| (s text) '> ))
|
| (tempo-template-cco)
`----
Best regards,
cu, -cc-
--
=> GNU Emacs Webring @ <http://www.gnusoftware.com/WebRing/> <=
Look Ma, this man can twist his fingers as if they were made of rubber,
isn't that amazing? -- Not really, he's been using emacs for years...!
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: tempo-define-template : missing initial position in template,
Christoph Conrad <=