[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-escape 9dd9cccf32 027/133: Add pass through functiona
|
From: |
ELPA Syncer |
|
Subject: |
[nongnu] elpa/evil-escape 9dd9cccf32 027/133: Add pass through functionality |
|
Date: |
Wed, 3 Jan 2024 21:59:50 -0500 (EST) |
branch: elpa/evil-escape
commit 9dd9cccf3210d6215144ffae13b50c88026729fd
Author: syl20bnr <sylvain.benner@gmail.com>
Commit: syl20bnr <sylvain.benner@gmail.com>
Add pass through functionality
Fixes the regression buffers in emacs state
---
evil-escape.el | 43 +++++++++++++++++++++++++++++++++++++------
1 file changed, 37 insertions(+), 6 deletions(-)
diff --git a/evil-escape.el b/evil-escape.el
index 2c0f7bb105..84e096e63e 100644
--- a/evil-escape.el
+++ b/evil-escape.el
@@ -5,7 +5,7 @@
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; Keywords: convenience editing evil
;; Created: 22 Oct 2014
-;; Version: 2.02
+;; Version: 2.03
;; Package-Requires: ((emacs "24") (evil "1.0.9"))
;; URL: https://github.com/syl20bnr/evil-escape
@@ -112,6 +112,10 @@ with a key sequence."
(fkeystr (char-to-string first-key)))
fkeystr)))
+(defun evil-escape--escape-function-symbol (from)
+ "Return the function symbol for the passed FROM string."
+ (intern (format "evil-escape-%s" from)))
+
(defmacro evil-escape-define-escape (from map command &rest properties)
"Define a function to escape from FROM in MAP keymap by executing COMMAND.
@@ -129,7 +133,7 @@ with a key sequence."
(delete-func (plist-get properties :delete-func)))
`(progn
(define-key ,map ,(evil-escape--first-key)
- (evil-define-motion ,(intern (format "evil-escape-%s" from))
+ (evil-define-motion ,(evil-escape--escape-function-symbol from)
(count)
;; called by the user
(if (called-interactively-p 'interactive)
@@ -156,7 +160,7 @@ with a key sequence."
(cond ((string-match "magit" (symbol-name major-mode))
(evil-escape--escape-with-q))
((eq 'paradox-menu-mode major-mode)
- (paradox-quit-and-close))
+ (evil-escape--escape-with-q))
((eq 'gist-list-menu-mode major-mode)
(quit-window))
(t evil-normal-state)))))
@@ -240,7 +244,7 @@ with a key sequence."
"Send `q' key press event to exit from a buffer."
(setq unread-command-events (listify-key-sequence "q")))
-(defun evil-escape--execute-shadow-func (func)
+(defun evil-escape--execute-shadowed-func (func)
"Execute the passed FUNC if the context allows it."
(unless (or (null func)
(eq 'insert evil-state)
@@ -248,6 +252,31 @@ with a key sequence."
(minibufferp))
(call-interactively func)))
+(defun evil-escape--passthrough (from key map hfunc)
+ "Allow the next command KEY to pass through MAP.
+Once the command KEY passed through MAP the function HFUNC is removed
+from the `post-command-hook'."
+ (if (lookup-key map key)
+ (define-key map key nil)
+ (let ((escape-func (evil-escape--escape-function-symbol from)))
+ (define-key map key escape-func)
+ (remove-hook 'post-command-hook hfunc))))
+
+(defun evil-escape--emacs-state-passthrough ()
+ "Allow next command KEY to pass through `evil-emcs-state-map'"
+ (evil-escape--passthrough "emacs-state"
+ (evil-escape--first-key)
+ evil-emacs-state-map
+ 'evil-escape--emacs-state-passthrough))
+
+(defun evil-escape--setup-emacs-state-passthrough ()
+ "Setup a pass through for emacs state map"
+ (when (eq 'emacs evil-state)
+ (add-hook 'post-command-hook 'evil-escape--emacs-state-passthrough)
+ (setq unread-command-events
+ (append unread-command-events (listify-key-sequence
+ (evil-escape--first-key))))))
+
(defun evil-escape--escape
(keys callback &optional shadowed-func insert-func delete-func)
"Execute the passed CALLBACK using KEYS. KEYS is a cons cell of 2 characters.
@@ -269,7 +298,8 @@ DELETE-FUNC when calling CALLBACK. "
(let* ((evt (read-event nil nil evil-escape-delay)))
(cond
((null evt)
- (evil-escape--execute-shadow-func shadowed-func))
+ (evil-escape--setup-emacs-state-passthrough)
+ (evil-escape--execute-shadowed-func shadowed-func))
((and (integerp evt)
(char-equal evt skey))
;; remove the f character
@@ -277,9 +307,10 @@ DELETE-FUNC when calling CALLBACK. "
(set-buffer-modified-p modified)
(call-interactively callback))
(t ; otherwise
+ (evil-escape--setup-emacs-state-passthrough)
(setq unread-command-events
(append unread-command-events (list evt)))
- (evil-escape--execute-shadow-func shadowed-func))))))
+ (evil-escape--execute-shadowed-func shadowed-func))))))
(provide 'evil-escape)
- [nongnu] branch elpa/evil-escape created (now bdb1e69971), ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape a8fb352edd 009/133: Add melpa badge to readme, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape fe0c3318d8 005/133: Remove duplicate var declaration, and add trailing comment line, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape b09500cc4e 002/133: Update readme, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 8af69d73f8 020/133: Fixes #10 deleting with `df)` does not include `)`, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 9dd9cccf32 027/133: Add pass through functionality,
ELPA Syncer <=
- [nongnu] elpa/evil-escape 0da35398ed 058/133: Fix support for operators, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 0346740ff1 031/133: Correctly handle the evil function properties, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 37c227e4df 018/133: Version 1.5.1, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 05709479ed 010/133: Add badge for melpa stable, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 1fe3759ab4 014/133: Fix 'commandp is nil` when search for `f` in isearch, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 5da641b6e6 019/133: Quit ert buffers, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape fe21e8f256 004/133: Fix error in readme, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 07c6c1b4da 007/133: Fixes #2 Symbol's value as variable is void: isearch-abort, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 1d09324c72 011/133: Fix byte-compilation and defcustom, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 7aa2bb2155 024/133: Suppress key-chord dependency (v2.0), ELPA Syncer, 2024/01/03