Skip to content

Commit

Permalink
Add new defcustom evil-escape-enable-only-for-major-modes
Browse files Browse the repository at this point in the history
Fixes #36
  • Loading branch information
syl20bnr committed Sep 2, 2015
1 parent 9164cda commit 5c5b1a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![MELPA](http://melpa.org/packages/evil-escape-badge.svg)](http://melpa.org/#/evil-escape)
[![MELPA Stable](http://stable.melpa.org/packages/evil-escape-badge.svg)](http://stable.melpa.org/#/evil-escape)

<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc/generate-toc again -->
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-generate-toc again -->
**Table of Contents**

- [evil-escape](#evil-escape)
Expand All @@ -11,6 +11,8 @@
- [Customization](#customization)
- [Key sequence](#key-sequence)
- [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)

<!-- markdown-toc end -->

Expand Down Expand Up @@ -88,4 +90,11 @@ composed with the two same characters it is recommended to set the delay to
A major mode can be excluded by adding it to the list
`evil-escape-excluded-major-modes`.

### 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.

[MELPA]: http://melpa.org/
16 changes: 14 additions & 2 deletions evil-escape.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
;; Author: Sylvain Benner <[email protected]>
;; Keywords: convenience editing evil
;; Created: 22 Oct 2014
;; Version: 3.03
;; Version: 3.04
;; Package-Requires: ((emacs "24") (evil "1.0.9"))
;; URL: https://github.com/syl20bnr/evil-escape

Expand Down Expand Up @@ -58,6 +58,11 @@
;; 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.

;; More information in the readme of the repository:
;; https://github.com/syl20bnr/evil-escape

Expand All @@ -80,11 +85,16 @@
:type 'number
:group 'evil-escape)

(defcustom evil-escape-excluded-major-modes '()
(defcustom evil-escape-excluded-major-modes nil
"Excluded major modes where escape sequences has no effect."
:type 'sexp
:group 'evil-escape)

(defcustom evil-escape-enable-only-for-major-modes nil
"List of major modes where evil-escape is enabled."
:type 'sexp
:group 'evil-escape)

;;;###autoload
(define-minor-mode evil-escape-mode
"Buffer-local minor mode to escape insert state and everythin else
Expand Down Expand Up @@ -120,6 +130,8 @@ with a key sequence."
(and (fboundp 'helm-alive-p) (helm-alive-p))
(not (eq evil-state 'normal)))
(not (memq major-mode evil-escape-excluded-major-modes))
(or (not evil-escape-enable-only-for-major-modes)
(memq major-mode evil-escape-enable-only-for-major-modes))
(equal (this-command-keys) (evil-escape--first-key))))

(defun evil-escape--escape ()
Expand Down

0 comments on commit 5c5b1a6

Please sign in to comment.