unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Mapping ESC to Cancel in terminal emacs
@ 2015-02-01 22:39 Craig Muth
  2015-02-02  8:33 ` David Kastrup
  2015-02-02 17:07 ` Stefan Monnier
  0 siblings, 2 replies; 3+ messages in thread
From: Craig Muth @ 2015-02-01 22:39 UTC (permalink / raw)
  To: Emacs-Devel devel

I added some elisp to the following emacswiki page that gets somewhat
close to making ESC behave like C-g.  It uses a small cua-mode-like
delay to distinguish using ESC as a prefix key from an ESC to cancel:

http://www.emacswiki.org/emacs/CancelingInEmacs

Anyone know of a better way to put something like "\eb" back into
unread-command-events, so it replicate the state before the event was
read?  Here's a relevant blurb I added at the bottom of the emacswiki
page:

-------------------------------------------------------------------
One drawback, though, is that it messes up C-h C-k, making it think
the key you typed was only escape. Does anyone know of a better way of
putting the escape and the subsequent key back into effect than the
following? Maybe a way that makes it not treat the escape separately?

      (setq unread-command-events (cons event unread-command-events))
 ; Puts subsequent key back into effect
      (setq unread-command-events (cons 27 unread-command-events))   ;
Puts escape back into effect
-------------------------------------------------------------------

Caveat: I do fully realize that making escape work like C-g in a
general way is a bad idea. I have in mind the exceptional case where
emacs is used as an engine, or when you're temporarily remapping
escape while pairing with a user who isn't yet familiar with emacs.

Thanks!
--Craig



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

* Re: Mapping ESC to Cancel in terminal emacs
  2015-02-01 22:39 Mapping ESC to Cancel in terminal emacs Craig Muth
@ 2015-02-02  8:33 ` David Kastrup
  2015-02-02 17:07 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: David Kastrup @ 2015-02-02  8:33 UTC (permalink / raw)
  To: Craig Muth; +Cc: Emacs-Devel devel

Craig Muth <craig.muth@gmail.com> writes:

> I added some elisp to the following emacswiki page that gets somewhat
> close to making ESC behave like C-g.

You are aware that ESC ESC ESC aborts pretty much anywhere that C-g
aborts, with the exception of the terminal layer (interrupting running
Elisp) which you probably cannot sensibly tamper with anyway?

-- 
David Kastrup



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

* Re: Mapping ESC to Cancel in terminal emacs
  2015-02-01 22:39 Mapping ESC to Cancel in terminal emacs Craig Muth
  2015-02-02  8:33 ` David Kastrup
@ 2015-02-02 17:07 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2015-02-02 17:07 UTC (permalink / raw)
  To: Craig Muth; +Cc: Emacs-Devel devel

> Anyone know of a better way to put something like "\eb" back into
> unread-command-events, so it replicate the state before the event was
> read?

Before trying to answer such a question, you should ask yourself whether
there's a way to get what you want *without* needing to put things back
on unread-command-events (i.e. so the event is only consumed when you
need to consume it).

I think if you use key remapping, such as input-decode-map, you can get
what you want.  Look for that variable in lisp/emulation/viper.el to see
how Viper handles VI's escape key, for example.


        Stefan



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

end of thread, other threads:[~2015-02-02 17:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-01 22:39 Mapping ESC to Cancel in terminal emacs Craig Muth
2015-02-02  8:33 ` David Kastrup
2015-02-02 17:07 ` Stefan Monnier

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