* v21 EDMACRO-FORMAT-KEYS chokes and dies on Meta number prefixes
@ 2003-08-03 19:19 sand
0 siblings, 0 replies; only message in thread
From: sand @ 2003-08-03 19:19 UTC (permalink / raw)
This is with GNU Emacs 21.3.2 (i386-pc-linux-gnu, X toolkit, Xaw3d
scroll bars) of 2003-04-24 on raven, modified by Debian.
Turn on DEBUG-ON-ERROR.
Start a keyboard macro:
C-x (
Move the current line to the top of the window with the following key
sequence:
M-0 C-l
End the keyboard macro:
C-x )
Edit the last keyboard macro:
C-x C-k C-x e
Emacs will generate the following error message:
Debugger entered--Lisp error: (error "Invalid character: 037000000060, -134217680, 0xf8000030")
concat("M-" [-134217680] " ")
(prog1 (concat "M-" (edmacro-subseq rest-mac 0 i) " ") (callf edmacro-subseq rest-mac i))
Etc., etc.
Internally, LAST-KEYBOARD-MACRO stores this macro as a two-character,
two-byte string: \xb0\x0c. This uses the special convention that bit
7 indicates the Meta modifier. When EDMACRO-FORMAT-KEYS goes to work,
one of the first things it does is convert these special characters
into the "modern" integer format: \xb0 becomes -134217680 or
0xf8000030. All further processing takes place with this format.
At the end, however, this has to get converted to a keysequence text
format for display, and EDMACRO-FORMAT-KEYS does this with:
(concat "M-" (edmacro-subseq rest-mac 0 i) " ")
(EDMACRO-SUBSEQ returns a sequence of these integers from positions 0
to I.) CONCAT is unable to deal with integers outside the range of
[0..255] and barfs. This may have worked before, but the docs say
that Emacs 21 uses a new internal format for character encoding.
So some solutions, in order of preference, are:
1. CONCAT, STRING and all the comparable functions get extended to
support characters outside of [0..255].
2. Emacs gets INTEGER-CHARACTER-CODE and CHARACTER-CODE-INTEGER
functions that convert to and from the special string
convention.
3. We add the attatched patch to "edmacro.el", which undoes just
this particular integer conversion.
Derek
--
Derek Upham
sand@blarg.net
"Ha! Your Leaping Tiger Kung Fu is no match for my Frightened Piglet style!"
------------------------------ cut here ------------------------------
diff -u /usr/share/emacs/21.3/lisp/edmacro.el /home/sand/edmacro.el
--- /usr/share/emacs/21.3/lisp/edmacro.el 2002-07-06 06:39:24.000000000 -0700
+++ /home/sand/edmacro.el 2003-08-03 12:11:50.000000000 -0700
@@ -387,6 +387,20 @@
\f
;;; Formatting a keyboard macro as human-readable text.
+(defun edmacro-sanitize-for-string (seq)
+ "Convert a sequence of integers into a sequence of characters.
+
+The resulting characters follow the usual Emacs conventions (control
+characters are really ASCII control characters; Meta flags are
+indicated by bit 7 being set.
+
+This function only works with sequences that EDMACRO-FORMAT-KEYS has
+converted from the original string representation to integers."
+ (loop for i below (length seq) do
+ (when (< (aref seq i) 0)
+ (setf (aref seq i) (logand (aref seq i) 127))))
+ seq)
+
(defun edmacro-format-keys (macro &optional verbose)
(setq macro (edmacro-fix-menu-commands macro))
(let* ((maps (append (current-minor-mode-maps)
@@ -419,7 +433,10 @@
(while (memq (aref rest-mac i) (cdr mdigs))
(incf i))
(and (not (memq (aref rest-mac i) pkeys))
- (prog1 (concat "M-" (edmacro-subseq rest-mac 0 i) " ")
+ (prog1 (concat "M-"
+ (edmacro-sanitize-for-string
+ (edmacro-subseq rest-mac 0 i))
+ " ")
(callf edmacro-subseq rest-mac i)))))
(and (eq (aref rest-mac 0) ?\C-u)
(eq (key-binding [?\C-u]) 'universal-argument)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-08-03 19:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-03 19:19 v21 EDMACRO-FORMAT-KEYS chokes and dies on Meta number prefixes sand
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).