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

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

Re: Is there a way to convert a keyboard macro to a string?


From: Marcin Borkowski
Subject: Re: Is there a way to convert a keyboard macro to a string?
Date: Wed, 26 Jul 2017 20:18:49 +0200
User-agent: mu4e 0.9.19; emacs 26.0.50

On 2017-07-26, at 15:13, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

>> execute-kbd-macro accepts a string as MACRO.  However, if I record
>> a macro using F3 ... F4 and look at last-kbd-macro, it is a vector and
>> not a string.  How do I convert it to a string representing the same key
>> sequence?
>
> Depending on the purpose, you can do:
>
>     (seq-into VEC 'string)
> or
>     (key-description VEC)
>
> The first will fail if your key sequence includes non-character events,
> or events with non-trivial modifiers.  The second will give you a string
> that's human readable but needs to be passed through `kbd` before it can
> be used as a "key sequence" (e.g. for define-key).

Thanks, that was _exactly_ what I needed!  This means that what I want
is to first use seq-into (wrapped in condition-case), and if that fails,
key-description.  Emacs did not disappoint! ;-)

Best,

-- 
Marcin Borkowski



reply via email to

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