Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Nope, sorry. There is no trivial way to convert an emacs macro into elisp. </p> <p><em>Update:</em> There's been some work on Emacs to start down this path. See <a href="http://permalink.gmane.org/gmane.emacs.devel/125550" rel="noreferrer">this thread</a> as a starting point. It's still not possible (June 2010), but there's activity.</p> <p>The first reason I can think of is dealing with interactive commands and translating keystrokes into proper arguments for functions.</p> <p>Think of the following sequence:</p> <p><kbd>C-x b .em TAB RET</kbd></p> <p>This begins the command to switch to a buffer, types three characters, uses TAB completion to complete it and RET to accept. The equivalent lisp for the end result (in an emacs session where the TAB completion is unique) is:</p> <pre><code>(switch-to-buffer ".emacs") </code></pre> <p>Thinking of completion, there are also interactions with expansion of all types (<code>dabbrev</code>, <code>hippie-expand</code>, etc.).</p> <p>A starting point can be <kbd>M-x edit-last-kbd-macro</kbd> which (in my case) shows this:</p> <pre><code>;; Keyboard Macro Editor. Press C-c C-c to finish; press C-x k RET to cancel. ;; Original keys: C-x b .em &lt;tab&gt; RET Command: last-kbd-macro Key: none Macro: C-x b ;; switch-to-buffer .em ;; self-insert-command * 3 &lt;tab&gt; ;; pabbrev-expand-maybe RET ;; newline-and-indent </code></pre> <p>Which at least gives you some of the function names. But you'll see that <kbd>RET</kbd> is labeled as <code>'newline-and-indent</code> which is incorrect because at the time of the macro execution, the minibuffer is active and the binding is in fact <code>'minibuffer-complete-and-exit</code>. Similarly, the proper binding for <kbd>TAB</kbd> is <code>'minibuffer-complete</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload