[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-escape 65756d4a8d 077/133: Make it possible to assign
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-escape 65756d4a8d 077/133: Make it possible to assign a key binding to evil-escape |
Date: |
Wed, 3 Jan 2024 21:59:54 -0500 (EST) |
branch: elpa/evil-escape
commit 65756d4a8d89b9d9c60ee4236222cb5cf803c9cb
Author: syl20bnr <sylvain.benner@gmail.com>
Commit: syl20bnr <sylvain.benner@gmail.com>
Make it possible to assign a key binding to evil-escape
Fixes #29
---
README.md | 17 +++++++++++++----
evil-escape.el | 49 +++++++++++++++++++++++++++----------------------
2 files changed, 40 insertions(+), 26 deletions(-)
diff --git a/README.md b/README.md
index 75a5011b58..d2b97bcff8 100644
--- a/README.md
+++ b/README.md
@@ -13,6 +13,7 @@
- [Delay between keys](#delay-between-keys)
- [Excluding a major mode](#excluding-a-major-mode)
- [Enable only for a list of major
modes](#enable-only-for-a-list-of-major-modes)
+ - [Assign a key binding directly](#assign-a-key-binding-directly)
<!-- markdown-toc end -->
@@ -92,9 +93,17 @@ A major mode can be excluded by adding it to the list
### Enable only for a list of major modes
-It is also possible to provide an inclusive list of major modes
-with the variable `evil-escape-enable-only-for-major-modes`. When this list
-non-nil then evil-escape is enabled only for the major-modes contained in the
-list.
+An inclusive list of major modes can defined with the variable
+`evil-escape-enable-only-for-major-modes`. When this list is non-nil
+then evil-escape is enabled only for the major-modes in the list.
+
+### Assign a key binding directly
+
+It is possible to bind `evil-escape' function directly`, for
+instance to execute evil-escape with <kbd>C-c C-g</kbd>:
+
+```elisp
+(global-set-key (kbd "C-c C-g") 'evil-escape)
+```
[MELPA]: http://melpa.org/
diff --git a/evil-escape.el b/evil-escape.el
index 4d6a88903e..a9c8a25718 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: 3.04
+;; Version: 3.05
;; Package-Requires: ((emacs "24") (evil "1.0.9"))
;; URL: https://github.com/syl20bnr/evil-escape
@@ -58,10 +58,15 @@
;; A major mode can be excluded by adding it to the list
;; `evil-escape-excluded-major-modes'.
-;; It is also possible to provide an inclusive list of major modes
-;; with the variable `evil-escape-enable-only-for-major-modes'. When this list
-;; non-nil then evil-escape is enabled only for the major-modes contained in
the
-;; list.
+;; An inclusive list of major modes can defined with the variable
+;; `evil-escape-enable-only-for-major-modes'. When this list is
+;; non-nil then evil-escape is enabled only for the major-modes
+;; in the list.
+
+;; It is possible to bind `evil-escape' function directly, for
+;; instance to execute evil-escape with `C-c C-g':
+
+;; (global-set-key (kbd "C-c C-g") 'evil-escape)
;; More information in the readme of the repository:
;; https://github.com/syl20bnr/evil-escape
@@ -106,6 +111,21 @@ with a key sequence."
(add-hook 'pre-command-hook 'evil-escape-pre-command-hook)
(remove-hook 'pre-command-hook 'evil-escape-pre-command-hook)))
+(defun evil-escape ()
+ "Escape from everything... well almost everything."
+ (interactive)
+ (pcase evil-state
+ (`normal (evil-escape--escape-normal-state))
+ (`motion (evil-escape--escape-motion-state))
+ (`insert (evil-normal-state))
+ (`emacs (evil-escape--escape-emacs-state))
+ (`evilified (evil-escape--escape-emacs-state))
+ (`visual (evil-exit-visual-state))
+ (`replace (evil-normal-state))
+ (`lisp (evil-normal-state))
+ (`iedit (evil-iedit-state/quit-iedit-mode))
+ (`iedit-insert (evil-iedit-state/quit-iedit-mode))))
+
(defun evil-escape-pre-command-hook ()
"evil-escape pre-command hook."
(when (evil-escape-p)
@@ -117,14 +137,14 @@ with a key sequence."
(set-buffer-modified-p modified)
(cond
((and (integerp evt) (char-equal evt skey))
- (evil-escape--escape)
+ (evil-escape)
(setq this-command 'ignore))
((null evt))
(t (setq unread-command-events
(append unread-command-events (list evt))))))))
(defun evil-escape-p ()
- "Return non-nil if evil-escape should run."
+ "Return non-nil if evil-escape can run."
(and (or (window-minibuffer-p)
(bound-and-true-p isearch-mode)
(and (fboundp 'helm-alive-p) (helm-alive-p))
@@ -134,21 +154,6 @@ with a key sequence."
(memq major-mode evil-escape-enable-only-for-major-modes))
(equal (this-command-keys) (evil-escape--first-key))))
-(defun evil-escape--escape ()
- "Escape from everything... well almost everything."
- (pcase evil-state
- (`normal (evil-escape--escape-normal-state))
- (`motion (evil-escape--escape-motion-state))
- (`insert (evil-normal-state))
- (`emacs (evil-escape--escape-emacs-state))
- (`evilified (evil-escape--escape-emacs-state))
- (`visual (evil-exit-visual-state))
- (`replace (evil-normal-state))
- (`lisp (evil-normal-state))
- (`iedit (evil-iedit-state/quit-iedit-mode))
- (`iedit-insert (evil-iedit-state/quit-iedit-mode))
- (_ (evil-escape--escape-normal-state))))
-
(defun evil-escape--escape-normal-state ()
"Escape from normal state."
(cond
- [nongnu] elpa/evil-escape 6a9d60c733 087/133: Update README TOC, (continued)
- [nongnu] elpa/evil-escape 6a9d60c733 087/133: Update README TOC, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape fccebfe601 098/133: Add support for emoji-cheat-sheet-plus-buffer, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 09e0622e16 109/133: Add support for image-mode, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape af1a6eb532 110/133: Fix display flickering when using 'global-hl-line-mode', ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 9328f25199 122/133: Fix docstrings, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 8f5b4ccc81 094/133: Revert insert/delete functions, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 9257ed0427 130/133: Don't redisplay and font locking while doing evil-escape, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 80029c6892 108/133: Add support for evil-magit, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 04b6e9c0cf 126/133: Depend on latest Evil release, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 1c8fc8b46b 129/133: Reindent code that font-locked highlighted as problematic, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 65756d4a8d 077/133: Make it possible to assign a key binding to evil-escape,
ELPA Syncer <=
- [nongnu] elpa/evil-escape 8f8b58db5e 121/133: Fix compiler warnings, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape bdb1e69971 133/133: Correct treemacs integration (#5), ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape fd1f59d4ab 131/133: Add non-matching events to unread-post-input-method-events, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape a04305aa74 028/133: typos in comments, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 7e0b99467f 061/133: Use `self-insert-command` instead of `insert`, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 5a8704e6a6 066/133: Add missing docstring, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 509e39d3a0 088/133: Declare function for compiler, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 47d2031f62 046/133: Fix `f is undefined`, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 8012e3d21f 054/133: Correctly escape in evil replace state, ELPA Syncer, 2024/01/03
- [nongnu] elpa/evil-escape 8af706a87c 013/133: Fixes #4 evil-escape confuse evil's minibuffer echo system, ELPA Syncer, 2024/01/03