[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fire defun by typing keyword
From: |
Emanuel Berg |
Subject: |
Re: Fire defun by typing keyword |
Date: |
Fri, 01 Nov 2013 19:58:58 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> Again, it would work just as abbrev, only instead of
>> a table lookup and replace, it would trigger a defun.
>
> An abbrev can have a "hook", which is indeed a
> function that gets called after inserting the
> expansion. So, you can do the above with an abbrev
> like
>
> ("mydate" "" date)
Cool! I took a break from "dead-serious hacking" a
couple of days and solved this problem with the help of
the idle timer you told me about earlier. This
"solution" is not one I would recommend to anyone, but
it was interesting to see that the idle timer indeed
worked exactly as expected.
(defun word-to-defun (word)
(if (string= word "thedate")
(progn
(backward-kill-word 1)
(date)) ))
(defun read-last-word ()
(save-excursion
(backward-word)
(string-make-multibyte (thing-at-point 'word)) ))
(defun read-trigger-last-word ()
(interactive)
(word-to-defun (read-last-word)) )
(run-with-idle-timer 1 t 'read-trigger-last-word)
--
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united: http://user.it.uu.se/~embe8573
- Re: Fire defun by typing keyword,
Emanuel Berg <=
- Re: Fire defun by typing keyword, Emanuel Berg, 2013/11/04
- Re: Fire defun by typing keyword, Kai Großjohann, 2013/11/05
- Message not available
- Re: Fire defun by typing keyword, Emanuel Berg, 2013/11/05
- Re: Fire defun by typing keyword, Rustom Mody, 2013/11/05
- Re: Fire defun by typing keyword, Emanuel Berg, 2013/11/06
- Re: Fire defun by typing keyword, Rustom Mody, 2013/11/06
- Re: Fire defun by typing keyword, Alan Schmitt, 2013/11/07
- Re: Fire defun by typing keyword, Peter Dyballa, 2013/11/07
- Re: Fire defun by typing keyword, Rustom Mody, 2013/11/07
- Re: Fire defun by typing keyword, Peter Dyballa, 2013/11/07