🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #98527

copy-keymap does not work as documented

#98527
From: Kevin Gallagher
Date: Tue, 23 Jul 1991 05:41
45 lines
3081 bytes
In Version 1.03 of the GNU Emacs Lisp Reference Manual, under section 19.2
Creating Keymaps, withing the function description for copy-keymap, the third
sentence states:

	However, recursive copying does not take place when the definition of
	a character is a symbol whose function definition is a keymap; the
	same symbol appears in the new copy.

I have verified that this is NOT the case in Emacs 18.54 (on an Apollo), 18.55
(on an Apollo and on a VAX under VMS), and 18.57 (on an Apollo).  When the
definition of a character is a symbol whose function definition is a keymap,
recursive copying still takes place.

To see this for yourself, first notice that in global-map, ^C is defined to be
mode-specific-command-prefix and ESC is defined to be ESC-prefix.  The
function definition of both of these symbols is a keymap.  Nevertheless, if
one executes

	(copy-keymap global-map)

the output does NOT contain the functions mode-specific-command-prefix NOR
ESC-prefix.  Instead, it contains a nested and recursively expanded COPY of the
keymaps specified by mode-specific-command-prefix and ESC-prefix.  I have
found that there are circumstances where it is more desirable to have
copy-keymap behave as it is documented.  

For example, if the terminal type is vt200, then Emacs will load
lisp/term/vt200.el during initialization.  If term-setup-hook is bound to a
function which executes enable-arrow-keys, then ESC-prefix will end up bound
to "\e" AND to the character sequence "\e[23~".  Thus, the map in ESC-prefix
will have a nested character sequence bound back to itself.  Since copy-keymap
does NOT work as documented, if one applies copy-keymap to either global-map
or ESC-prefix, AFTER vt200.el has been loaded and AFTER enable-arrow-keys has
been executed, then Emacs will be stuck in an infinite loop recursive trying
to expand ESC-prefix, until it runs out of memory and dies with a memory
fault.

I would like to see the function copy-keymap enhanced to contain an optional
second parameter which, if set to t, would cause it to behave as described in
the manual.

----------------------------------------------------------------------------
Kevin Gallagher        kgallagh@digi.lonestar.org OR ...!uunet!digi!kgallagh
DSC Communications Corporation   Addr: MS 152, 1000 Coit Rd, Plano, TX 75075
----------------------------------------------------------------------------
Technical Details
Message-ID: <9107231541.AA11497@digi.lonestar.org>
Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!digi.lonestar.ORG!kgallagh

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,f4f14d8f05fad854,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1991-07-22 22:41:45 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!digi.lonestar.ORG!kgallagh
From: kgallagh@digi.lonestar.ORG (Kevin Gallagher)
Newsgroups: gnu.emacs.bug
Subject: copy-keymap does not work as documented
Message-ID: <9107231541.AA11497@digi.lonestar.org>
Date: 23 Jul 91 05:41:45 GMT
Sender: gnulists@ai.mit.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 45
Approved: bug-gnu-emacs@prep.ai.mit.edu