[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-escape 457386c7bc 043/133: Generalize passthrough
|
From: |
ELPA Syncer |
|
Subject: |
[nongnu] elpa/evil-escape 457386c7bc 043/133: Generalize passthrough |
|
Date: |
Wed, 3 Jan 2024 21:59:51 -0500 (EST) |
branch: elpa/evil-escape
commit 457386c7bc7fd2ffa62369095c05ca19fba2e1ab
Author: syl20bnr <sylvain.benner@gmail.com>
Commit: syl20bnr <sylvain.benner@gmail.com>
Generalize passthrough
Fixes #19
---
evil-escape.el | 70 ++++++++++++++++++++++------------------------------------
1 file changed, 27 insertions(+), 43 deletions(-)
diff --git a/evil-escape.el b/evil-escape.el
index 99d24680ac..0d166d9943 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.14
+;; Version: 2.15
;; Package-Requires: ((emacs "24") (evil "1.0.9"))
;; URL: https://github.com/syl20bnr/evil-escape
@@ -162,27 +162,17 @@ with a key sequence."
(evil-define-motion ,(evil-escape--escape-function-symbol from)
(count)
,@evil-func-props
- (if (memq major-mode evil-escape-excluded-major-modes)
- (progn
- ;; excluded major mode, passthrough
- (when (fboundp ',insert-func)
- (funcall ',insert-func ,(evil-escape--first-key)))
- (when (fboundp ',shadowed-func)
- (evil-escape--execute-shadowed-func ',shadowed-func)))
- (if (called-interactively-p 'interactive)
- ;; called by the user
- (evil-escape--escape ,evil-escape-key-sequence
- ',command
- ',shadowed-func
- ',insert-func
- ',delete-func)
- (cond
- ;; not called by the user, i.e. called by a keyboard macro
- ((fboundp ',insert-func)
- (funcall ',insert-func ,(evil-escape--first-key)))
- ((fboundp ',shadowed-func)
- (evil-escape--setup-emacs-state-passthrough)
- (evil-escape--execute-shadowed-func ',shadowed-func))))))))))
+ (if (and (called-interactively-p 'interactive)
+ (not (memq major-mode evil-escape-excluded-major-modes)))
+ ;; called by the user
+ (evil-escape--escape ,from
+ ',map
+ ,evil-escape-key-sequence
+ ',command
+ ',insert-func
+ ',delete-func)
+ ;; not called by the user (i.e. via a macro)
+ (evil-escape--setup-passthrough ,from ',map)))))))
(defun evil-escape--define-keys ()
"Set the key bindings to escape _everything!_"
@@ -326,17 +316,16 @@ from the `post-command-hook'."
(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-emacs-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)
+(defun evil-escape--setup-passthrough (from map)
+ "Setup a pass through for the next command"
+ (let ((hfunc (intern (format "evil-escape--%s-passthrough" from))))
+ (eval `(defun ,hfunc ()
+ ,(format "Setup an evil-escape passthrough for wrapper %s" from)
+ (evil-escape--passthrough ,from
+ (evil-escape--first-key)
+ ,map
+ ',hfunc)))
+ (add-hook 'post-command-hook hfunc)
(unless (or (and (boundp 'isearch-mode) (symbol-value 'isearch-mode))
(minibufferp))
(setq unread-command-events
@@ -344,13 +333,9 @@ from the `post-command-hook'."
(evil-escape--first-key)))))))
(defun evil-escape--escape
- (keys callback &optional shadowed-func insert-func delete-func)
+ (from map keys callback &optional insert-func delete-func)
"Execute the passed CALLBACK using KEYS. KEYS is a cons cell of 2 characters.
-If the first key insertion shadowed a function then pass the shadowed function
-in SHADOWED-FUNC and it will be executed if the key sequence was not
- successfull.
-
If INSERT-FUNC is not nil then the first key pressed is inserted using the
function INSERT-FUNC.
@@ -364,8 +349,8 @@ DELETE-FUNC when calling CALLBACK. "
(let* ((evt (read-event nil nil evil-escape-delay)))
(cond
((null evt)
- (evil-escape--setup-emacs-state-passthrough)
- (evil-escape--execute-shadowed-func shadowed-func))
+ (unless insert-func
+ (evil-escape--setup-passthrough from map)))
((and (integerp evt)
(char-equal evt skey))
;; remove the f character
@@ -375,10 +360,9 @@ DELETE-FUNC when calling CALLBACK. "
(setq overriding-terminal-local-map nil)
(call-interactively callback))
(t ; otherwise
- (evil-escape--setup-emacs-state-passthrough)
+ (evil-escape--setup-passthrough from map)
(setq unread-command-events
- (append unread-command-events (list evt)))
- (evil-escape--execute-shadowed-func shadowed-func))))))
+ (append unread-command-events (list evt))))))))
(provide 'evil-escape)
- [nongnu] elpa/evil-escape da5498d25e 035/133: Correctly restore evil-lisp-state shadowed function by evil-escape, (continued)
- [nongnu] elpa/evil-escape da5498d25e 035/133: Correctly restore evil-lisp-state shadowed function by evil-escape, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape cf3e18673d 051/133: Undefine mapping on first key when evil-escape is disabled, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape cbfc43840f 063/133: Ensure that map is defined when undefining keys, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape b8c9b4631d 049/133: Add support for helm-ag-edit, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape b205051996 056/133: More stable passthrough, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape afa9c9c321 067/133: Fixes #37 Capital r deletes a char inappropriately, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 67843e9dd4 041/133: Fix recursive `f` input during isearch in certain buffers, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape e78ffcdbeb 036/133: Explicitly disable any running transient map, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape e556c7a6b6 057/133: Fix line highlight flicker on escape, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 05d9e5fc80 052/133: Don't break deft-mode, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 457386c7bc 043/133: Generalize passthrough,
ELPA Syncer <=
- [nongnu] elpa/evil-escape 6c6379c19b 065/133: Update README for 3.0, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape bc054dbe1e 059/133: Add documentation to generated wrapper functions, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 1488a2c9c3 037/133: When replaying macro, pass shadow func, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape f8fe5c98d2 083/133: Add `evil-escape-inhibit-functions`, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape b0d033794c 089/133: Fix typo in docstring of evil-escape-mode, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 1c4b0efc06 100/133: Allow evil-escape in normal state if it makes sense, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape bb6f6c254a 069/133: Fix isearch support, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape bf41c9e797 068/133: Fix typo in docstring (thanks to person808), ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 6790f87d87 081/133: Fix unexpected escape when unordered-key-sequence is non nil, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 5c5b1a655c 076/133: Add new defcustom evil-escape-enable-only-for-major-modes, ELPA Syncer, 2024/01/03