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: Kevin Rodgers
Subject: Re: Alt as meta, except for certain keys, how?
Date: Fri, 08 Aug 2003 12:51:59 -0600
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

Ehud Karni wrote:

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

On Thu, 07 Aug 2003 12:38:54 -0600, Kevin Rodgers <address@hidden> wrote:
(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))))))


Overkill.


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


Just evaluate ?\M-7.  On my system, it is -134217673, which is the crux of the
problem: meta-modified characters may have a negative character code, and thus
may not be a valid index into a char-table.


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


key-translation-map takes character arguments, not (vector or string) keys:

wrong-type-argument integerp [-134217673]


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


But on my system, that signals an args-out-of-range error:

args-out-of-range #^[t nil nil nil ...] -134217673


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))

key-translation-map is now a char-table, not a keymap (see the Translating Input
node of the Emacs Lisp manual).

--
Kevin Rodgers



reply via email to

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