From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: Alt as meta, except for certain keys, how? Date: Fri, 08 Aug 2003 12:51:59 -0600 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <3F33F14F.2060903@yahoo.com> References: <3F329CBE.8050706@yahoo.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-8-I; format=flowed Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1060369308 6740 80.91.224.253 (8 Aug 2003 19:01:48 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 8 Aug 2003 19:01:48 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 08 21:02:14 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19lCVC-0003yE-00 for ; Fri, 08 Aug 2003 21:02:14 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19lCTg-0007Np-R4 for geh-help-gnu-emacs@m.gmane.org; Fri, 08 Aug 2003 15:00:40 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!syros.belnet.be!news.belnet.be!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!170.207.51.80!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 70 Original-NNTP-Posting-Host: 170.207.51.80 Original-X-Trace: news.uni-berlin.de 1060368710 30512941 170.207.51.80 (16 [82742]) User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2 X-Accept-Language: en-us Original-Xref: shelby.stanford.edu gnu.emacs.help:115755 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:11671 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:11671 Ehud Karni wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Thu, 07 Aug 2003 12:38:54 -0600, Kevin Rodgers 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