help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Convert an existing keyboard macro to elisp code?


From: Andreas Röhler
Subject: Re: Convert an existing keyboard macro to elisp code?
Date: Sat, 04 Aug 2012 08:13:59 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120713 Thunderbird/14.0

Am 03.08.2012 18:33, schrieb PJ Weisberg:
On Fri, Aug 3, 2012 at 8:10 AM, Thorsten Jolitz <tjolitz@googlemail.com> wrote:
Unfortunately, the answer was more a less a 'NO'(or 'YOU HAVE TO WRITE
IT YOURSELF').

Since Emacs is a pretty dynamic project, I thought I give it another try
on the mailing list - maybe this feature request has been implemented in
the meantime by somebody?

If it were just a matter of reading the key sequence and mapping it to
functions it wouldn't be too bad, but the more I think about this, the
more it seems like a rat hole.  How would you translate

(fset 'my-macro
    [?\M-x ?m ?a ?g tab ?i ?t tab ?s ?t tab ?t tab return ?m ?a tab return])

into

(defun my-macro ()
   (interactive)
   (magit-status "c:/Users/PJ/Documents/magit/"))

?

You would need to know what auto-completion happened when the user
pressed tab, and then you would need to know how the function
translated its user input into interactive arguments.  I don't think
there's a way to do it without running the macro and (somehow)
watching what happens.  And that could have unpleasant side effects.

And this particular example wouldn't even be portable, since when I
type "M-x magit-status RET magit RET", Magit actually does some magic
to translate that into a full path.  So on my other machine, the
proper definition of that macro would be

(defun my-macro ()
   (interactive)
   (magit-status "/home/pj/source-code/magit"))


And that doesn't even take into account different keymaps.

-PJ


Hi,

so you might get different code when calling from different circumstances. 
Which wouldn't hinder to notate a would-be-executed code from
a point of interest.

Basically IMHO such a thing is feasible.

Andreas

Gehm's Corollary to Clark's Law: Any technology distinguishable from
magic is insufficiently advanced.






reply via email to

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