branch: elpa/evil-nerd-commenter
commit 275c95c89cc09c7096bd6fd0deabd49f29634f5d
Merge: 34d411715e 65bb73ec49
Author: Chen Bin <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #88 from mssdvd/master
Add an option to not define keybindings in Emacs mode
---
README.org | 2 ++
evil-nerd-commenter.el | 14 ++++++++------
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/README.org b/README.org
index 5156f0ebd8..24bcf006bd 100644
--- a/README.org
+++ b/README.org
@@ -36,6 +36,8 @@ Please note v3.2.1 is the last version supporting Emacs 24.3.
Insert =(evilnc-default-hotkeys)= into =~/.emacs= to use key bindings preset
for both evil and non-evil mode. This is recommended way.
Use =(evilnc-default-hotkeys t)= to use key binding only for non-evil mode if
you want to define key bindings in evil-mode by yourself.
+
+Use =(evilnc-default-hotkeys nil t)= to use key binding only for evil mode if
you want to define key bindings in Emacs mode by yourself.
** Use evil-leader instead
Install [[https://github.com/cofi/evil-leader][evil-leader according to its
README]].
diff --git a/evil-nerd-commenter.el b/evil-nerd-commenter.el
index 30456b0ec5..c281665fd2 100644
--- a/evil-nerd-commenter.el
+++ b/evil-nerd-commenter.el
@@ -673,15 +673,17 @@ Then we operate the expanded region. NUM is ignored."
(defvar evil-inner-text-objects-map)
(defvar evil-outer-text-objects-map)
;;;###autoload
-(defun evilnc-default-hotkeys (&optional no-evil-keybindings)
+(defun evilnc-default-hotkeys (&optional no-evil-keybindings
no-emacs-keybindings)
"Setup the key bindings of evil-nerd-comment.
-If NO-EVIL-KEYBINDINGS is t, we don't define keybindings in EVIL."
+If NO-EVIL-KEYBINDINGS is t, we don't define keybindings in EVIL,
+if NO-EMACS-KEYBINDINGS is t, we don't define keybindings in EMACS mode."
(interactive)
;; Install hotkeys for Emacs mode
- (global-set-key (kbd "M-;") 'evilnc-comment-or-uncomment-lines)
- (global-set-key (kbd "C-c l") 'evilnc-quick-comment-or-uncomment-to-the-line)
- (global-set-key (kbd "C-c c") 'evilnc-copy-and-comment-lines)
- (global-set-key (kbd "C-c p") 'evilnc-comment-or-uncomment-paragraphs)
+ (unless no-emacs-keybindings
+ (global-set-key (kbd "M-;") 'evilnc-comment-or-uncomment-lines)
+ (global-set-key (kbd "C-c l")
'evilnc-quick-comment-or-uncomment-to-the-line)
+ (global-set-key (kbd "C-c c") 'evilnc-copy-and-comment-lines)
+ (global-set-key (kbd "C-c p") 'evilnc-comment-or-uncomment-paragraphs))
;; Install key bindings for evil
(unless no-evil-keybindings