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 13:59:40 +0100 Message-ID: <87r0ug8rlv.fsf@gmail.com> References: <87wn4amraf.fsf@cns.nyu.edu> <87wn4891q6.fsf@gmail.com> 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="15009"; 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 14:01:44 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 1pVBEG-0003nU-Kx for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Feb 2023 14:01:44 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVBCg-0006yu-10; Thu, 23 Feb 2023 08:00:06 -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 1pVBCc-0006lL-Nh for bug-gnu-emacs@gnu.org; Thu, 23 Feb 2023 08:00: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 1pVBCc-0002k3-AD for bug-gnu-emacs@gnu.org; Thu, 23 Feb 2023 08:00:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pVBCc-0004IN-3o for bug-gnu-emacs@gnu.org; Thu, 23 Feb 2023 08:00:02 -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 13:00:02 +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.167715719116459 (code B ref 61700); Thu, 23 Feb 2023 13:00:02 +0000 Original-Received: (at 61700) by debbugs.gnu.org; 23 Feb 2023 12:59:51 +0000 Original-Received: from localhost ([127.0.0.1]:33328 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVBCQ-0004HP-Qt for submit@debbugs.gnu.org; Thu, 23 Feb 2023 07:59:51 -0500 Original-Received: from mail-wr1-f48.google.com ([209.85.221.48]:38562) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVBCO-0004HB-Lg for 61700@debbugs.gnu.org; Thu, 23 Feb 2023 07:59:49 -0500 Original-Received: by mail-wr1-f48.google.com with SMTP id i11so4448885wrp.5 for <61700@debbugs.gnu.org>; Thu, 23 Feb 2023 04:59:48 -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=NM2yzZASDyajNvJxq4VWz1aw+Bm0x+FnZBkV+991hXc=; b=DXD75RI+VfxJDMqpq7zq3NgIYHKJ0UgSKbzagsoRi1AI1NmY/P0jOREm3dKocfJ3Lq OfzFOIIth4Y5XzZIwRq6j6fshhe1i9KB6eSL1bfqSfuOy4tuZqA/RbsBNPHOHDQB31wP jv1jSC1mK59IdXpsWxNejEQxQzYA/PkK4lBME59RekpYXd0mMYpFqYLgQu5cVe92YNDu 5Ws3ro7X4D05fWy8+0RW34oVyk1QKkeNuVRVWIEB1hIoc8IkGqlsdfn8AVZRoiMOF0/r fyY7q2NK8FwwzTmYewbXeR8n5SG3W61iEVUxZr/JrbzqbSyWVSROxPFmLKxjjBwgSnBX HP9g== 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=NM2yzZASDyajNvJxq4VWz1aw+Bm0x+FnZBkV+991hXc=; b=pWoiJ6zVLgtWG3EVy+mGkxRjPo36Oi2K4sbr14oZoaxU0BqqRR/WI8BNCB9s49gRP4 xpRaOrPQ8vGheTpGXYI2z38eRBK4CvQ/YWqzoKkYGxuWtgiOnE08wCp2BpJJdlGA3f9I ovljgpQ1QenDxXVOOeNESOQUVZVNL7+ZRbw+HqE4TbzHol88+3jKXzQYIRoTvvQYhnvm jp8eRjaBP+maue+5UbFjKWsPHqc/7giDrzw8J6PlDVMcHsQ8eSGF/Lz2DtQ6rSihdMcl 7JIoDi8G34q07+c7DBUbmJ2gngmYctl9mvrPOPRmzWkKbnNWyzV/D7cMwRy+GG/EEdRC 6OiQ== X-Gm-Message-State: AO0yUKV+vMs32TpO/d9ZAYibsXlVw2AcZ9ooFCbcAhShXSgnEeMtDeI+ /9rcmRqCGZprF4Qqemp0yf4= X-Google-Smtp-Source: AK7set+9K/Da4fxjDBHijtDxE+yRN8gBEFih8uK9KL2zdiX0uuL1dKHMrdJxEKmJImQ/OoCSVJwssQ== X-Received: by 2002:a5d:6150:0:b0:2c5:63df:1171 with SMTP id y16-20020a5d6150000000b002c563df1171mr11384883wrt.19.1677157182349; Thu, 23 Feb 2023 04:59:42 -0800 (PST) Original-Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id r13-20020adfdc8d000000b002c557f82e27sm8406645wrj.99.2023.02.23.04.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 04:59:41 -0800 (PST) In-Reply-To: <87wn4891q6.fsf@gmail.com> (Robert Pluim's message of "Thu, 23 Feb 2023 10:21:05 +0100") 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:256453 Archived-At: >>>>> On Thu, 23 Feb 2023 10:21:05 +0100, Robert Pluim s= aid: Robert> This fails in emacs-29 as well. Stefan, you rewrote this code to Robert> use oclosures, any ideas? I guess we could just use Robert> macro--string-to-vector in both cases, but you=CA=BCre the expe= rt here :-) The following passes 'make bootstrap' and 'make check'. I=CA=BCve probably committed a heinous crime by autoloading an internal function, but that seemed cleaner than "(require 'macros)" in two places. Robert --=20 diff --git c/lisp/kmacro.el i/lisp/kmacro.el index 94d8794bd23..411f981d47b 100644 --- c/lisp/kmacro.el +++ i/lisp/kmacro.el @@ -380,7 +380,10 @@ kmacro-view-item-no (defun kmacro-ring-head () "Return pseudo head element in macro ring." (and last-kbd-macro - (kmacro last-kbd-macro kmacro-counter kmacro-counter-format-start))) + (kmacro (if (stringp last-kbd-macro) + (macro--string-to-vector last-kbd-macro) + last-kbd-macro) + kmacro-counter kmacro-counter-format-start))) =20 =20 (defun kmacro-push-ring (&optional elt) @@ -841,8 +844,6 @@ kmacro-lambda-form (setq mac (nth 0 mac))) (when (stringp mac) ;; `kmacro' interprets a string according to `key-parse'. - (require 'macros) - (declare-function macro--string-to-vector "macros") (setq mac (macro--string-to-vector mac))) (kmacro mac counter format))) =20 diff --git c/lisp/macros.el i/lisp/macros.el index 59c7796551f..e00aedc82b0 100644 --- c/lisp/macros.el +++ i/lisp/macros.el @@ -46,6 +46,7 @@ macros--insert-vector-macro " ") ?\])) =20 +;;;###autoload (defun macro--string-to-vector (str) "Convert an old-style string key sequence to the vector form." (let ((vec (string-to-vector str))) diff --git c/test/lisp/kmacro-tests.el i/test/lisp/kmacro-tests.el index 551fd8b60fc..a325220e8d9 100644 --- c/test/lisp/kmacro-tests.el +++ i/test/lisp/kmacro-tests.el @@ -614,6 +614,20 @@ kmacro-tests-name-last-macro-bind-and-rebind (kmacro-tests-should-insert "bb" (kmacro-tests-simulate-command '(kmacro-tests-symbol-for-test)))) =20 +;; Bug#61700 inserting named macro when the definition contains things +;; that `key-parse' thinks are named keys +(kmacro-tests-deftest kmacro-tests-name-last-macro-key-parse-syntax () + "Name last macro can rebind a symbol it binds." + ;; Make sure our symbol is unbound. + (when (fboundp 'kmacro-tests-symbol-for-test) + (fmakunbound 'kmacro-tests-symbol-for-test)) + (setplist 'kmacro-tests-symbol-for-test nil) + (kmacro-tests-define-macro " hello ") + (kmacro-name-last-macro 'kmacro-tests-symbol-for-test) + ;; Now run the function bound to the symbol. + (kmacro-tests-should-insert " hello " + (kmacro-tests-simulate-command '(kmacro-tests-symbol-for-test)))) + (kmacro-tests-deftest kmacro-tests-store-in-register () "Macro can be stored in and retrieved from a register." (use-local-map kmacro-tests-keymap)