* bug#283: scan-error for keyboard macro
2008-05-20 7:06 ` bug#283: scan-error for keyboard macro Roland Winkler
@ 2008-05-20 13:06 ` Stefan Monnier
2008-05-20 14:39 ` Stefan Monnier
2008-05-21 15:45 ` bug#283: marked as done (scan-error for keyboard macro) Emacs bug Tracking System
1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2008-05-20 13:06 UTC (permalink / raw)
To: Roland Winkler; +Cc: 283, bug-gnu-emacs
> 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)
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#283: marked as done (scan-error for keyboard macro)
2008-05-20 7:06 ` bug#283: scan-error for keyboard macro Roland Winkler
2008-05-20 13:06 ` Stefan Monnier
@ 2008-05-21 15:45 ` Emacs bug Tracking System
1 sibling, 0 replies; 5+ messages in thread
From: Emacs bug Tracking System @ 2008-05-21 15:45 UTC (permalink / raw)
To: Stefan Monnier
[-- Attachment #1: Type: text/plain, Size: 847 bytes --]
Your message dated Wed, 21 May 2008 11:36:16 -0400
with message-id <jwvprrfr7ow.fsf-monnier+emacsbugreports@gnu.org>
and subject line Re: bug#283: scan-error for keyboard macro
has caused the Emacs bug report #283,
regarding scan-error for keyboard macro
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact don@donarmstrong.com
immediately.)
--
283: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=283
Emacs Bug Tracking System
Contact don@donarmstrong.com with problems
[-- Attachment #2: Type: message/rfc822, Size: 3238 bytes --]
From: "Roland Winkler" <Roland.Winkler@physik.uni-erlangen.de>
To: bug-gnu-emacs@gnu.org
Subject: scan-error for keyboard macro
Date: Tue, 20 May 2008 09:06:19 +0200
Message-ID: <m3y765cv4k.fsf@tfkp07.physik.uni-erlangen.de>
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
[-- Attachment #3: Type: message/rfc822, Size: 2266 bytes --]
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: 283-done@emacsbugs.donarmstrong.com
Subject: Re: bug#283: scan-error for keyboard macro
Date: Wed, 21 May 2008 11:36:16 -0400
Message-ID: <jwvprrfr7ow.fsf-monnier+emacsbugreports@gnu.org>
>> 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
^ permalink raw reply [flat|nested] 5+ messages in thread