[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: execute after char/string
From: |
Xah Lee |
Subject: |
Re: execute after char/string |
Date: |
Thu, 27 Nov 2008 17:35:34 -0800 (PST) |
User-agent: |
G2/1.0 |
On Nov 27, 12:19 pm, Steve Chow <msweaksa...@hotmail.com> wrote:
> is there a way I can execute a function/macro after I've inserted a
> character or string? In this case I'd like execute a function after
> typing . or -> in c-mode. I tried using global-set-key but then of
> course it won't let me enter those characters into the buffer.
this will work:
(defun ff ()
"type period then do y."
(interactive)
(let ()
(self-insert-command 1)
(funcall 'y)
)
)
(global-set-key (kbd ".") 'ff)
the y is whatever your function.
for "->", you could do the above for “>”, and the ff checks whether
previous char is “-”.
Xah
∑ http://xahlee.org/
☄