[gnu.emacs] appending to keyboard-translate-table

merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) (04/17/89)

In article <4943@tekgvs.LABS.TEK.COM>, jans@tekgvs (Jan Steinman) writes:
| Just what I was thinking, as I've done this to swap backspace with rubout, but 
| here's a question:  why must you rebuild the entire list from scratch?  Note 
| that the example given undoes any backspace/rubout swap that was put in 
| site-init.el.  I've tried:
| 
| 	(aset keyboard-translate-table ?\177 ?\010)
| 	(aset keyboard-translate-table ?\010 ?\177)
| 
| which didn't work, probably because keyboard-translate-table is a list rather 
| than an string.  Other than using some ungodly combination of cons/car/cdr, is 
| there some way to index into and modify keyboard-translate-table without 
| building it from scratch?


Not a list, but either nil or a string (possibly less than 128 chars).  You
first need to extend it in a non-change way, and then do your asets, like so:

(or keyboard-translate-table
    (setq keyboard-translate-table ""))	; first ensure it is a string, not nil

(while (< (length keyboard-translate-table) 128)
  (setq keyboard-translate-table
	(concat keyboard-translate-table
		(list (length keyboard-translate-table)))))
					; now force it to 128 chars

(aset keyboard-translate-table ?\177 ?\010)
(aset keyboard-translate-table ?\010 ?\177)
					; and do the changes

There.  Try that (he says, defiantly...)...
-- 
/=====Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095========\
{        on contract to BiiN (for now :-) Hillsboro, Oregon, USA.             }
{<@intel-iwarp.arpa:merlyn@intelob.intel.com> ...!uunet!tektronix!biin!merlyn }
\=====Cute quote: "Welcome to Oregon... home of the California Raisins!"======/