all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Slightly OT: Where are keycodes defined for emacs -nw in X-Windows?
@ 2003-10-24 19:03 Alan Mackenzie
  2003-10-24 19:25 ` Barry Margolin
  2003-10-24 20:15 ` Stefan Monnier
  0 siblings, 2 replies; 12+ messages in thread
From: Alan Mackenzie @ 2003-10-24 19:03 UTC (permalink / raw)


Emacs 21.1.

In X-windows (running on GNU/Linux) I start emacs with "emacs -nw".  If I
type up and [C-up], followed by C-h l `view-lossage', I see this:

up     produces    ESC O A
[C-up] produces    ESC [ 2 4 ~

However, my Emacs isn't set up to handle the [C-up] event-sequence.  It
would seem I need to enhance my function-key-map somehow.

Searching the info pages brought me to the page "Terminal Specific" in
the Elisp manual.  Checking the environment variable TERM brought me to
the initalisation file ...../lisp/term/xterm.el.  In this file, only a
small number (21) of function keys are defined, none of them with
modifiers (i.e. C- M- S- ....).

Two questions:

Where on X is the file which defines the relevant keytable, and what's
the name of the function in X which loads such a table (analogues of
/etc/default.keytab and loadkeys for the Linux console)?

Is there a better file already in existence than the above xterm.el, one
that copes with _all_ keys with _all_ combinations of modifiers? 

Thanks in advance!

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Slightly OT: Where are keycodes defined for emacs -nw in X-Windows?
  2003-10-24 19:03 Slightly OT: Where are keycodes defined for emacs -nw in X-Windows? Alan Mackenzie
@ 2003-10-24 19:25 ` Barry Margolin
  2003-10-24 20:15 ` Stefan Monnier
  1 sibling, 0 replies; 12+ messages in thread
From: Barry Margolin @ 2003-10-24 19:25 UTC (permalink / raw)


In article <f2tbnb.ee.ln@acm.acm>, Alan Mackenzie <none@example.invalid> wrote:
>Emacs 21.1.
>
>In X-windows (running on GNU/Linux) I start emacs with "emacs -nw".  If I
>type up and [C-up], followed by C-h l `view-lossage', I see this:
>
>up     produces    ESC O A
>[C-up] produces    ESC [ 2 4 ~
>
>However, my Emacs isn't set up to handle the [C-up] event-sequence.  It
>would seem I need to enhance my function-key-map somehow.
>
>Searching the info pages brought me to the page "Terminal Specific" in
>the Elisp manual.  Checking the environment variable TERM brought me to
>the initalisation file ...../lisp/term/xterm.el.  In this file, only a
>small number (21) of function keys are defined, none of them with
>modifiers (i.e. C- M- S- ....).
>
>Two questions:
>
>Where on X is the file which defines the relevant keytable, and what's
>the name of the function in X which loads such a table (analogues of
>/etc/default.keytab and loadkeys for the Linux console)?

The translation from keycodes to escape sequences is done by the xterm
terminal emulator, not Emacs.  You can customize this by defining
translations in your XTerm app-defaults resource file.  See the xterm
documentation for details on this.

-- 
Barry Margolin, barry.margolin@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Slightly OT:  Where are keycodes defined for emacs -nw in X-Windows?
  2003-10-24 19:03 Slightly OT: Where are keycodes defined for emacs -nw in X-Windows? Alan Mackenzie
  2003-10-24 19:25 ` Barry Margolin
@ 2003-10-24 20:15 ` Stefan Monnier
  2003-10-24 20:19   ` Stefan Monnier
  2003-10-26 10:19   ` Alan Mackenzie
  1 sibling, 2 replies; 12+ messages in thread
From: Stefan Monnier @ 2003-10-24 20:15 UTC (permalink / raw)


> Searching the info pages brought me to the page "Terminal Specific" in
> the Elisp manual.  Checking the environment variable TERM brought me to
> the initalisation file ...../lisp/term/xterm.el.  In this file, only a
> small number (21) of function keys are defined, none of them with
> modifiers (i.e. C- M- S- ....).

The sequences are poorly standardized, especially the ones with modifiers.
That's why they're absent mostly.  But since it generally doesn't hurt to
add bindings to that table (as long as there's no collision between two
different bindings for the same sequence), feel free to send patches
to complete the table.

In the Emacs-CVS code, I've added a binding for C-up but it uses a different
sequence than yours (more specifically ESC [ 0 5 A).  This is the binding
I get on my GNU/Linux system.  Obviously, different GNU/Linux systems
will not necessarily all use the same sequence.

> Where on X is the file which defines the relevant keytable, and what's
> the name of the function in X which loads such a table (analogues of
> /etc/default.keytab and loadkeys for the Linux console)?

X is not directly at fault.  The translation from C-up to a sequence of
ASCII codes is done by your terminal emulator, so you need to look at
the doc of your xterm, kterm, what-have-you-term, ...

Then Emacs turns those sequences back into meaningful events based
on the lisp/term/$TERM.el file but also based on the terminfo of
your terminal.


        Stefan

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Slightly OT:  Where are keycodes defined for emacs -nw in X-Windows?
  2003-10-24 20:15 ` Stefan Monnier
@ 2003-10-24 20:19   ` Stefan Monnier
  2003-10-26 10:19   ` Alan Mackenzie
  1 sibling, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2003-10-24 20:19 UTC (permalink / raw)


> sequence than yours (more specifically ESC [ 0 5 A).  This is the binding
                                         ^^^^^^^^^^^
                                         ESC O 5 A
Sorry,


        Stefan

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Slightly OT: Where are keycodes defined for emacs -nw in X-Windows?
  2003-10-24 20:15 ` Stefan Monnier
  2003-10-24 20:19   ` Stefan Monnier
@ 2003-10-26 10:19   ` Alan Mackenzie
  2003-10-26 16:15     ` Thomas Dickey
                       ` (3 more replies)
  1 sibling, 4 replies; 12+ messages in thread
From: Alan Mackenzie @ 2003-10-26 10:19 UTC (permalink / raw)


Stefan Monnier <monnier@iro.umontreal.ca> wrote on Fri, 24 Oct 2003
20:15:24 GMT:
>> Searching the info pages brought me to the page "Terminal Specific" in
>> the Elisp manual.  Checking the environment variable TERM brought me
>> to the initalisation file ...../lisp/term/xterm.el.  In this file,
>> only a small number (21) of function keys are defined, none of them
>> with modifiers (i.e. C- M- S- ....).

Thanks Stefan, thanks Barry, for chrystal clear answers in record time!

> The sequences are poorly standardized, especially the ones with
> modifiers.  That's why they're absent mostly.  But since it generally
> doesn't hurt to add bindings to that table (as long as there's no
> collision between two different bindings for the same sequence), feel
> free to send patches to complete the table.

On my xterm, the modifier keys get filtered out, so that C-up and up
degenerate into the same event sequence.  :-(

>> Where on X is the file which defines the relevant keytable, and what's
>> the name of the function in X which loads such a table (analogues of
>> /etc/default.keytab and loadkeys for the Linux console)?

> X is not directly at fault.  The translation from C-up to a sequence of
> ASCII codes is done by your terminal emulator, so you need to look at
> the doc of your xterm, kterm, what-have-you-term, ...

<rant mode>
[... several frustrating hours later ... ].  The documentation of xterm
is of lesser quality than that of Emacs.  As well as its man-page, I've
got an introductory users' guide to X (a book).  It goes on and on and on
about the syntax of "resources" (whatever they are), but doesn't seem to
say whether they are compiled in with the application, are loaded from
some file, or what.  It spends nearly 30 pages (not counting a dump of
the complete man-page) describing xterm, yet fails to say where to find
the keyboard translation table used, or even give any pointers.  After
all, who'd want to know that anyway?

The glossary in this book lacks an entry for "resource", presumably on
the grounds that everybody knows what one is anyway, and an accurate
definition might spoil that nice warm feeling that you're meant to get
because "you've got lot's of resources, therefore you must be very
wealthy".  However, the glossary _does_ have an entry for "mouse", useful
for those people who don't know what that moveable lump of plastic beside
their keyboards is called.
<\rant mode>

Obviously the place to carry this on would be an X newsgroup, not here.

> Then Emacs turns those sequences back into meaningful events based on
> the lisp/term/$TERM.el file but also based on the terminfo of your
> terminal.

Yes.  I'm begining to wish I hadn't asked the question.  Obviously if I
want to get anywhere, I'm going to have to spend a _lot_ of time learning
about X.  That would be a lot of time not available for hacking Emacs.
:-(

Thanks anyhow!

>         Stefan

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Slightly OT: Where are keycodes defined for emacs -nw in X-Windows?
  2003-10-26 10:19   ` Alan Mackenzie
@ 2003-10-26 16:15     ` Thomas Dickey
  2003-10-28 10:16       ` Alan Mackenzie
  2003-10-27  9:50     ` Gian Uberto Lauri
                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Thomas Dickey @ 2003-10-26 16:15 UTC (permalink / raw)


Alan Mackenzie <none@example.invalid> wrote:

> On my xterm, the modifier keys get filtered out, so that C-up and up
> degenerate into the same event sequence.  :-(

DESCRIPTION
     The xterm program is a terminal emulator for  the  X  Window
     System.  It provides DEC VT102 and Tektronix 4014 compatible
     terminals for programs that  can't  use  the  window  system
     directly.   If the underlying operating system supports ter-
     minal resizing capabilities (for example, the SIGWINCH  sig-
     nal  in  systems  derived  from  4.3bsd), xterm will use the
     facilities to notify programs running in the window whenever
     it is resized.

a vt102, you may recall, doesn't have modifiers...

> <rant mode>
> [... several frustrating hours later ... ].  The documentation of xterm
> is of lesser quality than that of Emacs.  As well as its man-page, I've

xterm is (fortunately) smaller than Emacs, but it is documented.

if you read the manpage, you may notice this near the end:

SEE ALSO
     resize(1), stty(1), tty(1), tty(7), X11(7),
     Xterm Control Sequences

> got an introductory users' guide to X (a book).  It goes on and on and on
> about the syntax of "resources" (whatever they are), but doesn't seem to

start with man X11.

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Slightly OT: Where are keycodes defined for emacs -nw in X-Windows?
  2003-10-26 10:19   ` Alan Mackenzie
  2003-10-26 16:15     ` Thomas Dickey
@ 2003-10-27  9:50     ` Gian Uberto Lauri
       [not found]     ` <mailman.2518.1067256787.21628.help-gnu-emacs@gnu.org>
  2003-12-03 22:20     ` Kai Grossjohann
  3 siblings, 0 replies; 12+ messages in thread
From: Gian Uberto Lauri @ 2003-10-27  9:50 UTC (permalink / raw)
  Cc: help-gnu-emacs

>>>>> "AM" == Alan Mackenzie <none@example.invalid> writes:

AM> about the syntax of "resources" (whatever they are), but doesn't seem to
AM> say whether they are compiled in with the application, are loaded from
AM> some file, or what.

>From a file.

The user specific file should  have the name ".Xresources" if I remember
it correctly.

 /\            ___
/___/\__|_|\_|__|___Gian Uberto Lauri_____________________
  //--\ | | \|  |   Integralista GNUslamico e fancazzista 
\/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Slightly OT: Where are keycodes defined for emacs -nw in X-Windows?
       [not found]     ` <mailman.2518.1067256787.21628.help-gnu-emacs@gnu.org>
@ 2003-10-27 15:56       ` Stefan Monnier
  0 siblings, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2003-10-27 15:56 UTC (permalink / raw)


AM> about the syntax of "resources" (whatever they are), but doesn't seem to
AM> say whether they are compiled in with the application, are loaded from
AM> some file, or what.

> From a file.
> The user specific file should  have the name ".Xresources" if I remember
> it correctly.

It's all documented in the X11 manpage, but you basically have to know the
answer in order to find it and understand it :-(

The resources are found by the application in a few files and on the
X server which keeps a "resource database".  The resource database of the
server can be queried and modified with the `xrdb' command.  Typically upon
login, the user's ~/.Xresources is passed to `xrdb' to load it into the
X server's database.

The application also looks at files such as
/usr/X11R6/lib/X11/app-defaults/XTerm, and ~/.Xdefaults and then some,
depending on various envvars such as XENVIRONMENT, XFILESEARCHPATH,
XUSERFILESEARCHPATH and I'm probably forgetting some things.


        Stefan

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Slightly OT: Where are keycodes defined for emacs -nw in X-Windows?
  2003-10-26 16:15     ` Thomas Dickey
@ 2003-10-28 10:16       ` Alan Mackenzie
  2003-10-28 13:17         ` Thomas Dickey
  2003-10-28 15:21         ` Barry Margolin
  0 siblings, 2 replies; 12+ messages in thread
From: Alan Mackenzie @ 2003-10-28 10:16 UTC (permalink / raw)


Thomas Dickey <dickey@saltmine.radix.net> wrote on 26 Oct 2003 16:15:57
GMT:
> Alan Mackenzie <none@example.invalid> wrote:

>> On my xterm, the modifier keys get filtered out, so that C-up and up
>> degenerate into the same event sequence.  :-(

> DESCRIPTION
>      The xterm program is a terminal emulator for  the  X  Window
>      System.  It provides DEC VT102 and Tektronix 4014 compatible
>      terminals for programs that  can't  use  the  window  system
>      directly.   If the underlying operating system supports terminal
>      resizing capabilities (for example, the SIGWINCH  signal  in
>      systems  derived  from  4.3bsd), xterm will use the facilities to
>      notify programs running in the window whenever it is resized.

> a vt102, you may recall, doesn't have modifiers...

Well, funnily enough, in the twenty years since I last used one, that
fact seemed to have slipped my mind.  ;-)  The next question, of course,
is why on earth are we emulating a VT102, when "we" just want a command
line window?  Maybe I should look for a different emulator, "linux-term"
(or whatever).

>> <rant mode>
>> [... several frustrating hours later ... ].  The documentation of
>> xterm is of lesser quality than that of Emacs.  As well as its
>> man-page, I've

> xterm is (fortunately) smaller than Emacs, but it is documented.

> if you read the manpage, you may notice this near the end:

> SEE ALSO
>      resize(1), stty(1), tty(1), tty(7), X11(7),
>      Xterm Control Sequences

>> got an introductory users' guide to X (a book).  It goes on and on and
>> on about the syntax of "resources" (whatever they are), but doesn't
>> seem to

> start with man X11.

I Haven't got it.  Haven't got "man x11" either, but "man X" works.
Maybe that's because my system is very old.  In that manual page they go
with the "warm cosy feeling" approach too:

>From X man page:
> To  make the tailoring of applications to personal preferences easier,
> X provides a mechanism for  storing  default values  for program
> resources (e.g. background color, window title, etc.)  Resources are
> specified as strings  that are  read  in  from  various places when an
> application is run.  

So, one can store default values of program "resources";  but still no
sentence which has "resource" as the subject and "is" as the verb.  I
think "resource" is the X11 term for what sensible programs call
"settings" or "options" (or "customizable variables" ;-) and patronising
programs call "preferences".  It would be nice to be told, though, rather
than having to pick it up osmotically.

Why must the English language be so misused?  A "resource" is something
one can utilise productively and which it's good to have a lot of, like
money or disk space or agricultural land, or manufacturing plants.  What
was wrong with the word "setting"?

[By contrast, the Elisp manual starts off by saying that lisp is a
programming language.  Something that surely _everybody_ knows, but it's
written down anyway.  Sometimes I think it's a shame that such a wizard
documenter like RMS wasted so much time merely programming.  ;-]

Sorry, I'm still in rant mode at the moment.  I'm going to stop now.

Actually, I've got a much better idea now about xterm, resources and X
itself, than I had last week.  One of these days, I'll get over my
irritation and get down to learning X properly.

Thanks for all the help.

> -- 
> Thomas E. Dickey
> http://invisible-island.net
> ftp://invisible-island.net

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Slightly OT: Where are keycodes defined for emacs -nw in X-Windows?
  2003-10-28 10:16       ` Alan Mackenzie
@ 2003-10-28 13:17         ` Thomas Dickey
  2003-10-28 15:21         ` Barry Margolin
  1 sibling, 0 replies; 12+ messages in thread
From: Thomas Dickey @ 2003-10-28 13:17 UTC (permalink / raw)


Alan Mackenzie <none@example.invalid> wrote:
> Thomas Dickey <dickey@saltmine.radix.net> wrote on 26 Oct 2003 16:15:57
> GMT:
>> Alan Mackenzie <none@example.invalid> wrote:

>>> On my xterm, the modifier keys get filtered out, so that C-up and up
>>> degenerate into the same event sequence.  :-(

>> a vt102, you may recall, doesn't have modifiers...

> Well, funnily enough, in the twenty years since I last used one, that
> fact seemed to have slipped my mind.  ;-)  The next question, of course,
> is why on earth are we emulating a VT102, when "we" just want a command
> line window?  Maybe I should look for a different emulator, "linux-term"
> (or whatever).

oddly enough, Linux console uses modifiers less than xterm.

XFree86 xterm keyboard handling normally (the default resource settings),
does use modifiers (but your posting implied that you're not seeing that
behavior).

as for why (vt102 - or vt220) because it simplifies using systems that
people occasionally find useful.  A complete redesign won't solve that
problem.

>> start with man X11.

> I Haven't got it.  Haven't got "man x11" either, but "man X" works.
> Maybe that's because my system is very old.  In that manual page they go
> with the "warm cosy feeling" approach too:

it seems to depend on the system - I was quoting from Solaris' xterm manpage

xterm control sequences is not a manpage - there's an nroff-formatted copy off
my webpage (but it looks nicer in postscript).

> From X man page:
>> To  make the tailoring of applications to personal preferences easier,
>> X provides a mechanism for  storing  default values  for program
>> resources (e.g. background color, window title, etc.)  Resources are
>> specified as strings  that are  read  in  from  various places when an
>> application is run.  

> So, one can store default values of program "resources";  but still no
> sentence which has "resource" as the subject and "is" as the verb.  I
> think "resource" is the X11 term for what sensible programs call
> "settings" or "options" (or "customizable variables" ;-) and patronising
> programs call "preferences".  It would be nice to be told, though, rather
> than having to pick it up osmotically.

like all jargon - it's simple if you're familiar with it.
(and once familiar, one forgets that it's jargon).

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Slightly OT: Where are keycodes defined for emacs -nw in X-Windows?
  2003-10-28 10:16       ` Alan Mackenzie
  2003-10-28 13:17         ` Thomas Dickey
@ 2003-10-28 15:21         ` Barry Margolin
  1 sibling, 0 replies; 12+ messages in thread
From: Barry Margolin @ 2003-10-28 15:21 UTC (permalink / raw)


In article <0lflnb.16.ln@acm.acm>, Alan Mackenzie <none@example.invalid> wrote:
>So, one can store default values of program "resources";  but still no
>sentence which has "resource" as the subject and "is" as the verb.  I
>think "resource" is the X11 term for what sensible programs call
>"settings" or "options" (or "customizable variables" ;-) and patronising
>programs call "preferences".  It would be nice to be told, though, rather
>than having to pick it up osmotically.
>
>Why must the English language be so misused?  A "resource" is something
>one can utilise productively and which it's good to have a lot of, like
>money or disk space or agricultural land, or manufacturing plants.  What
>was wrong with the word "setting"?

I think Apple may have introduced the use of the word "resource" for this
type of thing being used with GUI systems, but I wouldn't be surprised if
it goes back to Xerox.  All Macintosh files have a separate "resource fork"
that contains structured data that goes along with the application data.
Some of these resources are just settings, but other resources are used to
hold messages, dialogue layouts, etc.

I think the X designers envisioned that its resources might also get more
general use than just parameter settings, so they copied the more general
term.

-- 
Barry Margolin, barry.margolin@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Slightly OT:  Where are keycodes defined for emacs -nw in X-Windows?
  2003-10-26 10:19   ` Alan Mackenzie
                       ` (2 preceding siblings ...)
       [not found]     ` <mailman.2518.1067256787.21628.help-gnu-emacs@gnu.org>
@ 2003-12-03 22:20     ` Kai Grossjohann
  3 siblings, 0 replies; 12+ messages in thread
From: Kai Grossjohann @ 2003-12-03 22:20 UTC (permalink / raw)


Alan Mackenzie<none@example.invalid> writes:

> On my xterm, the modifier keys get filtered out, so that C-up and up
> degenerate into the same event sequence.  :-(

You can tell xterm to send any string to the app inside when you hit
C-up.  Something like this:

XTerm.VT100.Translations:	#override \
                        <Key>Delete: string(0x1B) string("[3~") \n\
                   Ctrl <Key>Up: string(0x1B) string("abcde")

The above goes in ~/.Xdefaults or ~/.Xresources.  It tells xterm to
send ESC [ 3 ~ to the app when you press delete and, well, the rest
should be obvious.

Does it work?

Kai

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2003-12-03 22:20 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-24 19:03 Slightly OT: Where are keycodes defined for emacs -nw in X-Windows? Alan Mackenzie
2003-10-24 19:25 ` Barry Margolin
2003-10-24 20:15 ` Stefan Monnier
2003-10-24 20:19   ` Stefan Monnier
2003-10-26 10:19   ` Alan Mackenzie
2003-10-26 16:15     ` Thomas Dickey
2003-10-28 10:16       ` Alan Mackenzie
2003-10-28 13:17         ` Thomas Dickey
2003-10-28 15:21         ` Barry Margolin
2003-10-27  9:50     ` Gian Uberto Lauri
     [not found]     ` <mailman.2518.1067256787.21628.help-gnu-emacs@gnu.org>
2003-10-27 15:56       ` Stefan Monnier
2003-12-03 22:20     ` Kai Grossjohann

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.