[comp.emacs] input considerations was "M-foo" == "ESC foo"?

gaynor@sparky.rutgers.edu (Silver) (09/16/90)

lakin@csli.Stanford.EDU (Fred Lakin) writes:
>> I tried to bind it to C-X C-M-L:
>>      (global-set-key "\C-x\C-[\C-l" 'foo)
>> and found I had rebound C-X ESC ... and in fact it seems like
>> the <anything> in "\C-x\C-[<anything>" made no difference.

gumby@Cygnus.COM (David Vinayak Wallace) responds:
> GNU emacs uses seven-bit ASCII.  Meta-foo is converted to escape foo
> internally!

GNU Emacs recognizes 8-bit characters.  However, it resolves terminal
meta-characters in the map under meta-prefix-char's when meta-flag is non-nil.
I don't know whether this was done because meta-characters are not available on
most terminals, and maps which knew about about them would take more space, or
because they are not ascii, or because it tends to make the bindings too
complicated for most users to deal with, or what.

Regardless, you can control the map in which meta-characters are resolved.

  ;; some-char should be one which the user is never,
  ;; ever likely to type, like 23 or something.
  (setq meta-prefix-char some-char)

  ;; Produce your own hand-crafted meta-map.
  (defvar meta-map (make-keymap)) ; or (make-sparse-keymap)
  (fset 'Meta-Prefix meta-map)    ; see the Info node on keymaps
  "Keymap in which meta-characters should be resolved.")
  (define-key meta-map ...)

  ;; Fix up the map for some-char.
  (define-key global-map (char-to-string meta-prefix-char) 'Meta-Prefix)
  ...

> I have seen the future and it is Unix.
For the meantime, probably.

> And they call this a kinder, gentler age!
Especially in the middle east, where everyone
has a kinder, gentler machine gun hand!

Personally, I would favor the extension to handling meta-characters in their
own right, but this might take a bit of doing.  Another thing I would really
like to see is an extension to the input driver to evaluate keys in a stack of
maps, instead of just a local map and a global map.  Dang, this would solve a
lot of problems with specialized minor modes and customizations in general.
You push to a set of shadowing bindings.  This isn't really all that clever, I
wonder why rms didn't do it?  It's a backward-compatible extension that is just
as efficient and probably easily implemented.

Just perambulating, [Ag] gaynor@paul.rutgers.edu