all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* translating numpad keys in linux terminal
@ 2015-03-30 15:12 Tim Johnson
  2015-04-01 10:08 ` Michael Heerdegen
       [not found] ` <mailman.3119.1427882930.31049.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 19+ messages in thread
From: Tim Johnson @ 2015-03-30 15:12 UTC (permalink / raw)
  To: Emacs

With emacs 24 on linux ubuntu 14.04 

Gui emacs translates all numeric keypad keys except the backspace as
distinct from the equivalent on the main keyboard.

Example : kp-up vs. up

Unfortunately, my preference is emacs -nw from the terminal, which
in this case is gnome-terminal. emacs -nw only translates 
kp-(divide, multiply, minus, plus and enter).

Is there a way to read the other keys with "kp-" as in gui emacs?

thanks
-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com



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

* Re: translating numpad keys in linux terminal
  2015-03-30 15:12 Tim Johnson
@ 2015-04-01 10:08 ` Michael Heerdegen
       [not found] ` <mailman.3119.1427882930.31049.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 19+ messages in thread
From: Michael Heerdegen @ 2015-04-01 10:08 UTC (permalink / raw)
  To: Emacs

Tim Johnson <tim@akwebsoft.com> writes:

> Is there a way to read the other keys with "kp-" as in gui emacs?

I don't think so.  If you have a look at the lossage (C-h l), you see
what events Emacs receives before doing any key translations.

For the up and kp-up keys for example I see the same events coming from
the terminal: ESC O A.  Thus Emacs can't distinguish the two.

At least that's what happens here.  Maybe it is different when using
a different terminal or different terminal settings.


Michael.



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

* Re: translating numpad keys in linux terminal
       [not found] ` <mailman.3119.1427882930.31049.help-gnu-emacs@gnu.org>
@ 2015-04-01 14:33   ` Pascal J. Bourguignon
  2015-04-01 15:37     ` Tim Johnson
                       ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Pascal J. Bourguignon @ 2015-04-01 14:33 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Tim Johnson <tim@akwebsoft.com> writes:
>
>> Is there a way to read the other keys with "kp-" as in gui emacs?
>
> I don't think so.  If you have a look at the lossage (C-h l), you see
> what events Emacs receives before doing any key translations.
>
> For the up and kp-up keys for example I see the same events coming from
> the terminal: ESC O A.  Thus Emacs can't distinguish the two.
>
> At least that's what happens here.  Maybe it is different when using
> a different terminal or different terminal settings.

It all depends if you can configure your terminal (or terminal
emulator), to send different code sequences to distinguish 1 from kp-1.

If you use a terminal emulator, they you might be able to patch it more
easily than if you use a physical terminal (which assumedly is
improbable).

-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


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

* Re: translating numpad keys in linux terminal
  2015-04-01 14:33   ` Pascal J. Bourguignon
@ 2015-04-01 15:37     ` Tim Johnson
       [not found]     ` <mailman.3140.1427902682.31049.help-gnu-emacs@gnu.org>
  2015-04-01 23:23     ` Emanuel Berg
  2 siblings, 0 replies; 19+ messages in thread
From: Tim Johnson @ 2015-04-01 15:37 UTC (permalink / raw)
  To: help-gnu-emacs

* Pascal J. Bourguignon <pjb@informatimago.com> [150401 07:11]:
> Michael Heerdegen <michael_heerdegen@web.de> writes:
> 
> > Tim Johnson <tim@akwebsoft.com> writes:
> >
> >> Is there a way to read the other keys with "kp-" as in gui emacs?
> >
> > I don't think so.  If you have a look at the lossage (C-h l), you see
> > what events Emacs receives before doing any key translations.
> >
> > For the up and kp-up keys for example I see the same events coming from
> > the terminal: ESC O A.  Thus Emacs can't distinguish the two.
> >
> > At least that's what happens here.  Maybe it is different when using
> > a different terminal or different terminal settings.
> 
> It all depends if you can configure your terminal (or terminal
> emulator), to send different code sequences to distinguish 1 from kp-1.
> 
> If you use a terminal emulator, they you might be able to patch it more
> easily than if you use a physical terminal (which assumedly is
> improbable).
> -- 
> __Pascal Bourguignon__                 http://www.informatimago.com/
> “The factory of the future will have only two employees, a man and a
> dog. The man will be there to feed the dog. The dog will be there to
> keep the man from touching the equipment.” -- Carl Bass CEO Autodesk
  Thanks for the replies. I found the same with earlier versions of
  ubuntu. 
  
  FYI: The workstation is a mac mini with OS X on dual-boot. I
  find that iTerm2 translates all but the enter key, but as if
  numlock is on (which is OK for binding).

  Oh well, I'll just use X11 emacs, which is as nimble on ubuntu as
  terminal mode is on the Mac :)
  thanks again

-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com



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

* Re: translating numpad keys in linux terminal
       [not found]     ` <mailman.3140.1427902682.31049.help-gnu-emacs@gnu.org>
@ 2015-04-01 16:28       ` Pascal J. Bourguignon
  2015-04-01 18:57         ` Tim Johnson
  0 siblings, 1 reply; 19+ messages in thread
From: Pascal J. Bourguignon @ 2015-04-01 16:28 UTC (permalink / raw)
  To: help-gnu-emacs

Tim Johnson <tim@akwebsoft.com> writes:

>   FYI: The workstation is a mac mini with OS X on dual-boot. I
>   find that iTerm2 translates all but the enter key, but as if
>   numlock is on (which is OK for binding).
>
>   Oh well, I'll just use X11 emacs, which is as nimble on ubuntu as
>   terminal mode is on the Mac :)
>   thanks again

Then just install X11 on MacOSX, and use X11 emacs (be it a remote or a
local), or use http://emacsformacosx.com locally.

http://xquartz.macosforge.org/landing/

-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


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

* Re: translating numpad keys in linux terminal
  2015-04-01 16:28       ` Pascal J. Bourguignon
@ 2015-04-01 18:57         ` Tim Johnson
  0 siblings, 0 replies; 19+ messages in thread
From: Tim Johnson @ 2015-04-01 18:57 UTC (permalink / raw)
  To: help-gnu-emacs

* Pascal J. Bourguignon <pjb@informatimago.com> [150401 08:50]:
> Tim Johnson <tim@akwebsoft.com> writes:
> 
> >   FYI: The workstation is a mac mini with OS X on dual-boot. I
> >   find that iTerm2 translates all but the enter key, but as if
> >   numlock is on (which is OK for binding).
> >
> >   Oh well, I'll just use X11 emacs, which is as nimble on ubuntu as
> >   terminal mode is on the Mac :)
> >   thanks again
> 
> Then just install X11 on MacOSX, and use X11 emacs (be it a remote or a
> local), or use http://emacsformacosx.com locally.
> 
> http://xquartz.macosforge.org/landing/
  Thanks. Never knew about it ...
-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com



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

* Re: translating numpad keys in linux terminal
  2015-04-01 14:33   ` Pascal J. Bourguignon
  2015-04-01 15:37     ` Tim Johnson
       [not found]     ` <mailman.3140.1427902682.31049.help-gnu-emacs@gnu.org>
@ 2015-04-01 23:23     ` Emanuel Berg
  2 siblings, 0 replies; 19+ messages in thread
From: Emanuel Berg @ 2015-04-01 23:23 UTC (permalink / raw)
  To: help-gnu-emacs

"Pascal J. Bourguignon" <pjb@informatimago.com>
writes:

> It all depends if you can configure your terminal
> (or terminal emulator), to send different code
> sequences to distinguish 1 from kp-1.

Try xev(1) from xterm in X - /usr/bin/xev, likely -
and hit the different keys. Do you (the OP) get
different results? I do, but I also get an annoying
little window which reports the keypresses.
With 'emacs -nw', don't you still have the terminal
window to do this? Maybe the reason is: 'emacs -nw'
doesn't only say "run Emacs in a terminal", perhaps it
also says "...then we don't need to bother about some
modules" and those are precisely what you would need.

Regardless of whatever, those keys are not good
(neither) as they involve moving your right hand out
of typing position. You have more luck, and more
speed, with shortcuts that don't require you to move
your hands from the "asdf" and "jkl;" positions.

Another approach would be to do a little configuration
to the GUI Emacs: get away with the menu, scrollbars,
and so on. Soon, it'll look just like the terminal
version and with modern computers it should be just as
fast as well.

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: translating numpad keys in linux terminal
       [not found] <mailman.3029.1427728348.31049.help-gnu-emacs@gnu.org>
@ 2015-04-01 23:46 ` Dan Espen
  2015-04-02 10:49 ` Simon Clubley
  1 sibling, 0 replies; 19+ messages in thread
From: Dan Espen @ 2015-04-01 23:46 UTC (permalink / raw)
  To: help-gnu-emacs

Tim Johnson <tim@akwebsoft.com> writes:

> With emacs 24 on linux ubuntu 14.04 
>
> Gui emacs translates all numeric keypad keys except the backspace as
> distinct from the equivalent on the main keyboard.
>
> Example : kp-up vs. up
>
> Unfortunately, my preference is emacs -nw from the terminal, which
> in this case is gnome-terminal. emacs -nw only translates 
> kp-(divide, multiply, minus, plus and enter).
>
> Is there a way to read the other keys with "kp-" as in gui emacs?

If you were using xterm, rxvt, you could use X-Resources to set the "translations"
resource to create any kind translation of X11 key to any string you like.

The xterm man page describes this.

-- 
Dan Espen


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

* Re: translating numpad keys in linux terminal
       [not found] <mailman.3029.1427728348.31049.help-gnu-emacs@gnu.org>
  2015-04-01 23:46 ` translating numpad keys in linux terminal Dan Espen
@ 2015-04-02 10:49 ` Simon Clubley
  2015-04-02 23:10   ` Emanuel Berg
  1 sibling, 1 reply; 19+ messages in thread
From: Simon Clubley @ 2015-04-02 10:49 UTC (permalink / raw)
  To: help-gnu-emacs

On 2015-03-30, Tim Johnson <tim@akwebsoft.com> wrote:
> With emacs 24 on linux ubuntu 14.04 
>
> Gui emacs translates all numeric keypad keys except the backspace as
> distinct from the equivalent on the main keyboard.
>
> Example : kp-up vs. up
>
> Unfortunately, my preference is emacs -nw from the terminal, which
> in this case is gnome-terminal. emacs -nw only translates 
> kp-(divide, multiply, minus, plus and enter).
>
> Is there a way to read the other keys with "kp-" as in gui emacs?
>

Yes. (I currently rely on this ability for some of my workflow as
I use the EDT keypad layout when editing in emacs.)

You need a decent terminal emulator which supports DEC keyboard
escape sequences correctly and can go into application keypad mode.
For me, xterm with a script[*] I picked up from comp.os.vms a decade
or so qualifies as does the pterm component of PuTTY.

In both cases, I am running the keyboard permanently in application
keypad mode, rather than messing around with going in and out of
application keypad mode when entering/exiting emacs. This may not be
suitable for you and you may choose to do the switching yourself
as required.

You then have two choices:

1) You can look at a version of tpu-edt.el from early emacs 22.x or
before which shows how to turn the incoming escape sequences into
something can be processed within your emacs code.

2) Sometime after this, tpu-edt.el was rewritten to drop the direct
processing of escape sequences (and utterly breaking character cell
support in the process; I've only just discovered this after switching
to a newer LTS version of Linux and I've just notified the tpu-edt.el
author).

However, even in this broken version, when TERM is set to vt200, the
keypad keys other than PF1-PF4 still work when in application keypad
mode, so this might be enough for you. If so, have a look at a current
version of tpu-edt.el and you might be able to see something which you
can use; this would appear to be an easier approach than directly
processing escape sequences in your case.

Simon.

[*] There's a script on http://invisible-island.net/xterm/xterm.faq.html
which might help you get started if you choose this approach; you want
one which maps Num Lock to PF1; these specific scripts I have not tested
however.

-- 
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980s technology to a 21st century world


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

* Re: translating numpad keys in linux terminal
  2015-04-02 10:49 ` Simon Clubley
@ 2015-04-02 23:10   ` Emanuel Berg
  2015-04-02 23:45     ` Richard Wordingham
                       ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Emanuel Berg @ 2015-04-02 23:10 UTC (permalink / raw)
  To: help-gnu-emacs

Simon Clubley
<clubley@remove_me.eisner.decus.org-Earth.UFP> writes:

> ... tpu-edt.el ... when TERM is set to vt200, the
> keypad keys other than PF1-PF4 still work when in
> application keypad mode, so this might be enough for
> you. ...

What? :)

Please explain in more detail what to do step by step.

If I set TERM to vt200 ('TERM=vt200 emacs -nw' in
xterm), my colors are broken. Tho I am able to
(require 'tpu-edt) that doesn't do anything to change
the keys reported by `describe-key' what I can see.

But yes, X and xterm should be enough because as said,
xev do reports different keys when run from xterm.

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: translating numpad keys in linux terminal
  2015-04-02 23:10   ` Emanuel Berg
@ 2015-04-02 23:45     ` Richard Wordingham
       [not found]     ` <mailman.3207.1428018356.31049.help-gnu-emacs@gnu.org>
  2015-04-03 13:35     ` Simon Clubley
  2 siblings, 0 replies; 19+ messages in thread
From: Richard Wordingham @ 2015-04-02 23:45 UTC (permalink / raw)
  To: help-gnu-emacs

On Fri, 03 Apr 2015 01:10:47 +0200
Emanuel Berg <embe8573@student.uu.se> wrote:

> But yes, X and xterm should be enough because as said,
> xev do reports different keys when run from xterm.

When I run xev on Ubuntu 12.04 in a gnome-terminal and then select the
original terminal, xev reports nothing when I hit keypad keys.  Some
keys generate sequences that are echoed to the terminal.  This is the
root of the problem.  Emacs does not get keystrokes directly from X;
instead they are mediated by the terminal emulator, gnome-terminal in
my case.

Now, if I click on the window created by xev, keypad events do get
reported.  These events have gone to Xev via the X system; the terminal
emulator has not seen them as directed at it.

Richard.




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

* Re: translating numpad keys in linux terminal
       [not found]     ` <mailman.3207.1428018356.31049.help-gnu-emacs@gnu.org>
@ 2015-04-03  0:48       ` Emanuel Berg
  2015-04-03  1:23         ` Emanuel Berg
  2015-04-03  1:25         ` Dan Espen
  0 siblings, 2 replies; 19+ messages in thread
From: Emanuel Berg @ 2015-04-03  0:48 UTC (permalink / raw)
  To: help-gnu-emacs

Richard Wordingham <richard.wordingham@ntlworld.com>
writes:

> When I run xev on Ubuntu 12.04 in a gnome-terminal
> and then select the original terminal, xev reports
> nothing when I hit keypad keys. Some keys generate
> sequences that are echoed to the terminal. This is
> the root of the problem. Emacs does not get
> keystrokes directly from X; instead they are
> mediated by the terminal emulator, gnome-terminal in
> my case.
>
> Now, if I click on the window created by xev, keypad
> events do get reported. These events have gone to
> Xev via the X system; the terminal emulator has not
> seen them as directed at it.

... regardless of whatever, with X and xterm and xev
(and possibly the uncanny X-Men as well, tho we have
to look into that), you *are* able to get output that
indicates a distinction between the numerologist
keypad and the bender arrow keys, e.g.:

         keycode 83 (keysym 0xff96, KP_Left)

                         vs.

          keycode 113 (keysym 0xff51, Left)

This tells me, in principle there shouldn't be
a problem for 'emacs -nw' to do the same. Why this
doesn't happen is thus due to some implementation
detail or policy: be it a bug, a coincidence, or
a consideration - either in Emacs itself, or in how
Emacs is run in the terminal.

Perhaps someone in this list that is familiar with
just exactly what the '-nw' option does can
enlighten us?

PS. For me, it works with gnome-terminal as well tho
    I don't recommend using it all the same.

PPS. Here is the entire xev output:

    KeyRelease event, serial 47, synthetic NO, window 0xa00001,
        root 0x22d, subw 0x0, time 20703938, (-1,747), root:(0,767),
        state 0x0, keycode 83 (keysym 0xff96, KP_Left), same_screen YES,
        XLookupString gives 0 bytes:
        XFilterEvent returns: False

    KeyPress event, serial 47, synthetic NO, window 0xa00001,
        root 0x22d, subw 0x0, time 20704914, (-1,747), root:(0,767),
        state 0x0, keycode 113 (keysym 0xff51, Left), same_screen YES,
        XLookupString gives 0 bytes:
        XmbLookupString gives 0 bytes:
        XFilterEvent returns: False

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: translating numpad keys in linux terminal
  2015-04-03  0:48       ` Emanuel Berg
@ 2015-04-03  1:23         ` Emanuel Berg
  2015-04-03  1:25         ` Dan Espen
  1 sibling, 0 replies; 19+ messages in thread
From: Emanuel Berg @ 2015-04-03  1:23 UTC (permalink / raw)
  To: help-gnu-emacs

If one instead opens xterm, and in another window do
'wmctrl -l' and then 'xev -id 0x0140000d' (if that is
the window ID of the xterm instance), then one gets
a bunch of output like this.

Man, I'm happy I don't use X that often and never the
arrow and numpad keys :) Well, the window seems to be
the "key" to this problem, as well.

    FocusIn event, serial 18, synthetic NO, window 0x140000d,
        mode NotifyNormal, detail NotifyNonlinear

    KeymapNotify event, serial 18, synthetic NO, window 0x0,
        keys:  4294967237 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
               0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

    VisibilityNotify event, serial 18, synthetic NO, window 0x140000d,
        state VisibilityUnobscured

    EnterNotify event, serial 18, synthetic NO, window 0x140000d,
        root 0x22d, subw 0x140001b, time 23233067, (0,767), root:(0,767),
        mode NotifyNormal, detail NotifyNonlinearVirtual, same_screen YES,
        focus YES, state 0

    KeymapNotify event, serial 18, synthetic NO, window 0x0,
        keys:  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
               0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

    FocusOut event, serial 18, synthetic NO, window 0x140000d,
        mode NotifyGrab, detail NotifyAncestor

    FocusOut event, serial 18, synthetic NO, window 0x140000d,
        mode NotifyGrab, detail NotifyPointer

    VisibilityNotify event, serial 18, synthetic NO, window 0x140000d,
        state VisibilityPartiallyObscured

    LeaveNotify event, serial 18, synthetic NO, window 0x140000d,
        root 0x22d, subw 0x140001b, time 23239673, (0,767), root:(0,767),
        mode NotifyNormal, detail NotifyNonlinearVirtual, same_screen YES,
        focus YES, state 8

    FocusIn event, serial 18, synthetic NO, window 0x140000d,
        mode NotifyUngrab, detail NotifyNonlinear

    KeymapNotify event, serial 18, synthetic NO, window 0x0,
        keys:  45  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
               0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

    EnterNotify event, serial 18, synthetic NO, window 0x140000d,
        root 0x22d, subw 0x140001b, time 23239803, (0,767), root:(0,767),
        mode NotifyNormal, detail NotifyNonlinearVirtual, same_screen YES,
        focus YES, state 0

    KeymapNotify event, serial 18, synthetic NO, window 0x0,
        keys:  2   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
               0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

    VisibilityNotify event, serial 18, synthetic NO, window 0x140000d,
        state VisibilityUnobscured

    FocusOut event, serial 18, synthetic NO, window 0x140000d,
        mode NotifyNormal, detail NotifyNonlinear

    VisibilityNotify event, serial 18, synthetic NO, window 0x140000d,
        state VisibilityFullyObscured

    LeaveNotify event, serial 18, synthetic NO, window 0x140000d,
        root 0x22d, subw 0x140001b, time 23239811, (0,767), root:(0,767),
        mode NotifyNormal, detail NotifyNonlinearVirtual, same_screen YES,
        focus NO, state 0

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: translating numpad keys in linux terminal
  2015-04-03  0:48       ` Emanuel Berg
  2015-04-03  1:23         ` Emanuel Berg
@ 2015-04-03  1:25         ` Dan Espen
  2015-04-03  1:46           ` Emanuel Berg
  1 sibling, 1 reply; 19+ messages in thread
From: Dan Espen @ 2015-04-03  1:25 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> Richard Wordingham <richard.wordingham@ntlworld.com>
> writes:
>
> Perhaps someone in this list that is familiar with
> just exactly what the '-nw' option does can
> enlighten us?

From the docs:

  Don't communicate directly with the window system, disregarding the
  DISPLAY environment variable even if it is set. This means that Emacs
  uses the terminal from which it was launched for all its display and
  input.

The terminal gets and sends X Events.

Emacs gets and sends _characters_ to and  from the terminal.

Sometimes Emacs may get signals from the terminal,
like when the terminal is resized.

Emacs in a terminal does not see X Events.

So, your issue is what does the terminal send to Emacs
when you hit a KP key,

Terminals like rxvt and xterm give you complete control.

gnome-terminal, sorry, I don't use it.

-- 
Dan Espen


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

* Re: translating numpad keys in linux terminal
  2015-04-03  1:25         ` Dan Espen
@ 2015-04-03  1:46           ` Emanuel Berg
  2015-04-03  2:56             ` Tim Johnson
       [not found]             ` <mailman.3215.1428029828.31049.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 19+ messages in thread
From: Emanuel Berg @ 2015-04-03  1:46 UTC (permalink / raw)
  To: help-gnu-emacs

Dan Espen <despen@verizon.net> writes:

>> Perhaps someone in this list that is familiar with
>> just exactly what the '-nw' option does can
>> enlighten us?
>
> From the docs:
>
> Don't communicate directly with the window system,
> disregarding the DISPLAY environment variable even
> if it is set. This means that Emacs uses the
> terminal from which it was launched for all its
> display and input.
>
> The terminal gets and sends X Events.
>
> Emacs gets and sends _characters_ to and from
> the terminal.
>
> Sometimes Emacs may get signals from the terminal,
> like when the terminal is resized.
>
> Emacs in a terminal does not see X Events.
>
> So, your issue is what does the terminal send to Emacs
> when you hit a KP key,
>
> Terminals like rxvt and xterm give you
> complete control.
>
> gnome-terminal, sorry, I don't use it.

Case closed.

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: translating numpad keys in linux terminal
  2015-04-03  1:46           ` Emanuel Berg
@ 2015-04-03  2:56             ` Tim Johnson
       [not found]             ` <mailman.3215.1428029828.31049.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 19+ messages in thread
From: Tim Johnson @ 2015-04-03  2:56 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg <embe8573@student.uu.se> [150402 17:49]:
> Dan Espen <despen@verizon.net> writes:
> 
> >> Perhaps someone in this list that is familiar with
> >> just exactly what the '-nw' option does can
> >> enlighten us?
> >
> > From the docs:
> >
> > Don't communicate directly with the window system,
> > disregarding the DISPLAY environment variable even
> > if it is set. This means that Emacs uses the
> > terminal from which it was launched for all its
> > display and input.
> >
> > The terminal gets and sends X Events.
> >
> > Emacs gets and sends _characters_ to and from
> > the terminal.
> >
> > Sometimes Emacs may get signals from the terminal,
> > like when the terminal is resized.
> >
> > Emacs in a terminal does not see X Events.
> >
> > So, your issue is what does the terminal send to Emacs
> > when you hit a KP key,
> >
> > Terminals like rxvt and xterm give you
> > complete control.
> >
> > gnome-terminal, sorry, I don't use it.
> 
> Case closed.
  Indeed. 
  
  My workstation is a Mac Mini. To recap, I get unique translations
  of numeric keypad input to 'emacs' running from iTerm2.

  I didn't get the same uniqueness when I booted the same machine
  into ubuntu 14.04 and ran 'emacs -nw' from gnome-terminal.

  The terminal emulator controls what emacs gets when it is in
  terminal - this from the good people who responded to my
  inquiries.

  As has been pointed out, rxvt _does_ translate numeric keypad
  uniquely (unlink gnome-terminal). By starting rxvt in my setup and
  then invoking emacs -nw and then running <help>-c, I can see that
  M-O sequences are being generated (that is Alt-Shift-(the capital
  letter "O")).

  If I so choose then I could build unique definitions of keypad
  input by runing emacs in terminal mode from rxvt (or presumable
  xterm). 
   
  X11 emacs in ubuntu is preferable to AquaMacs on OS X, (for me
  anyway) and I can just use it.

  Thanks for all the input. Great thread.

  cheers
-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com



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

* Re: translating numpad keys in linux terminal
       [not found]             ` <mailman.3215.1428029828.31049.help-gnu-emacs@gnu.org>
@ 2015-04-03  3:38               ` Dan Espen
  0 siblings, 0 replies; 19+ messages in thread
From: Dan Espen @ 2015-04-03  3:38 UTC (permalink / raw)
  To: help-gnu-emacs

Tim Johnson <tim@akwebsoft.com> writes:

> * Emanuel Berg <embe8573@student.uu.se> [150402 17:49]:
>> Dan Espen <despen@verizon.net> writes:
>> 
>> >> Perhaps someone in this list that is familiar with
>> >> just exactly what the '-nw' option does can
>> >> enlighten us?
>> >
>> > From the docs:
>> >
>> > Don't communicate directly with the window system,
>> > disregarding the DISPLAY environment variable even
>> > if it is set. This means that Emacs uses the
>> > terminal from which it was launched for all its
>> > display and input.
>> >
>> > The terminal gets and sends X Events.
>> >
>> > Emacs gets and sends _characters_ to and from
>> > the terminal.
>> >
>> > Sometimes Emacs may get signals from the terminal,
>> > like when the terminal is resized.
>> >
>> > Emacs in a terminal does not see X Events.
>> >
>> > So, your issue is what does the terminal send to Emacs
>> > when you hit a KP key,
>> >
>> > Terminals like rxvt and xterm give you
>> > complete control.
>> >
>> > gnome-terminal, sorry, I don't use it.
>> 
>> Case closed.
>   Indeed. 
>   
>   My workstation is a Mac Mini. To recap, I get unique translations
>   of numeric keypad input to 'emacs' running from iTerm2.
>
>   I didn't get the same uniqueness when I booted the same machine
>   into ubuntu 14.04 and ran 'emacs -nw' from gnome-terminal.
>
>   The terminal emulator controls what emacs gets when it is in
>   terminal - this from the good people who responded to my
>   inquiries.
>
>   As has been pointed out, rxvt _does_ translate numeric keypad
>   uniquely (unlink gnome-terminal). By starting rxvt in my setup and
>   then invoking emacs -nw and then running <help>-c, I can see that
>   M-O sequences are being generated (that is Alt-Shift-(the capital
>   letter "O")).

The man pages describes more.
This is from an xresource file for XTerm:

XTerm*VT100.translations:#override\n\
	Shift<Key>KP_9:	scroll-back(1, page)\n\
	Shift<Key>KP_3:	scroll-forw(1, page)

The "translations" resource lets you specify
the X event and the corresponding action for that event.

So, if I wanted the un-shifted KP_9 key to
do something special I could specify:

	None<Key>KP_9:	string("Hi Mom!") \n\

The first part is the X event, the second part is the action
as described in the man page.

I'm guessing gnome-terminal has something equivalent
but perhaps not as flexible.

-- 
Dan Espen


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

* Re: translating numpad keys in linux terminal
  2015-04-02 23:10   ` Emanuel Berg
  2015-04-02 23:45     ` Richard Wordingham
       [not found]     ` <mailman.3207.1428018356.31049.help-gnu-emacs@gnu.org>
@ 2015-04-03 13:35     ` Simon Clubley
  2015-04-05 23:39       ` Emanuel Berg
  2 siblings, 1 reply; 19+ messages in thread
From: Simon Clubley @ 2015-04-03 13:35 UTC (permalink / raw)
  To: help-gnu-emacs

On 2015-04-02, Emanuel Berg <embe8573@student.uu.se> wrote:
> Simon Clubley
><clubley@remove_me.eisner.decus.org-Earth.UFP> writes:
>
>> ... tpu-edt.el ... when TERM is set to vt200, the
>> keypad keys other than PF1-PF4 still work when in
>> application keypad mode, so this might be enough for
>> you. ...
>
> What? :)
>

I promise you that explanation would make perfect sense to someone
with a DEC background who had actually used the physical terminals
the various emulators emulate (with various degrees of accuracy). :-)

> Please explain in more detail what to do step by step.
>

Other postings have covered most of this. However, a bit of background
on DEC terminals because I can see why you might be confused by what
I said.

On a DEC terminal, the top row of the keypad sends out escape sequences
when the keys on that row are pressed. The keys are known as PF1 (which
is the Num Lock position on a PC keyboard) through PF4 (the minus key).
PF1 is also known as the Gold key in the DEC world and you can see it
described as such in tpu-edt.el.

The rest of the keypad can operate in one of two modes, a numeric keypad
mode and an application keypad mode. You can switch the terminal between
these two modes by sending escape sequences to the terminal from a program.

In numeric mode, pressing (say) the 5 key, sends a 5. In application keypad
mode, pressing a key sends a specific and unique escape sequence.
Applications in the DEC world (such as editors) use this to determine the
user pressed a key on the keypad instead of on the main keyboard.

> If I set TERM to vt200 ('TERM=vt200 emacs -nw' in
> xterm), my colors are broken. Tho I am able to
> (require 'tpu-edt) that doesn't do anything to change
> the keys reported by `describe-key' what I can see.
>
> But yes, X and xterm should be enough because as said,
> xev do reports different keys when run from xterm.
>

As someone else mentioned, the different keycodes are required, but not
sufficient. When emacs is in character cell mode (emacs -nw) the only
thing it can see are the escape sequences coming from the terminal
emulator; it has no knowledge of what is going on at X11 level.

Either the terminal emulator already knows it needs to send these escape
sequences in response to a key press or it needs to be configured to do
so via some keycode to escape sequence mapping.

Simon.

-- 
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980s technology to a 21st century world


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

* Re: translating numpad keys in linux terminal
  2015-04-03 13:35     ` Simon Clubley
@ 2015-04-05 23:39       ` Emanuel Berg
  0 siblings, 0 replies; 19+ messages in thread
From: Emanuel Berg @ 2015-04-05 23:39 UTC (permalink / raw)
  To: help-gnu-emacs

Simon Clubley
<clubley@remove_me.eisner.decus.org-Earth.UFP> writes:

> I promise you that explanation would make perfect
> sense to someone with a DEC background who had
> actually used the physical terminals the various
> emulators emulate (with various degrees of
> accuracy). :-)

I would have loved to have done that, or do that, tho
if I did today that would rather be an interesting
excursion to the past (?) than "reality", of course.
One of the most appealing thing about the mainframe
epoch is that those who did it were computer,
technology, and/or science people in one way or
another. That doesn't mean they had to be hot shots at
companies or universities (tho that would have helped)
- most European and Australian hackers are from the
blue collar or modest white collar classes, and
I suspect it is the same in America (but not in Asia,
though I suspect that to change if it hasn't already
as computers climb down the social ladder). Today on
the other hand everyone uses computers and where it
will lead will sure be interesting to follow :) I can
already see that many advanced computer users don't
have a problem living the hybrid computer life of
using the soft-/hardware/services of the masses, then
seamlessly switch and do their advanced projects, then
switch backs, and so on - while others are proud of
their elitism and stubborn exclusiveness...

> Other postings have covered most of this. However,
> a bit of background ...

Thank you, I don't have any comments on that material
but I thought it'd be unappreciative not to comment at
all :)

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

end of thread, other threads:[~2015-04-05 23:39 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.3029.1427728348.31049.help-gnu-emacs@gnu.org>
2015-04-01 23:46 ` translating numpad keys in linux terminal Dan Espen
2015-04-02 10:49 ` Simon Clubley
2015-04-02 23:10   ` Emanuel Berg
2015-04-02 23:45     ` Richard Wordingham
     [not found]     ` <mailman.3207.1428018356.31049.help-gnu-emacs@gnu.org>
2015-04-03  0:48       ` Emanuel Berg
2015-04-03  1:23         ` Emanuel Berg
2015-04-03  1:25         ` Dan Espen
2015-04-03  1:46           ` Emanuel Berg
2015-04-03  2:56             ` Tim Johnson
     [not found]             ` <mailman.3215.1428029828.31049.help-gnu-emacs@gnu.org>
2015-04-03  3:38               ` Dan Espen
2015-04-03 13:35     ` Simon Clubley
2015-04-05 23:39       ` Emanuel Berg
2015-03-30 15:12 Tim Johnson
2015-04-01 10:08 ` Michael Heerdegen
     [not found] ` <mailman.3119.1427882930.31049.help-gnu-emacs@gnu.org>
2015-04-01 14:33   ` Pascal J. Bourguignon
2015-04-01 15:37     ` Tim Johnson
     [not found]     ` <mailman.3140.1427902682.31049.help-gnu-emacs@gnu.org>
2015-04-01 16:28       ` Pascal J. Bourguignon
2015-04-01 18:57         ` Tim Johnson
2015-04-01 23:23     ` Emanuel Berg

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.