all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Sticky escape key
@ 2015-09-18 13:05 Surya Kiran Gullapalli
  2015-09-18 22:54 ` Emanuel Berg
  2015-09-18 22:59 ` Bob Proulx
  0 siblings, 2 replies; 6+ messages in thread
From: Surya Kiran Gullapalli @ 2015-09-18 13:05 UTC (permalink / raw)
  To: help-gnu-emacs

I started using kinesis keyboard and mapped my left control key to escape
(near left thumb) and escape is the hyper key for me.

I created some keybindings with the escape key. Everything is working fine.
But the escape key is behaving as if it is a sticky key. I want it to
behave like a non-sticky key like ctrl or shift or alt.

Is there a way to do it in emacs ? (Kinesis doesn't seem to have that
option for escape key).

Surya


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

* Re: Sticky escape key
  2015-09-18 13:05 Sticky escape key Surya Kiran Gullapalli
@ 2015-09-18 22:54 ` Emanuel Berg
  2015-09-18 22:59 ` Bob Proulx
  1 sibling, 0 replies; 6+ messages in thread
From: Emanuel Berg @ 2015-09-18 22:54 UTC (permalink / raw)
  To: help-gnu-emacs

Surya Kiran Gullapalli
<suryakiran.gullapalli@gmail.com> writes:

> I ... mapped my left control key to escape (near
> left thumb) ... But the escape key is behaving as if
> it is a sticky key

Did you, outside of Emacs, map the left control key so
that it is now the Escape key? In that case what you
experience is expected.

What do you want, exactly? Do you want a new shortcut
key, at the position of the left control key, so you
can do new shortcuts with this key as the prefix, i.e,
in addition to C-f, M-f, etc. you want to do for
example $-f, if we pretend the new key is called $?

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




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

* Re: Sticky escape key
  2015-09-18 13:05 Sticky escape key Surya Kiran Gullapalli
  2015-09-18 22:54 ` Emanuel Berg
@ 2015-09-18 22:59 ` Bob Proulx
  2015-09-19  3:09   ` Emanuel Berg
  1 sibling, 1 reply; 6+ messages in thread
From: Bob Proulx @ 2015-09-18 22:59 UTC (permalink / raw)
  To: Surya Kiran Gullapalli; +Cc: help-gnu-emacs

Surya Kiran Gullapalli wrote:
> I started using kinesis keyboard and mapped my left control key to escape
> (near left thumb) and escape is the hyper key for me.

You mapped it how?  What did you do?  Did you do it with the keyboard?
With the terminal?  With X and xmodmap?  With setxkbmap?  With a
checkbox from your desktop manager dialog box?  Some other method?  I
am thinking very hard but I haven't been eating enough fish and my
telepathy is low at the moment.  Or perhaps you aren't sending your
thoughts hard enough?

> I created some keybindings with the escape key. Everything is working fine.

Do you mean M- somethings in emacs?  Something like this?  (This is
just an example of creating a key binding using the escape key.)

  (global-set-key "\M-r" 'replace-regexp) ; orig 'move-to-window-line

Or something different?

> But the escape key is behaving as if it is a sticky key. I want it to
> behave like a non-sticky key like ctrl or shift or alt.

For me as a Unix/GNU/Linux user the xmodmap way works well.  Here is
my .xmodmap file that does this.

  ! Capslock becomes Control_L
  ! Control_L becomes Escape
  clear Lock
  clear Control
  keycode 37 = Escape NoSymbol Escape
  keycode 66 = Control_L NoSymbol Control_L
  add Control = Control_L Control_R

But note that this is a very old-school way of doing things.  It
applies to people like me who are using X windows with a window
manager such as FVWM or similar.  It won't apply to people running
heavy desktop managers such as GNOME nor MS-Windows nor probably other
environments.

I mostly provide this to show that many of us do this routinely and it
works well.

> Is there a way to do it in emacs ? (Kinesis doesn't seem to have that
> option for escape key).

Yes.  No.  Maybe.  It can't be done for emacs running in a terminal
because the terminal needs to know the difference between escape and
control.  Escape actually sends an escape whereas control modifies the
character modified the same way that shift and meta/alt do.  But
graphical emacs has access to the entire keyboard input method.  It
can be done in graphical emacs.  But I think that is bad because then
it won't be applied uniformly to it being run in a terminal.  And it
won't be applied to other applications such as a bash command line
shell.  Therefore it is much better to remap the keyboard instead.

Bob



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

* Re: Sticky escape key
  2015-09-18 22:59 ` Bob Proulx
@ 2015-09-19  3:09   ` Emanuel Berg
  2015-09-20 23:37     ` Bob Proulx
  0 siblings, 1 reply; 6+ messages in thread
From: Emanuel Berg @ 2015-09-19  3:09 UTC (permalink / raw)
  To: help-gnu-emacs

Bob Proulx <bob@proulx.com> writes:

> You mapped it how? What did you do? Did you do it
> with the keyboard? With the terminal? With X and
> xmodmap? With setxkbmap? With a checkbox from your
> desktop manager dialog box? Some other method?

It seems to me from reading the OP's post that he
succeeded remapping the left control key to the escape
key, then he setup some shortcuts which uses the
escape key, and those also work, only the key
"sticks" - which is exactly what the escape key does!

But: Escape already does what meta does only meta
doesn't stick. When the OP sets up shortcuts with
escape he might as well use meta! (Or it is actually
better because it is what you expect.) Because:

    (global-set-key (kbd "ESC r") (lambda () (interactive) (message "ESC-r is M-r")))

Try this with escape and meta!

So the OP should rebind the left control key to meta
and that will do what he wants.

> Yes. No. Maybe. It can't be done for emacs running in
> a terminal because the terminal needs to know the
> difference between escape and control.

In the ttys, you can rebind escape with the familiar
method [1]. The escape key has keycode 1. You can then
do whatever with that key. Only it still "sticks"!
I don't know if Emacs or the terminal does that, but
I'll find out.

[1] http://user.it.uu.se/~embe8573/tty-emacs-keys.txt

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




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

* Re: Sticky escape key
  2015-09-19  3:09   ` Emanuel Berg
@ 2015-09-20 23:37     ` Bob Proulx
  2015-09-21  0:06       ` Emanuel Berg
  0 siblings, 1 reply; 6+ messages in thread
From: Bob Proulx @ 2015-09-20 23:37 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg wrote:
> Bob Proulx writes:
> > You mapped it how? What did you do? Did you do it
> > with the keyboard? With the terminal? With X and
> > xmodmap? With setxkbmap? With a checkbox from your
> > desktop manager dialog box? Some other method?
> 
> It seems to me from reading the OP's post that he
> succeeded remapping the left control key to the escape
> key, then he setup some shortcuts which uses the
> escape key, and those also work, only the key
> "sticks" - which is exactly what the escape key does!

Ah...  So you are thinking that the original poster is trying to hold
down escape along with other keys in a chord the same way that control
and shift are used?  Basically conflating escape with meta?  Hmm...  I
guess that is possible and I had not considered that.

> But: Escape already does what meta does only meta
> doesn't stick. When the OP sets up shortcuts with
> escape he might as well use meta! (Or it is actually
> better because it is what you expect.) Because:

Yes and no.  I mean yes meta can be used when meta can be used.  But
often an actual escape is needed such as C-x ESC ESC
repeat-complex-command and so forth.  That requires a real escape and
not using escape to meta-ize the next character.

>     (global-set-key (kbd "ESC r") (lambda () (interactive) (message "ESC-r is M-r")))
> 
> Try this with escape and meta!
>
> So the OP should rebind the left control key to meta
> and that will do what he wants.

You may be right about that.  But maybe not too.  There is already the
left alt that is usually bound to meta.  And a lot of people bind
escape to the control key.  It is hard to say what is actually desired
there.  Plus there is the problem of running in a text terminal.
(Personally I bind Control_L to CAPLOCK and Escape to Control_L in
xmodmap so it is global outside of emacs for everything and am very
happy.)

> > Yes. No. Maybe. It can't be done for emacs running in
> > a terminal because the terminal needs to know the
> > difference between escape and control.
> 
> In the ttys, you can rebind escape with the familiar
> method [1]. The escape key has keycode 1. You can then
> do whatever with that key. Only it still "sticks"!
> I don't know if Emacs or the terminal does that, but
> I'll find out.
> 
> [1] http://user.it.uu.se/~embe8573/tty-emacs-keys.txt

Here we may be differing on a definition of "sticks".  To me that
would be like capslock.  When I turn on capslock it sticks and all
characters typed after that point are in caps.  To me that is a sticky
key.  And in the modern age with sticky shift on such things as touch
screens then it is also a capslock and is called sticky.  But escape
is only like a sticky meta key for exactly one character.  As you know
escape causes the next character to be interpreted as a meta
character.  But after that folllowing characters are not meta
characters.  I wouldn't describe that as sticky.

Here you are talking about the Linux tty console which operates quite
differently from a graphics terminal emulator running under X such as
most people use these days.  Under the Linux console I have had the
following in my /etc/rc.local for quite a while to remap my keys.

  dumpkeys --full-table | sed -n '/^keycode  *29/p;/^keycode  *58/p' | sed '/^keycode  *29/s/Control/Escape/g;/^keycode  *58/s/CtrlL_Lock/Control/g' | loadkeys -q

That dumps the full table.  Then the sed -n only prints out the two
lines for keycodes 29 Control and 58 CtrlL_Lock.  Then it changes the
keycode 29 Control to keycode 29 Escape and keycode 58 CtrlL_Lock to
keycode 58 Control.  This way even on the Linux console I get the old
style keyboard arrangement such as the HP-UX HIL keyboard that I
liked.  This doesn't do anything with Alt and Meta because Alt is
already Meta on the Linux console.  But it does set capslock to be
control and the left control to be escape as I like.

Hopefully the original poster will respond and let us know whether
they are wanting capslock to be a meta key or an escape key.

Bob



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

* Re: Sticky escape key
  2015-09-20 23:37     ` Bob Proulx
@ 2015-09-21  0:06       ` Emanuel Berg
  0 siblings, 0 replies; 6+ messages in thread
From: Emanuel Berg @ 2015-09-21  0:06 UTC (permalink / raw)
  To: help-gnu-emacs

Bob Proulx <bob@proulx.com> writes:

> As you know escape causes the next character [...]
> But after that folllowing characters are not [...]
> I wouldn't describe that as sticky.

OK - that was what I meant anyway, it affects what
comes next and you don't have to hold it down for this
to happen.

In a Linux tty Emacs (and maybe in general as well),
even if I rebind the escape key (keycode 1) to
something else, this behavior "sticks" around, so when
I hit the key it affects the next input regardless
what it first does.

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




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

end of thread, other threads:[~2015-09-21  0:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-18 13:05 Sticky escape key Surya Kiran Gullapalli
2015-09-18 22:54 ` Emanuel Berg
2015-09-18 22:59 ` Bob Proulx
2015-09-19  3:09   ` Emanuel Berg
2015-09-20 23:37     ` Bob Proulx
2015-09-21  0:06       ` 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.