From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Re: Is there a way to convert a keyboard macro to a string? Date: Wed, 26 Jul 2017 20:18:49 +0200 Message-ID: <878tjb3vue.fsf@jane> References: <87a83r4t43.fsf@jane> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1501093175 17712 195.159.176.226 (26 Jul 2017 18:19:35 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 26 Jul 2017 18:19:35 +0000 (UTC) User-Agent: mu4e 0.9.19; emacs 26.0.50 Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jul 26 20:19:30 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1daQu9-0004MK-Hy for geh-help-gnu-emacs@m.gmane.org; Wed, 26 Jul 2017 20:19:29 +0200 Original-Received: from localhost ([::1]:39500 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daQuF-0005OI-Eb for geh-help-gnu-emacs@m.gmane.org; Wed, 26 Jul 2017 14:19:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daQtm-0005NG-8A for help-gnu-emacs@gnu.org; Wed, 26 Jul 2017 14:19:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daQtj-0000Ml-Jh for help-gnu-emacs@gnu.org; Wed, 26 Jul 2017 14:19:06 -0400 Original-Received: from mail.mojserwer.eu ([195.110.48.8]:60363) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daQtj-0000LH-D4 for help-gnu-emacs@gnu.org; Wed, 26 Jul 2017 14:19:03 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id 636B3E67E6; Wed, 26 Jul 2017 20:19:01 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Original-Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7Qygd56g2uRO; Wed, 26 Jul 2017 20:18:58 +0200 (CEST) Original-Received: from localhost (static-dwadziewiec-jedenpiec7.echostar.pl [109.232.29.157]) by mail.mojserwer.eu (Postfix) with ESMTPSA id 1028BE677E; Wed, 26 Jul 2017 20:18:58 +0200 (CEST) In-reply-to: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.110.48.8 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.help:113877 Archived-At: On 2017-07-26, at 15:13, Stefan Monnier 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