Skip to content

Add key-seq-define-evil for evil-mode state-aware key sequences - #6

Open
zzeitt wants to merge 2 commits into
vlevit:masterfrom
zzeitt:master
Open

Add key-seq-define-evil for evil-mode state-aware key sequences#6
zzeitt wants to merge 2 commits into
vlevit:masterfrom
zzeitt:master

Conversation

@zzeitt

@zzeitt zzeitt commented Aug 26, 2026

Copy link
Copy Markdown

Add key-seq-define-evil, a state-aware variant of key-seq-define for evil-mode.

It defines an ordered two-key sequence in a specific evil state's keymap, e.g.:

(key-seq-define-evil 'normal org-mode-map ";n" 'org-capture)

Unlike key-seq-define, the binding goes through evil's evil-define-key*, so the chord is only active in the given state(s).

Changes:

  • Add evil as a package dependency and (require 'evil).
  • Add key-seq-define-evil (state keymap keys command).
  • Enable lexical-binding and use the evil-define-key* function form instead of the evil-define-key macro. The macro defers via after-load-functions when the keymap argument is lexically scoped (boundp can't see lexical bindings), so bindings were never applied; the function form binds immediately.

ztDell added 2 commits September 18, 2024 15:57
Enable lexical-binding and switch key-seq-define-evil from the
`evil-define-key` macro to the `evil-define-key*` function form.

`evil-define-key` expands to a `boundp` check on the keymap argument;
with lexical-binding a lexically scoped parameter is invisible to
`boundp`, so the binding was deferred to `after-load-functions` and
never applied. `evil-define-key*` binds immediately.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant