From: Raffaele Ricciardi <rfflrccrd@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Convert an existing keyboard macro to elisp code?
Date: Sat, 04 Aug 2012 10:48:47 +0100 [thread overview]
Message-ID: <a845unF12gU1@mid.individual.net> (raw)
In-Reply-To: <mailman.6259.1344011630.855.help-gnu-emacs@gnu.org>
On 08/03/2012 05:33 PM, PJ Weisberg wrote:> 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
>
> Gehm's Corollary to Clark's Law: Any technology distinguishable from
> magic is insufficiently advanced.
>
Be stumped:
C-h f command-history
C-h v command-history
Emacs already keeps track of commands that read input from terminal, I
don't see
the reason it couldn't keep track of all commands, as the third-party
library
mwe-log-commands.el does it, while discarding the arguments. Maybe
Emacs does
it already in some other variable I don't know.
Regarding commands requiring further input and possibly performing
conversions
on their own, Emacs could feed them the same input you did. Of course, the
resulting translation will be context-sensitive just like the original macro
was. Adjustments to make the code portable would be up to the user.
next prev parent reply other threads:[~2012-08-04 9:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-03 15:10 Convert an existing keyboard macro to elisp code? Thorsten Jolitz
2012-08-03 16:33 ` PJ Weisberg
2012-08-03 17:00 ` Yuri Khan
2012-08-03 18:16 ` Thorsten Jolitz
2012-08-04 6:13 ` Andreas Röhler
[not found] ` <mailman.6259.1344011630.855.help-gnu-emacs@gnu.org>
2012-08-04 9:48 ` Raffaele Ricciardi [this message]
2012-08-04 16:39 ` Thorsten Jolitz
2012-08-04 16:51 ` Suvayu Ali
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a845unF12gU1@mid.individual.net \
--to=rfflrccrd@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).