From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#61700: 30.0.50; insert-kbd-macro fails for named macro but not last macro Date: Thu, 23 Feb 2023 10:21:05 +0100 Message-ID: <87wn4891q6.fsf@gmail.com> References: <87wn4amraf.fsf@cns.nyu.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20691"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61700@debbugs.gnu.org, Stefan Monnier To: Josh Moller-Mara Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 23 10:22:21 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pV7nx-00058k-Il for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Feb 2023 10:22:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV7nf-0004Qz-Pc; Thu, 23 Feb 2023 04:22:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pV7ne-0004Qn-36 for bug-gnu-emacs@gnu.org; Thu, 23 Feb 2023 04:22:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV7nd-0006FM-R8 for bug-gnu-emacs@gnu.org; Thu, 23 Feb 2023 04:22:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pV7nd-0001kr-MB for bug-gnu-emacs@gnu.org; Thu, 23 Feb 2023 04:22:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 23 Feb 2023 09:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61700 X-GNU-PR-Package: emacs Original-Received: via spool by 61700-submit@debbugs.gnu.org id=B61700.16771440746687 (code B ref 61700); Thu, 23 Feb 2023 09:22:01 +0000 Original-Received: (at 61700) by debbugs.gnu.org; 23 Feb 2023 09:21:14 +0000 Original-Received: from localhost ([127.0.0.1]:32943 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pV7mr-0001jm-Rn for submit@debbugs.gnu.org; Thu, 23 Feb 2023 04:21:14 -0500 Original-Received: from mail-wm1-f42.google.com ([209.85.128.42]:40753) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pV7mq-0001jX-TT for 61700@debbugs.gnu.org; Thu, 23 Feb 2023 04:21:13 -0500 Original-Received: by mail-wm1-f42.google.com with SMTP id az11-20020a05600c600b00b003dc4fd6e61dso9390432wmb.5 for <61700@debbugs.gnu.org>; Thu, 23 Feb 2023 01:21:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=94Mtaaz4LCdCVuBIw2kjVzKhSgypkIO3FQHUlf2o+hg=; b=Ti/6RZUVUGVpVfkq7k4voXUCUf5436r8d3ki1GZFwwm4d9K7ujSFnXPHuALeRO1JFg ydkX7R7dhKoVan5Bj8KH7QTFxOkOJ6wHW1Dwh07iuEBthaa85rsRke76A5qrCjJL0e4S JLwbGgNJ8lcFuusf10zkJWDyLagTASyy5Ss9w9C066BYmRFQlqJjdG1vDzsQkWOpOtXc cZlCcchkxLf6nnNfuxBa+GdqIWwnC2RVS3GUhQp7C7YdvSg5yz3YW0NbblVlpjiqi+bR +z2P6SlMrmz9ZmUiM5lP1w49fDVlW7VooAMjn41PZMTZeDiC6vrUFdAk0RgVVWGOmF8A 1h1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=94Mtaaz4LCdCVuBIw2kjVzKhSgypkIO3FQHUlf2o+hg=; b=vDlhm3DZJOFbm8A+AIUbc/RLERrd0iVBLG5oY0QIalovI4xZ3lUXCn1Sf+LiXb0gmj SHnhs5D+3Q3Uy2rUPbK2Upy7o8F/Qtgb5IbYp/9ZqGlDIvjrQ/pcrdsTnWbG4eZL59oJ tEnoMMbfVTd86cXXJECvToSjHNqh9EcbKdngNAOoK5ms21yG21Ktthlh/77FYp+VbBA6 KMQIwQPrCNlqSPWs2NJXjg6Z4Ich0jQxWBIOwXmnU/RPVykE6mwVFTTVrAjM1+tBRNHo 0mFOYZUYJ0MROq9vQ8sq2eqlGjmlYesRyA69OO6BVSKMYg1jaJTacGXm0oJdQpGA2Q88 7vvQ== X-Gm-Message-State: AO0yUKWUbgAiY1Ym9NJrAoxGdeKsloTsiocNg5DqxO5eq1oJDnIETrAb TF40ATPMArox3AeV2ux92rU= X-Google-Smtp-Source: AK7set+8vfTNwYpAESVDl526CQFcAfF3Aqo0RUXSFY0daVF5VuOcdu0awFrZocXbDBsX5EajRoIF2w== X-Received: by 2002:a05:600c:4495:b0:3dc:5a7c:f8ad with SMTP id e21-20020a05600c449500b003dc5a7cf8admr3336016wmo.21.1677144066515; Thu, 23 Feb 2023 01:21:06 -0800 (PST) Original-Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id j8-20020a5d6048000000b002c553e061fdsm12075846wrt.112.2023.02.23.01.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 01:21:05 -0800 (PST) In-Reply-To: <87wn4amraf.fsf@cns.nyu.edu> (Josh Moller-Mara's message of "Tue, 21 Feb 2023 17:18:16 -0800") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:256429 Archived-At: >>>>> On Tue, 21 Feb 2023 17:18:16 -0800, Josh Moller-Mara said: Josh> Using =E2=80=9CM-x insert-kbd-macro=E2=80=9D can insert an incorr= ect kmacro form for a Josh> named macro, while still correctly inserting the =E2=80=9Clast-kb= d-macro=E2=80=9D. Josh> To see this, we=E2=80=99ll define a macro that simply inserts the= HTML string Josh> =E2=80=9Chello=E2=80=9D (press F3, type the previous strin= g, then press F4). Josh> We=E2=80=99ll name this macro =E2=80=9Cbold-hello=E2=80=9D using = =E2=80=9CC-x C-k n=E2=80=9D. Josh> Inserting the definition to the last macro (using =E2=80=9CM-x in= sert-kbd-macro=E2=80=9D Josh> and leaving the prompt blank) returns: Josh> (setq last-kbd-macro Josh> (kmacro "< b > H e l l o < / b >")) Josh> Inserting the definition to =E2=80=9Cbold-hello=E2=80=9D (using = =E2=80=9CM-x insert-kbd-macro=E2=80=9D Josh> and typing =E2=80=9Cbold-hello=E2=80=9D at the prompt) returns: Josh> (defalias 'bold-hello Josh> (kmacro " H e l l o < / b >")) Josh> Notice the difference in =E2=80=9C< b >=E2=80=9D vs =E2=80=9C= =E2=80=9D. The =E2=80=9Cbold-hello=E2=80=9D command Josh> doesn=E2=80=99t work, printing the message: Josh> =E2=80=9CAfter 0 kbd macro iterations: Keyboard macro terminated = by a command ringing the bell=E2=80=9D Josh> I think this may have to do with the use of =E2=80=9Ckey-parse=E2= =80=9D in =E2=80=9Ckmacro=E2=80=9D (see Josh> =E2=80=9C(find-function 'kmacro)=E2=80=9D). Josh> (key-parse "hello") returns Josh> =E2=80=9C[b 104 101 108 108 111 60 47 98 62]=E2=80=9D Josh> but Josh> (macro--string-to-vector "hello") returns Josh> =E2=80=9C[60 98 62 104 101 108 108 111 60 47 98 62]=E2=80=9D Josh> The latter form is used in =E2=80=9Cinsert-kbd-macro=E2=80=9D whe= n inserting Josh> =E2=80=9Clast-kbd-macro=E2=80=9D. This fails in emacs-29 as well. Stefan, you rewrote this code to use oclosures, any ideas? I guess we could just use macro--string-to-vector in both cases, but you=CA=BCre the expert here :-) Josh> You can also quickly replicate the issue by evaluating the follow= ing Josh> form: Josh> (progn Josh> (setq last-kbd-macro "hello") Josh> (kmacro-name-last-macro 'bold-hello) Josh> (let ((temp-buffer (generate-new-buffer "*macros*"))) Josh> (with-current-buffer temp-buffer Josh> (insert-kbd-macro (intern "")) Josh> (insert-kbd-macro 'bold-hello)) Josh> (display-buffer temp-buffer))) Robert --=20