From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Ehud Karni" Newsgroups: gmane.emacs.help Subject: Re: Alt as meta, except for certain keys, how? Date: Sat, 9 Aug 2003 00:26:19 +0300 Organization: Mivtach-Simon Insurance agencies Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <200308082126.h78LQJOW020370@beta.mvs.co.il> References: <3F329CBE.8050706@yahoo.com> <3F33F14F.2060903@yahoo.com> Reply-To: ehud@unix.mvs.co.il NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-8-i Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1060378867 23943 80.91.224.253 (8 Aug 2003 21:41:07 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 8 Aug 2003 21:41:07 +0000 (UTC) Cc: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 08 23:41:31 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 19lEzL-0001kJ-00 for ; Fri, 08 Aug 2003 23:41:31 +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 19lElk-000622-0q for geh-help-gnu-emacs@m.gmane.org; Fri, 08 Aug 2003 17:27:28 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19lElK-00061L-Qd for help-gnu-emacs@gnu.org; Fri, 08 Aug 2003 17:27:02 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19lEko-0005xY-Ij for help-gnu-emacs@gnu.org; Fri, 08 Aug 2003 17:27:01 -0400 Original-Received: from [192.114.178.12] (helo=unix.mvs.co.il) by monty-python.gnu.org with esmtp (Exim 4.20) id 19lEkn-0005xO-PE for help-gnu-emacs@gnu.org; Fri, 08 Aug 2003 17:26:30 -0400 Original-Received: from beta.mvs.co.il (beta [10.253.0.3]) by unix.mvs.co.il (8.11.6/8.11.6) with ESMTP id h78LQNb12343; Sat, 9 Aug 2003 00:26:24 +0300 Original-Received: from beta.mvs.co.il (localhost [127.0.0.1]) by beta.mvs.co.il (8.12.5/8.12.5) with ESMTP id h78LQJBD020376; Sat, 9 Aug 2003 00:26:19 +0300 Original-Received: (from root@localhost) by beta.mvs.co.il (8.12.5/8.12.5/Submit) id h78LQJOW020370; Sat, 9 Aug 2003 00:26:19 +0300 Original-To: ihs_4664@yahoo.com In-reply-to: <3F33F14F.2060903@yahoo.com> (message from Kevin Rodgers on Fri, 08 Aug 2003 12:51:59 -0600) X-Mailer: Emacs 21.3.1 rmail (send-msg 1.108) 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:11677 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:11677 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Fri, 08 Aug 2003 12:51:59 -0600, Kevin Rodgers wrote: > > 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. It is not an overkill - see below. > > 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. I did evaluate ?\M-7 and I get the same result (-134217673) as you. It is NOT what my function returns (4194359) !!! > > So if you do: > > (define-key key-translation-map [4194359] "|") > > > key-translation-map takes character arguments, not (vector or string) keys: Not true, see below. > wrong-type-argument integerp [-134217673] On Cygwin Emacs (21.2) my function give the this number (dec=-134217673 hexa=f8000037) and when I do : (define-key key-translation-map [-134217673] "|") it works just fine (no error) and it does what's needed. > > 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 Did you use my function ? Did you check that key-translation-map exists ? I suggest you try my recipe exactly as it is given. I have tried it and it works (even with negative number). > > 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). I don't know which Emacs are you using, I checked it on 21.2, 21.3. and 21.3.50 (CVS HEAD version). On all the documentation for ` key-translation-map' says: Keymap of key translations that can override keymaps. This keymap works like `function-key-map', but comes after that, and applies even for keys that have ordinary bindings. I think you confuse it with `keyboard-translate-table' which is used/created by the `keyboard-translate' command. 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:ehud@unix.mvs.co.il Better Safe Than Sorry -----BEGIN PGP SIGNATURE----- Comment: use http://www.keyserver.net/ to get my key (and others) iD8DBQE/NBV6LFvTvpjqOY0RAtrdAJ9Ug/ADrgre76kS0G5SdE3jW9aGNACfVuJp GQA+SnMsgMpUnIruhcNLwYs= =UT// -----END PGP SIGNATURE-----