Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!hc!lanl!cmcl2!yale!Ram-Ashwin From: Ram-Ashwin@cs.yale.edu (Ashwin Ram) Newsgroups: comp.emacs Subject: Re: Keyboard macros (was: Re: Copy From Above?) Message-ID: <50958@yale-celray.yale.UUCP> Date: 17 Feb 89 15:39:23 GMT References: <690026@hpsemc.HP.COM> <36077@bbn.COM> <50884@yale-celray.yale.UUCP> <36476@think.UUCP> Sender: root@yale.UUCP Reply-To: Ram-Ashwin@cs.yale.edu (Ashwin Ram) Organization: Computer Science, Yale University, New Haven, CT 06520-2158 Lines: 23 In-reply-to: barmar@think.COM (Barry Margolin) In article <36476@think.UUCP>, barmar@think.COM (Barry Margolin) writes: > In article <50884@yale-celray.yale.UUCP> Ram-Ashwin@cs.yale.edu (Ashwin Ram) writes: > >I wish there was a way of "decompiling" the macro, i.e., a function that > >inserted, not the raw keystrokes, but the names of the commands that those > >keytrokes were bound to. Keyboard macros are neat for simple things, but if > >you want to modify one you're out of luck. > > It's extremely hard to do this right. Multics Emacs had such a > feature, but it made lots of mistakes. The problem is that it's > difficult to know the binding of a keystroke, because previous > commands might have caused key bindings to change. For example, after > a "c-x b return" command, what is the "d" key bound to? If the > previous buffer at the time of invocation is a Dired buffer it would > be bound to dired-flag-file-deleted, but in other cases it would be > self-insert-command. Good point. I think the function would have to look up the bindings for your keystrokes as you typed them in the keymap for the current mode, and construct the lisp expression as it goes along. It is probably impossible to decompile a sequence of keystrokes after the fact since there is no record of the bindings of those keystrokes. -- Ashwin.