From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: PJ Weisberg Newsgroups: gmane.emacs.help Subject: Re: Convert an existing keyboard macro to elisp code? Date: Fri, 3 Aug 2012 09:33:44 -0700 Message-ID: References: <87mx2cxb7x.fsf@googlemail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1344011651 17600 80.91.229.3 (3 Aug 2012 16:34:11 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 3 Aug 2012 16:34:11 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 03 18:34:07 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SxKp0-0000jk-D6 for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Aug 2012 18:33:54 +0200 Original-Received: from localhost ([::1]:33641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SxKoz-0004wy-Ai for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Aug 2012 12:33:53 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:35344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SxKot-0004wp-GR for help-gnu-emacs@gnu.org; Fri, 03 Aug 2012 12:33:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SxKos-0007x7-H2 for help-gnu-emacs@gnu.org; Fri, 03 Aug 2012 12:33:47 -0400 Original-Received: from mail-lb0-f169.google.com ([209.85.217.169]:57342) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SxKos-0007wx-9M for help-gnu-emacs@gnu.org; Fri, 03 Aug 2012 12:33:46 -0400 Original-Received: by lbon3 with SMTP id n3so1033013lbo.0 for ; Fri, 03 Aug 2012 09:33:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=EvP/suLdHe9rI+sD29ARR2xGde9U2LvsRBxv1IADMZ0=; b=0fWHa3aLLyC3UTwiHEUWHulqfgnrDu3T/AgK6wpF0Pv1eAC7hzBg91PAQULAFR6Fgm uKR8V9eNZ8HICzrowz2K4/cA0dljK0LFTxtYMHvW/fcMaabrBpcskYaW52PDjIvi1FWC 6Vo0P6GyrIs8e+zZrASWfYhJG2I7X8Jw6HGasp1B4m/UY3XeL6t0hxtySTZRva4s6uuL /YDDOYGZSI7dLSVOzMhdEmGMObRMrz/mFxMInXMP70TgPwUImzESZZZIMTbRjHnRIslb ef6vTgEYnjp8exNh6kd07cD8BQIzn/NJZWtKGzqaFyQh/eMuo3hfvKKVcDdNl/iMaoCR dngQ== Original-Received: by 10.112.49.68 with SMTP id s4mr895804lbn.27.1344011624503; Fri, 03 Aug 2012 09:33:44 -0700 (PDT) Original-Received: by 10.112.5.102 with HTTP; Fri, 3 Aug 2012 09:33:44 -0700 (PDT) In-Reply-To: <87mx2cxb7x.fsf@googlemail.com> X-Google-Sender-Auth: xx26zXXAOeo_egasFDZrptIJUj8 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.217.169 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:86183 Archived-At: On Fri, Aug 3, 2012 at 8:10 AM, Thorsten Jolitz 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.