unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Escape key as C-g
@ 2014-08-04 20:45 Craig Muth
  2014-08-04 20:56 ` Drew Adams
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Craig Muth @ 2014-08-04 20:45 UTC (permalink / raw)
  To: Emacs-Devel devel

Regarding making the Escape key behave like C-g, this seems to work
fine in GUI emacs, but not terminal emacs:

  (define-key key-translation-map "\e" (kbd "C-g"))

Anyone know of some sort of settings change or other I could make to
get this to work in emacs running in a terminal?

--Craig



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

* RE: Escape key as C-g
  2014-08-04 20:45 Escape key as C-g Craig Muth
@ 2014-08-04 20:56 ` Drew Adams
  2014-08-04 23:31 ` Juri Linkov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Drew Adams @ 2014-08-04 20:56 UTC (permalink / raw)
  To: Craig Muth, Emacs-Devel devel

> Regarding making the Escape key behave like C-g, this seems to work
> fine in GUI emacs, but not terminal emacs:
> 
>   (define-key key-translation-map "\e" (kbd "C-g"))
> 
> Anyone know of some sort of settings change or other I could make to
> get this to work in emacs running in a terminal?

Not an answer to your question, but I suggest that you not do that,
unless you really never need any keys that have ESC as a prefix.

Are you aware that `ESC-ESC-ESC' already does the same thing as `C-g'
in many cases?  (It's really not hard to hit it 3 times instead of 1.)

From the Emacs manual, node `Quitting':

 The sequence `<ESC> <ESC> <ESC>' (`keyboard-escape-quit') can either
 quit or abort.  (We defined it this way because <ESC> means "get out"
 in many PC programs.)  It can cancel a prefix argument, clear a
 selected region, or get out of a Query Replace, like `C-g'.  It can get
 out of the minibuffer or a recursive edit, like `C-]'.  It can also get
 out of splitting the frame into multiple windows, as with `C-x 1'.  One
 thing it cannot do, however, is stop a command that is running.  That's
 because it executes as an ordinary command, and Emacs doesn't notice it
 until it is ready for the next command.

Note the last part.  It is this that I think prevents you from defining
another key to do exactly and always what `C-g' does.  I believe that
`C-g' is hardwired in some places.  (Someone will correct me if I am
mistaken.)



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

* Re: Escape key as C-g
  2014-08-04 20:45 Escape key as C-g Craig Muth
  2014-08-04 20:56 ` Drew Adams
@ 2014-08-04 23:31 ` Juri Linkov
  2014-08-05  0:26   ` Craig Muth
  2014-08-05  1:03 ` Stephen J. Turnbull
  2014-08-05 15:26 ` raman
  3 siblings, 1 reply; 10+ messages in thread
From: Juri Linkov @ 2014-08-04 23:31 UTC (permalink / raw)
  To: Craig Muth; +Cc: Emacs-Devel devel

> Regarding making the Escape key behave like C-g, this seems to work
> fine in GUI emacs, but not terminal emacs:
>
>   (define-key key-translation-map "\e" (kbd "C-g"))
>
> Anyone know of some sort of settings change or other I could make to
> get this to work in emacs running in a terminal?

I recommend a more handy `keyboard-escape-quit' that takes care
of additional contexts for a single ESC in GUI, and leaves ESC
as a prefix key in a terminal:

  (define-key global-map [escape] 'keyboard-escape-quit)



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

* Re: Escape key as C-g
  2014-08-04 23:31 ` Juri Linkov
@ 2014-08-05  0:26   ` Craig Muth
  2014-08-05  7:21     ` Andreas Schwab
  0 siblings, 1 reply; 10+ messages in thread
From: Craig Muth @ 2014-08-05  0:26 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Emacs-Devel devel

I've used that in the past.  It seems to have no effect in the
terminal though (in emacs 22.1.1) :(

--Craig


On Mon, Aug 4, 2014 at 4:31 PM, Juri Linkov <juri@jurta.org> wrote:
>> Regarding making the Escape key behave like C-g, this seems to work
>> fine in GUI emacs, but not terminal emacs:
>>
>>   (define-key key-translation-map "\e" (kbd "C-g"))
>>
>> Anyone know of some sort of settings change or other I could make to
>> get this to work in emacs running in a terminal?
>
> I recommend a more handy `keyboard-escape-quit' that takes care
> of additional contexts for a single ESC in GUI, and leaves ESC
> as a prefix key in a terminal:
>
>   (define-key global-map [escape] 'keyboard-escape-quit)



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

* Escape key as C-g
  2014-08-04 20:45 Escape key as C-g Craig Muth
  2014-08-04 20:56 ` Drew Adams
  2014-08-04 23:31 ` Juri Linkov
@ 2014-08-05  1:03 ` Stephen J. Turnbull
  2014-08-05 15:26 ` raman
  3 siblings, 0 replies; 10+ messages in thread
From: Stephen J. Turnbull @ 2014-08-05  1:03 UTC (permalink / raw)
  To: Craig Muth; +Cc: Emacs-Devel devel

Craig Muth writes:

 > Regarding making the Escape key behave like C-g, this seems to work
 > fine in GUI emacs, but not terminal emacs:
 > 
 >   (define-key key-translation-map "\e" (kbd "C-g"))
 > 
 > Anyone know of some sort of settings change or other I could make to
 > get this to work in emacs running in a terminal?

There aren't any, if your definition of "work" includes "doesn't break
the function keys, the arrow keys, and pretty much everything that
isn't an ASCII character or control function".  (That last is an
exaggeration, but the breakage will indeed be widespread.)

The difference with the GUI is that in a GUI, Emacs has direct (well,
OS-level) access to the keyboard.  In TTY mode, on the other hand,
Emacs does not have access to the keyboard.  It has an input stream of
octets which may be generated by a keyboard, and conventionally all
but a few functions (basically, BEL, TAB, CR, LF, and ESC) are
represented by control sequences, which are introduced by ASCII ESC.

So, ironically, you could have almost any other key (preferably one
represented by a single octet), but ESC is off limits.

If you have a programmable terminal (Linux console, xterm), why not
just have the terminal send C-g when you stroke ESC?



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

* Re: Escape key as C-g
  2014-08-05  0:26   ` Craig Muth
@ 2014-08-05  7:21     ` Andreas Schwab
  0 siblings, 0 replies; 10+ messages in thread
From: Andreas Schwab @ 2014-08-05  7:21 UTC (permalink / raw)
  To: Craig Muth; +Cc: Juri Linkov, Emacs-Devel devel

See the function set-input-mode.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



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

* Re: Escape key as C-g
  2014-08-04 20:45 Escape key as C-g Craig Muth
                   ` (2 preceding siblings ...)
  2014-08-05  1:03 ` Stephen J. Turnbull
@ 2014-08-05 15:26 ` raman
  2014-08-05 21:17   ` Craig Muth
  3 siblings, 1 reply; 10+ messages in thread
From: raman @ 2014-08-05 15:26 UTC (permalink / raw)
  To: Craig Muth; +Cc: Emacs-Devel devel

This would be *an awful* idea -- a lot of long term emacs users --
myself included -- hit ESC  instead of meta since it requires less
chording. 



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

* Re: Escape key as C-g
  2014-08-05 15:26 ` raman
@ 2014-08-05 21:17   ` Craig Muth
  2014-08-05 21:52     ` T.V Raman
  0 siblings, 1 reply; 10+ messages in thread
From: Craig Muth @ 2014-08-05 21:17 UTC (permalink / raw)
  To: raman; +Cc: Emacs-Devel devel

> See the function set-input-mode.

Thanks - I tried a few different values and was sort of able to make
headway, but each thing I try has tradeoffs.  Mostly because of the
stupid way

> This would be *an awful* idea -- a lot of long term emacs users --
> myself included -- hit ESC

I agree with you, re changing ESC's behavior for existing emacs users.
My case is different though.  I'm using emacs as an engine (so to
speak), where users won't even have to know they're in emacs.  I think
there's a ton of runway for using emacs like this - as an
engine/framework for console apps.

--Craig



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

* Re: Escape key as C-g
  2014-08-05 21:17   ` Craig Muth
@ 2014-08-05 21:52     ` T.V Raman
  2014-08-06 19:37       ` Craig Muth
  0 siblings, 1 reply; 10+ messages in thread
From: T.V Raman @ 2014-08-05 21:52 UTC (permalink / raw)
  To: craig.muth; +Cc: emacs-devel, raman

I see --- apologies for the some what harsh note of my original
response in that case. For an instant, I thought you were talking
about changing emacs behavior for all users.

Craig Muth writes:
 > > See the function set-input-mode.
 > 
 > Thanks - I tried a few different values and was sort of able to make
 > headway, but each thing I try has tradeoffs.  Mostly because of the
 > stupid way
 > 
 > > This would be *an awful* idea -- a lot of long term emacs users --
 > > myself included -- hit ESC
 > 
 > I agree with you, re changing ESC's behavior for existing emacs users.
 > My case is different though.  I'm using emacs as an engine (so to
 > speak), where users won't even have to know they're in emacs.  I think
 > there's a ton of runway for using emacs like this - as an
 > engine/framework for console apps.
 > 
 > --Craig



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

* Re: Escape key as C-g
  2014-08-05 21:52     ` T.V Raman
@ 2014-08-06 19:37       ` Craig Muth
  0 siblings, 0 replies; 10+ messages in thread
From: Craig Muth @ 2014-08-06 19:37 UTC (permalink / raw)
  To: T.V Raman; +Cc: Emacs-Devel devel

> apologies for the some what harsh note

No prob! :)

--Craig



On Tue, Aug 5, 2014 at 2:52 PM, T.V Raman <raman@google.com> wrote:
> I see --- apologies for the some what harsh note of my original
> response in that case. For an instant, I thought you were talking
> about changing emacs behavior for all users.
>
> Craig Muth writes:
>  > > See the function set-input-mode.
>  >
>  > Thanks - I tried a few different values and was sort of able to make
>  > headway, but each thing I try has tradeoffs.  Mostly because of the
>  > stupid way
>  >
>  > > This would be *an awful* idea -- a lot of long term emacs users --
>  > > myself included -- hit ESC
>  >
>  > I agree with you, re changing ESC's behavior for existing emacs users.
>  > My case is different though.  I'm using emacs as an engine (so to
>  > speak), where users won't even have to know they're in emacs.  I think
>  > there's a ton of runway for using emacs like this - as an
>  > engine/framework for console apps.
>  >
>  > --Craig



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

end of thread, other threads:[~2014-08-06 19:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-04 20:45 Escape key as C-g Craig Muth
2014-08-04 20:56 ` Drew Adams
2014-08-04 23:31 ` Juri Linkov
2014-08-05  0:26   ` Craig Muth
2014-08-05  7:21     ` Andreas Schwab
2014-08-05  1:03 ` Stephen J. Turnbull
2014-08-05 15:26 ` raman
2014-08-05 21:17   ` Craig Muth
2014-08-05 21:52     ` T.V Raman
2014-08-06 19:37       ` Craig Muth

Code repositories for project(s) associated with this public inbox

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

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).