unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Ehud Karni" <ehud@unix.mvs.co.il>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Alt as meta, except for certain keys, how?
Date: Fri, 8 Aug 2003 10:05:49 +0300	[thread overview]
Message-ID: <200308080705.h7875nTk030718@beta.mvs.co.il> (raw)
In-Reply-To: <3F329CBE.8050706@yahoo.com> (message from Kevin Rodgers on Thu,  07 Aug 2003 12:38:54 -0600)

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

On Thu, 07 Aug 2003 12:38:54 -0600, Kevin Rodgers <ihs_4664@yahoo.com> 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: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/M0vLLFvTvpjqOY0RAhX+AJ9LHeuuOApGdN3Bm7w4JQyZHjlrUACfSxfp
GuDiPrO+dSD2WK1otk5mPAY=
=KJMF
-----END PGP SIGNATURE-----

  reply	other threads:[~2003-08-08  7:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-07 17:33 Alt as meta, except for certain keys, how? Jussi Piitulainen
2003-08-07 18:38 ` Kevin Rodgers
2003-08-08  7:05   ` Ehud Karni [this message]
     [not found]   ` <mailman.222.1060326618.29551.help-gnu-emacs@gnu.org>
2003-08-08 18:51     ` Kevin Rodgers
2003-08-08 21:26       ` Ehud Karni
     [not found]       ` <mailman.235.1060378027.29551.help-gnu-emacs@gnu.org>
2003-08-11 18:10         ` Jussi Piitulainen
2003-08-11 20:29           ` Kevin Rodgers
2003-08-12  8:26             ` Jussi Piitulainen
2003-08-12 17:14               ` Kevin Rodgers
2003-08-13  5:14                 ` Jussi Piitulainen
2003-08-15 13:05             ` Kai Großjohann
2003-08-11 19:54         ` Kevin Rodgers
2003-08-12 11:13           ` Ehud Karni
     [not found]           ` <mailman.336.1060687053.29551.help-gnu-emacs@gnu.org>
2003-08-12 18:16             ` Jussi Piitulainen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200308080705.h7875nTk030718@beta.mvs.co.il \
    --to=ehud@unix.mvs.co.il \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).