From unknown Wed Aug 20 02:46:55 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#283 <283@debbugs.gnu.org> To: bug#283 <283@debbugs.gnu.org> Subject: Status: scan-error for keyboard macro Reply-To: bug#283 <283@debbugs.gnu.org> Date: Wed, 20 Aug 2025 09:46:55 +0000 retitle 283 scan-error for keyboard macro reassign 283 emacs submitter 283 "Roland Winkler" severity 283 normal thanks From Roland.Winkler@physik.uni-erlangen.de Tue May 20 00:06:35 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-4.9 required=4.0 tests=BAYES_00,FOURLA, RCVD_IN_DNSWL_LOW autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at submit) by emacsbugs.donarmstrong.com; 20 May 2008 07:06:35 +0000 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m4K76V4T020561 for ; Tue, 20 May 2008 00:06:33 -0700 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JyLvb-0008NH-6A for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 03:06:31 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JyLvZ-0008N5-M2 for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 03:06:29 -0400 Received: from [199.232.76.173] (port=53815 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JyLvZ-0008N2-BI for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 03:06:29 -0400 Received: from mx20.gnu.org ([199.232.41.8]:43922) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JyLvY-0001Xw-Nz for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 03:06:29 -0400 Received: from tfkpsv.physik.uni-erlangen.de ([131.188.164.197]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JyLvW-00010A-SE for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 03:06:27 -0400 Received: from tfkp07.physik.uni-erlangen.de (tfkp07.physik.uni-erlangen.de [131.188.164.207]) by tfkpsv.physik.uni-erlangen.de (Postfix) with ESMTP id B964420CC7 for ; Tue, 20 May 2008 09:06:22 +0200 (CEST) Date: Tue, 20 May 2008 09:06:19 +0200 Message-Id: From: "Roland Winkler" To: bug-gnu-emacs@gnu.org Subject: scan-error for keyboard macro X-detected-kernel: by mx20.gnu.org: Linux 2.4-2.6 X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) The following piece of code was generated with insert-kbd-macro (fset 'foo [?\C-[ ?f ?\C-[ ? ?\C-[ ?b ?\C-[ ?w ?\C-x ?o ?\C-x ?\C-v left left ?\C-@ ?\C-r ?/ ?\C-m ?\C-w ?/ ?\C-y ?\C-[ ?y ?\C-m ?\C-x ?o]) If you put it into a file and load the file, the macro is available. If you put point at the end of the macro definition and execute C-x C-e (eval-last-sexp) this does not allow you to load the macro (though eval-last-sexp doesn't throw an error, in the end the macro foo is not available). If you put point inside the macro definition and type C-M-x (eval-defun) it throws the error (scan-error "Unbalanced parentheses" 1 145) In GNU Emacs 22.2.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 2008-03-27 on tfkp07 configured using `configure '--with-x'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: C value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_US.iso885915 locale-coding-system: iso-8859-15 default-enable-multibyte-characters: nil From monnier@IRO.UMontreal.CA Tue May 20 06:06:39 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-5.3 required=4.0 tests=AWL,BAYES_00,HAS_BUG_NUMBER, MURPHY_DRUGS_REL8,RCVD_IN_DNSWL_LOW autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at submit) by emacsbugs.donarmstrong.com; 20 May 2008 13:06:39 +0000 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m4KD6Yre012110 for ; Tue, 20 May 2008 06:06:36 -0700 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JyRY2-0003XF-Gc for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 09:06:34 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JyRY2-0003Wh-1w for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 09:06:34 -0400 Received: from [199.232.76.173] (port=53294 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JyRY1-0003WY-Ly for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 09:06:33 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:50282) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JyRY1-0006eH-9N for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 09:06:33 -0400 Received: from ceviche.home (vpn-132-204-232-45.acd.umontreal.ca [132.204.232.45]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id m4KD6mMN030087 for ; Tue, 20 May 2008 09:06:49 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 9E17BB422F; Tue, 20 May 2008 09:06:28 -0400 (EDT) From: Stefan Monnier To: Roland Winkler Cc: 283@debbugs.gnu.org, bug-gnu-emacs@gnu.org Subject: Re: bug#283: scan-error for keyboard macro Message-ID: References: Date: Tue, 20 May 2008 09:06:28 -0400 In-Reply-To: (Roland Winkler's message of "Tue, 20 May 2008 09:06:19 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3019=0 X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) X-CrossAssassin-Score: 2 > The following piece of code was generated with insert-kbd-macro > (fset 'foo > [?\C-[ ?f ?\C-[ ? ?\C-[ ?b ?\C-[ ?w ?\C-x ?o ?\C-x ?\C-v left left ?\C-@ ?\C-r ?/ ?\C-m ?\C-w ?/ ?\C-y ?\C-[ ?y ?\C-m ?\C-x ?o]) > If you put it into a file and load the file, the macro is available. > If you put point at the end of the macro definition and execute > C-x C-e (eval-last-sexp) this does not allow you to load the macro > (though eval-last-sexp doesn't throw an error, in the end the > macro foo is not available). If you put point inside the macro > definition and type C-M-x (eval-defun) it throws the error > (scan-error "Unbalanced parentheses" 1 145) The problem is a known one: the emacs-lisp-mode and its syntax-table does not properly recognize all the escaping going on in character constants. E.g. in ?\C-[, the mode thinks this opens a square bracket expression. If you add \ in front of the [ the problem will disappear. So we could fix it either by improving the Elisp code (i.e. either improve syntax.c to be able to understand it, or add a font-lock-syntactic-keywords), or by changing the printer code to escape those chars with a \. Can you confirm that the patch below fixes it? Stefan === modified file 'lisp/macros.el' --- lisp/macros.el 2008-05-06 14:18:59 +0000 +++ lisp/macros.el 2008-05-20 13:05:47 +0000 @@ -86,45 +86,7 @@ (setq end (point-marker)) (goto-char beg) (while (< (point) end) - (let ((char (following-char))) - (cond ((= char 0) - (delete-region (point) (1+ (point))) - (insert "\\C-@")) - ((< char 27) - (delete-region (point) (1+ (point))) - (insert "\\C-" (+ 96 char))) - ((= char ?\C-\\) - (delete-region (point) (1+ (point))) - (insert "\\C-\\\\")) - ((< char 32) - (delete-region (point) (1+ (point))) - (insert "\\C-" (+ 64 char))) - ((< char 127) - (forward-char 1)) - ((= char 127) - (delete-region (point) (1+ (point))) - (insert "\\C-?")) - ((= char 128) - (delete-region (point) (1+ (point))) - (insert "\\M-\\C-@")) - ((= char (aref "\M-\C-\\" 0)) - (delete-region (point) (1+ (point))) - (insert "\\M-\\C-\\\\")) - ((< char 155) - (delete-region (point) (1+ (point))) - (insert "\\M-\\C-" (- char 32))) - ((< char 160) - (delete-region (point) (1+ (point))) - (insert "\\M-\\C-" (- char 64))) - ((= char (aref "\M-\\" 0)) - (delete-region (point) (1+ (point))) - (insert "\\M-\\\\")) - ((< char 255) - (delete-region (point) (1+ (point))) - (insert "\\M-" (- char 128))) - ((= char 255) - (delete-region (point) (1+ (point))) - (insert "\\M-\\C-?")))))) + (prin1-char (following-char)))) (if (vectorp definition) (let ((len (length definition)) (i 0) char mods) (while (< i len) From monnier@iro.umontreal.ca Tue May 20 07:40:03 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-3.8 required=4.0 tests=AWL,BAYES_00,HAS_BUG_NUMBER, MURPHY_DRUGS_REL8,RCVD_IN_DNSWL_LOW autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at submit) by emacsbugs.donarmstrong.com; 20 May 2008 14:40:03 +0000 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m4KEdx5g001825 for ; Tue, 20 May 2008 07:40:00 -0700 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JyT0Q-0007a7-VC for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 10:39:59 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JyT0P-0007Ye-7Y for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 10:39:58 -0400 Received: from [199.232.76.173] (port=38922 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JyT0O-0007YW-Tc for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 10:39:56 -0400 Received: from 206-248-174-248.dsl.teksavvy.com ([206.248.174.248]:46009 helo=ceviche.home) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JyT0O-0004Ji-91 for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 10:39:56 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 1F991B422F; Tue, 20 May 2008 10:39:45 -0400 (EDT) From: Stefan Monnier To: Roland Winkler Cc: 283@debbugs.gnu.org, bug-gnu-emacs@gnu.org Subject: Re: bug#283: scan-error for keyboard macro Message-ID: References: Date: Tue, 20 May 2008 10:39:45 -0400 In-Reply-To: (Stefan Monnier's message of "Tue, 20 May 2008 09:06:28 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) X-Greylist: delayed 5607 seconds by postgrey-1.27 at monty-python; Tue, 20 May 2008 10:39:56 EDT X-CrossAssassin-Score: 2 >> The following piece of code was generated with insert-kbd-macro >> (fset 'foo >> [?\C-[ ?f ?\C-[ ? ?\C-[ ?b ?\C-[ ?w ?\C-x ?o ?\C-x ?\C-v left left ?\C-@ ?\C-r ?/ ?\C-m ?\C-w ?/ ?\C-y ?\C-[ ?y ?\C-m ?\C-x ?o]) >> If you put it into a file and load the file, the macro is available. >> If you put point at the end of the macro definition and execute >> C-x C-e (eval-last-sexp) this does not allow you to load the macro >> (though eval-last-sexp doesn't throw an error, in the end the >> macro foo is not available). If you put point inside the macro >> definition and type C-M-x (eval-defun) it throws the error >> (scan-error "Unbalanced parentheses" 1 145) > The problem is a known one: the emacs-lisp-mode and its syntax-table > does not properly recognize all the escaping going on in > character constants. E.g. in ?\C-[, the mode thinks this opens a square > bracket expression. If you add \ in front of the [ the problem > will disappear. > So we could fix it either by improving the Elisp code (i.e. either > improve syntax.c to be able to understand it, or add > a font-lock-syntactic-keywords), or by changing the printer code to > escape those chars with a \. Can you confirm that the patch below > fixes it? I wasn't very awak when I wrote that patch. The patch below seems to actually work. Of course, it only fixes the printing part, so if you already have the above fest in your .emacs, that won't directly help you. Stefan --- macros.el.~1.54.~ 2008-05-11 17:49:20.000000000 -0400 +++ macros.el 2008-05-20 10:37:31.000000000 -0400 @@ -131,41 +131,9 @@ (insert (if (zerop i) ?\[ ?\s)) (setq char (aref definition i) i (1+ i)) - (cond ((not (numberp char)) - (prin1 char (current-buffer))) - (t - (insert "?") - (setq mods (event-modifiers char) - char (event-basic-type char)) - (while mods - (cond ((eq (car mods) 'control) - (insert "\\C-")) - ((eq (car mods) 'meta) - (insert "\\M-")) - ((eq (car mods) 'hyper) - (insert "\\H-")) - ((eq (car mods) 'super) - (insert "\\s-")) - ((eq (car mods) 'alt) - (insert "\\A-")) - ((and (eq (car mods) 'shift) - (>= char ?a) - (<= char ?z)) - (setq char (upcase char))) - ((eq (car mods) 'shift) - (insert "\\S-"))) - (setq mods (cdr mods))) - (cond ((= char ?\\) - (insert "\\\\")) - ((= char ?\") - (insert "\\\"")) - ((= char ?\;) - (insert "\\;")) - ((= char 127) - (insert "\\C-?")) - ((< char 127) - (insert char)) - (t (insert "\\" (format "%o" char))))))) + (if (not (numberp char)) + (prin1 char (current-buffer)) + (princ (prin1-char char) (current-buffer)))) (insert ?\])) (prin1 definition (current-buffer)))) (insert ")\n") From Roland.Winkler@physik.uni-erlangen.de Tue May 20 19:58:33 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-7.0 required=4.0 tests=AWL,BAYES_00,HAS_BUG_NUMBER, MURPHY_DRUGS_REL8,RCVD_IN_DNSWL_LOW autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at submit) by emacsbugs.donarmstrong.com; 21 May 2008 02:58:33 +0000 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m4L2wRO3022249 for ; Tue, 20 May 2008 19:58:29 -0700 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JyeX5-0003VC-Mx for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 22:58:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JyeX3-0003V0-A2 for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 22:58:26 -0400 Received: from [199.232.76.173] (port=48811 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JyeX3-0003Ux-3k for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 22:58:25 -0400 Received: from tfkpsv.physik.uni-erlangen.de ([131.188.164.197]:10625) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JyeX2-0000Oo-PD for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 22:58:24 -0400 Received: from tfkp07.physik.uni-erlangen.de (tfkp07.physik.uni-erlangen.de [131.188.164.207]) by tfkpsv.physik.uni-erlangen.de (Postfix) with ESMTP id 66C7D20CC7; Wed, 21 May 2008 04:58:20 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18483.36809.54722.38260@tfkp07.physik.uni-erlangen.de> Date: Wed, 21 May 2008 04:58:17 +0200 From: "Roland Winkler" To: Stefan Monnier Cc: 283@debbugs.gnu.org, bug-gnu-emacs@gnu.org Subject: Re: bug#283: scan-error for keyboard macro In-Reply-To: References: X-Mailer: VM 8.0.9 under Emacs 22.2.1 (i686-pc-linux-gnu) X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 X-CrossAssassin-Score: 2 On Tue May 20 2008 Stefan Monnier wrote: > The problem is a known one: the emacs-lisp-mode and its > syntax-table does not properly recognize all the escaping going on > in character constants. E.g. in ?\C-[, the mode thinks this opens > a square bracket expression. If you add \ in front of the [ the > problem will disappear. Thanks a lot, if the backslash in front of the [ can solve this problem, then this is even an adequate fix for an existing collection of keyboard macros. > So we could fix it either by improving the Elisp code (i.e. either > improve syntax.c to be able to understand it, or add > a font-lock-syntactic-keywords), or by changing the printer code to > escape those chars with a \. Can you confirm that the patch below > fixes it? > > I wasn't very awak when I wrote that patch. The patch below seems > to actually work. I loaded the file that contains my keyboard macros and I created it again with the patched version of insert-kbd-macro. The only difference between the old and new file was the \ in front of the [. So on that level I can say that your patch has fixed my problem with apparently no undesired side effects. Thanks a lot, Roland From monnier@iro.umontreal.ca Wed May 21 08:36:24 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-3.0 required=4.0 tests=AWL,BAYES_00,HAS_BUG_NUMBER, HELO_LH_HOME,MURPHY_DRUGS_REL8,RDNS_DYNAMIC autolearn=no version=3.2.3-bugs.debian.org_2005_01_02 Received: (at 283-done) by emacsbugs.donarmstrong.com; 21 May 2008 15:36:25 +0000 Received: from ceviche.home (vpn-132-204-232-142.acd.umontreal.ca [132.204.232.142]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m4LFaGSm015278 for <283-done@emacsbugs.donarmstrong.com>; Wed, 21 May 2008 08:36:18 -0700 Received: by ceviche.home (Postfix, from userid 20848) id 58255B422F; Wed, 21 May 2008 11:36:16 -0400 (EDT) From: Stefan Monnier To: 283-done@debbugs.gnu.org Subject: Re: bug#283: scan-error for keyboard macro Message-ID: References: <18483.36809.54722.38260@tfkp07.physik.uni-erlangen.de> Date: Wed, 21 May 2008 11:36:16 -0400 In-Reply-To: <18483.36809.54722.38260@tfkp07.physik.uni-erlangen.de> (Roland Winkler's message of "Wed, 21 May 2008 04:58:17 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii >> The problem is a known one: the emacs-lisp-mode and its >> syntax-table does not properly recognize all the escaping going on >> in character constants. E.g. in ?\C-[, the mode thinks this opens >> a square bracket expression. If you add \ in front of the [ the >> problem will disappear. > Thanks a lot, if the backslash in front of the [ can solve this > problem, then this is even an adequate fix for an existing > collection of keyboard macros. Yes, that should fix it. > I loaded the file that contains my keyboard macros and I created it > again with the patched version of insert-kbd-macro. The only > difference between the old and new file was the \ in front of the [. > So on that level I can say that your patch has fixed my problem with > apparently no undesired side effects. Thanks, installed, Stefan From unknown Wed Aug 20 02:46:55 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: $requester Subject: Internal Control Message-Id: bug archived. Date: Thu, 19 Jun 2008 14:24:03 +0000 User-Agent: Fakemail v42.6.9 # A New Hope # A log time ago, in a galaxy far, far away # something happened. # # Magically this resulted in the following # action being taken, but this fake control # message doesn't tell you why it happened # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator