help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Alt as meta, except for certain keys, how?


From: Ehud Karni
Subject: Re: Alt as meta, except for certain keys, how?
Date: Fri, 8 Aug 2003 10:05:49 +0300

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 07 Aug 2003 12:38:54 -0600, Kevin Rodgers <address@hidden> wrote:
>
> Jussi Piitulainen wrote:
>
> > I want to use Alt as a Meta key, with the exception that certain keys
> > should be interpreted as ordinary unmodified characters: Alt-7 should
> > produce vertical bar |, Shift-Alt-7 alias Alt-/ should produce
> > backslash \, and there are a few others, all in ASCII.
> >
> > I have managed to (global-set-key "\M-7" "|"). That works for writing
> > but is not a real solution. At least in an incremental search Alt-7
> > has already been interpreted as two keys: the escape terminates the
> > search and 7 is inserted in the buffer.
>
>
> Try setting search-exit-option to nil.
>
>
> > I could not work out how to use keyboard-translate to turn Alt-7 into
> > vertical bar. If this is possible, could someone please show me the
> > concrete command? Or any other way to achieve my goal?
>
>
> (keyboard-translate ?\M-7 ?|) doesn't work, because keyboard-translate-table
> is a char-table, which only handles unmodified characters.

You can find the character value of any key by the following function:

(defun get-char-value () "get decimal value of any key"
  (interactive)
       (let (char
             desc)
           (message "Type any char - " )
           (setq char (read-event))
           (if (not char)
               (message "Non char event - no value")
               (condition-case ()
                   (setq desc (text-char-description char))
                   (error
                       (setq desc "(No description)")))
                   (if (numberp char)
                       (message "Character typed is %s, (octal=%03o, 
decimal=%d, hexa=%02x)"
                               desc char char char)
                       (message "Input typed is %s, not a number" 
(prin1-to-string char t))))))


On my system it shows for Alt-7:
  Character typed is "7", (octal=20000067, decimal=4194359, hexa=400037)

So if you do:
  (define-key key-translation-map [4194359] "|")

It will do what you want (in all modes and maps - including isearch).

Because key-translation-map may not exist, you better protect yourself
by adding the following (before the define-key command):
  (if (not key-translation-map)
      (make-sparse-keymap key-translation-map))

Ehud.


- --
 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 mailto:address@hidden                  Better  Safe  Than  Sorry
-----BEGIN PGP SIGNATURE-----
Comment: use http://www.keyserver.net/ to get my key (and others)

iD8DBQE/M0vLLFvTvpjqOY0RAhX+AJ9LHeuuOApGdN3Bm7w4JQyZHjlrUACfSxfp
GuDiPrO+dSD2WK1otk5mPAY=
=KJMF
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]