[comp.emacs] Alt key to Meta key bindings

aihaug@AUSTIN.LOCKHEED.COM (Daniel A Haug) (06/10/89)

> From jr@BBN.COM Fri Jun  9 08:23:24 1989
> To: Daniel A Haug <aihaug@austin.lockheed.com>
> Subject: Re: binding Alt-X to Meta-X 
> In-Reply-To: Your message of Thu, 08 Jun 89 00:03:00 -0500.
>              <8906080503.AA14210@shrike.Austin.Lockheed.COM> 
> Date: Fri, 09 Jun 89 09:16:38 -0400
> Message-Id: <11492.613401398@bbn.com>
> From: John Robinson <jr@BBN.COM>
> 
> > Thanks for the reply!  Your instructions got the job done!  Now I have
> > full Alt-key operations on the Silicon graphics.
> 
> In order that the next person not have to go through it again, maybe
> you would consider submitting the resulting code to the FSF as a
> contribution, or at least posting it to the newsgroup.
> 
> /jr

Okay, following is my .emacs file (for Gnu) with key bindings that map
the Alt-key to the Meta-key.  Note that on the SG, this only works
currently for the right Alt key, not the left Alt key.

dan haug
========================== cut here ===================================

;;; +-----------------------------------------------------------
;;; The following key bindings make the Alt key on the SG work
;;; like the Meta key.  In all cases (except backward-paragraph),
;;; you can still use ESC-key as well.
;;; +-----------------------------------------------------------

(global-unset-key "\e[")                       ;unbind ESC-[
(global-set-key "\e[084q" 'backward-paragraph) ;rebind to Alt-[

(global-set-key "\e[087q" 'backward-sentence)        ;ESC-a
(global-set-key "\e[105q" 'backward-word)            ;ESC-b
(global-set-key "\e[103q" 'capitalize-word)          ;ESC-c
(global-set-key "\e[089q" 'kill-word)                ;ESC-d
(global-set-key "\e[076q" 'forward-sentence)         ;ESC-e
(global-set-key "\e[090q" 'forward-word)             ;ESC-f
(global-set-key "\e[091q" 'fill-region)              ;ESC-g
(global-set-key "\e[092q" 'mark-paragraph)           ;ESC-h
(global-set-key "\e[081q" 'tab-to-tab-stop)          ;ESC-i
(global-set-key "\e[093q" 'indent-new-comment-line)  ;ESC-j
(global-set-key "\e[094q" 'kill-sentence)            ;ESC-k
(global-set-key "\e[095q" 'downcase-word)            ;ESC-l
(global-set-key "\e[107q" 'back-to-indentation)      ;ESC-m
(global-set-key "\e[074q" 'fill-paragraph)           ;ESC-q
(global-set-key "\e[077q" 'move-to-window-line)      ;ESC-r
(global-set-key "\e[078q" 'transpose-words)          ;ESC-t
(global-set-key "\e[080q" 'upcase-word)              ;ESC-u
(global-set-key "\e[104q" 'scroll-down)              ;ESC-v
(global-set-key "\e[075q" 'copy-region-as-kill)      ;ESC-w
(global-set-key "\e[102q" 'execute-extended-command) ;ESC-x
(global-set-key "\e[079q" 'yank-pop)                 ;ESC-y
(global-set-key "\e[101q" 'zap-to-char)              ;ESC-z

(global-set-key "\e[097q" 'indent-for-comment)       ;ESC-;
(global-set-key "\e[111q" 'find-tag)                 ;ESC-.
(global-set-key "\e[109q" 'tags-loop-continue)       ;ESC-,
(global-set-key "\e[111q" 'end-of-buffer)            ;ESC->
(global-set-key "\e[109q" 'beginning-of-buffer)      ;ESC-<
(global-set-key "\e[070q" 'count-lines-region)       ;ESC-=
(global-set-key "\e[068q" 'negative-argument)        ;ESC--
(global-set-key "\e[M"    'backward-kill-word)       ;ESC-<delete>
(global-set-key "\e[086q" 'delete-horizontal-space)  ;ESC-\
(global-set-key "\e[085q" 'forward-paragraph)        ;ESC-]
(global-set-key "\e[113q" 'dabbrev-expand)           ;ESC-/
========================== cut here ===================================

dan haug-- 
Internet: haug@austin.lockheed.com
UUCP:     ut-emx!lad-shrike!aihaug

kjones@talos.UUCP (Kyle Jones) (06/15/89)

Daniel A Haug writes:
 > Okay, following is my .emacs file (for Gnu) with key bindings that map
 > the Alt-key to the Meta-key.  Note that on the SG, this only works
 > currently for the right Alt key, not the left Alt key.
 > [...]
 > (global-set-key "\e[111q" 'find-tag)                 ;ESC-.
 > (global-set-key "\e[109q" 'tags-loop-continue)       ;ESC-,
 > (global-set-key "\e[111q" 'end-of-buffer)            ;ESC->
 > (global-set-key "\e[109q" 'beginning-of-buffer)      ;ESC-<

Something's amiss here.  The bindings suggest that there's no way to
distinguish ALT-. and ALT-, from ALT-> and ALT-<.

Also, we could get rid of all the (global-set-key ...) calls if someone
would post a translation table listing what each ALT key sequence
translates to.  With that, a single function could be written to do the
translation and this could be put into a file in the lisp/term directory
of the Emacs distribution.  The whole process could then be transparent
to the user.  Dan, if you don't hack Lisp, I'll write the
function given the aforementioned table.

In any event I'm curious about what kind of mapping the ALT key on the
SG terminal does.  I looked at the list of bindings posted and could see
no pattern, logical or otherwise.