all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Barry OReilly <gundaetiapo@gmail.com>
To: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: How to get in progress Key Sequence from Elisp
Date: Sun, 2 Dec 2012 15:09:36 -0500	[thread overview]
Message-ID: <CAFM41H1jVRufkFhz0HX98AVz0-iYpuY9TrYx8H7bhV1yuV5X6w@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1394 bytes --]

When I'm in the middle of inputting a Key Sequence, how may I get a data
structure with the Key Sequence entered thus far from Elisp?

More details: I create Key Translations that are contingent on the Evil
(Vim emulation) state.  If in insert state, it's the idenity translation:

  ;; -*- lexical-binding: t -*-
  (defun make-conditional-key-translation (key-from key-to translate-keys-p)
    "Make a Key Translation such that if the translate-keys-p function
returns true,
  key-from translates to key-to, else key-from translates to itself.
translate-keys-p
  takes no args. "
    (define-key key-translation-map key-from
                (lambda (prompt)
                        (if (funcall translate-keys-p) key-to key-from))))
  (defun my-translate-keys-p ()
    "Returns whether conditional key translations should be active.  See
make-conditional-key-translation function. "
    (or (evil-motion-state-p) (evil-normal-state-p) (evil-visual-state-p)))
  (make-conditional-key-translation (kbd "g") (kbd "C-x")
'my-translate-keys-p)

This works well, but one inconvenience is that for bindings like this:

  (define-key evil-motion-state-map "sg" 'my-func)

"sg" gets translated into "s C-x".  If I have my-translate-keys-p return
nil if not starting a Key Sequence, I will get the behavior I seek.  I can
do this if I can get the Key Sequence as the user has been entered at that
time.

[-- Attachment #2: Type: text/html, Size: 1567 bytes --]

             reply	other threads:[~2012-12-02 20:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-02 20:09 Barry OReilly [this message]
2012-12-02 21:15 ` How to get in progress Key Sequence from Elisp Drew Adams
2012-12-03 14:37   ` Barry OReilly

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFM41H1jVRufkFhz0HX98AVz0-iYpuY9TrYx8H7bhV1yuV5X6w@mail.gmail.com \
    --to=gundaetiapo@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.