From 5c5b1a655cf8600af9fd8dea8f60763474c82b45 Mon Sep 17 00:00:00 2001 From: syl20bnr Date: Wed, 2 Sep 2015 16:42:49 -0400 Subject: [PATCH] Add new defcustom evil-escape-enable-only-for-major-modes Fixes #36 --- README.md | 11 ++++++++++- evil-escape.el | 16 ++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9808d7c..75a5011 100644 --- a/README.md +++ b/README.md @@ -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) - + **Table of Contents** - [evil-escape](#evil-escape) @@ -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) @@ -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/ diff --git a/evil-escape.el b/evil-escape.el index 442a4b6..4d6a889 100644 --- a/evil-escape.el +++ b/evil-escape.el @@ -5,7 +5,7 @@ ;; Author: Sylvain Benner ;; 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 @@ -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 @@ -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 @@ -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 ()