branch: elpa/evil-nerd-commenter
commit 7a1647cf6d6b56e7fe9ea226ac7c27ff73cc2157
Author: Chen Bin <[email protected]>
Commit: Chen Bin <[email protected]>
donot use comma as default hotkey, v 1.5.14
---
README.org | 83 +++++++++++++++++------------------------
evil-nerd-commenter-operator.el | 7 +---
evil-nerd-commenter.el | 33 ++++++++--------
pkg.sh | 2 +-
4 files changed, 54 insertions(+), 71 deletions(-)
diff --git a/README.org b/README.org
index 5e5b2d4745..703dbe6418 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-nerd-commenter (v1.5.13)
+* evil-nerd-commenter (v1.5.14)
This program can be used *independently WITHOUT
[[http://www.emacswiki.org/Evil][evil-mode]]!*
@@ -27,16 +27,44 @@ The code snippet embedded in org file will automatically be
detected and *correc
* Install
evil-nerd-commenter is already uploaded to [[http://melpa.org]]. The best way
to install is Emacs package manager.
* Set up
-** The easy way
-You need add one line into ~/.emacs to use default hotkeys,
+** Use default key bindings
+You need only one line into ~/.emacs,
#+BEGIN_SRC lisp
(evilnc-default-hotkeys)
#+END_SRC
-** The hard way
-Check "Tip 4" in "Tips" section.
+
+** Use evil-leader instead
+Install [[https://github.com/cofi/evil-leader][evil-leader according to its
README]].
+
+Insert following code into you ~/.emacs,
+#+BEGIN_SRC elisp
+;; Emacs key bindings
+(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)
+
+;; Vim key bindings
+(require 'evil-leader)
+(global-evil-leader-mode)
+(evil-leader/set-key
+ "ci" 'evilnc-comment-or-uncomment-lines
+ "cl" 'evilnc-quick-comment-or-uncomment-to-the-line
+ "ll" 'evilnc-quick-comment-or-uncomment-to-the-line
+ "cc" 'evilnc-copy-and-comment-lines
+ "cp" 'evilnc-comment-or-uncomment-paragraphs
+ "cr" 'comment-or-uncomment-region
+ "cv" 'evilnc-toggle-invert-comment-line-by-line
+ "\\" 'evilnc-comment-operator ; if you prefer backslash key
+)
+#+END_SRC
+
* Usage
** Available commands and hotkeys
Here are available commands. They are NOT dependent on
[[http://emacswiki.org/emacs/Evil][evil-mode]]:
+
+If you use evil-leader, the "," in all evil-mode hotkeys is replaced with "\".
+
*** evilnc-comment-or-uncomment-lines (RECOMMENDED)
comment/uncomment lines. This command supports negative arguments.
@@ -130,14 +158,7 @@ All you need to is "M-x
evilnc-toggle-invert-comment-line-by-line" then "C-u 2 e
* Evil usage
If you use [[http://emacswiki.org/emacs/Evil][Evil]], you can use
[[http://vimdoc.sourceforge.net/htmldoc/motion.html#text-objects][text objects
and motions]].
-"evilnc-hotkey-comment-operator" acts much like the delete/change operator.
Takes a motion or text object and comments it out, yanking its content in the
process.
-
-By default we assign the hotkey ",," to evilnc-hotkey-comment-operator. If you
prefer backslash key, check the "Tip 4" in "Tips" section.
-
-Here is sample elisp code:
-#+BEGIN_SRC elisp
-(setq evilnc-hotkey-comment-operator ",,")
-#+END_SRC
+"evilnc-comment-operator" acts much like the delete/change operator. Takes a
motion or text object and comments it out, yanking its content in the process.
Example 1: ",,," to comment out the current line.
@@ -175,43 +196,9 @@ Thanks for Andrew Pennebaker (aka mcandre) providing this
tip.
Please check my project
[[https://github.com/redguardtoo/evil-matchit][evil-matchit]]. You can press
"vi%" to select a region between tags and press "M-/" to comment the region.
Most popular programming languages are supported;
-** Tip 4, use evil-leader if you use the *backslash* as the leader key in
evil-mode
-- Install [[https://github.com/cofi/evil-leader][evil-leader according to its
README]].
-- Remove line "(evilnc-default-hotkeys)" from your ~/.emacs.
-- Insert below code into you ~/.emacs,
-#+BEGIN_SRC elisp
-;; Emacs key bindings
-(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)
-
-;; Vim key bindings
-(require 'evil-leader)
-(global-evil-leader-mode)
-(evil-leader/set-key
- "ci" 'evilnc-comment-or-uncomment-lines
- "cl" 'evilnc-quick-comment-or-uncomment-to-the-line
- "ll" 'evilnc-quick-comment-or-uncomment-to-the-line
- "cc" 'evilnc-copy-and-comment-lines
- "cp" 'evilnc-comment-or-uncomment-paragraphs
- "cr" 'comment-or-uncomment-region
- "cv" 'evilnc-toggle-invert-comment-line-by-line
- "\\" 'evilnc-comment-operator ; if you prefer backslash key
-)
-#+END_SRC
-
-** Tip 5, (un)comment Lisp code
+** Tip 4, (un)comment Lisp code
- Make sure Evil installed
- Press ",,a("
-** Tip 6, work around Emacs 24.4 issue
-At first, latest version (after 2014-10-30) of this program is OK.
-
-If you still got some problem, run below command in shell,
-#+begin_src sh
-find ~/.emacs.d -type f -iwholename '*/evil-nerd-commenter*.elc' | xargs rm
-#+end_src
-
* Credits
- [[https://github.com/lalopmak][Lally Oppenheimer (AKA lalopmak)]] added the
support for text-object in Evil
- [[https://github.com/ryuslash][Tom Willemse (AKA ryuslash)]] provided the
fix to make Emacs 24.4 work
diff --git a/evil-nerd-commenter-operator.el b/evil-nerd-commenter-operator.el
index 0c05fdcd6a..8c412eb4b7 100644
--- a/evil-nerd-commenter-operator.el
+++ b/evil-nerd-commenter-operator.el
@@ -1,10 +1,10 @@
;;; evil-nerd-commenter-operator --- Provides an evil operator for
evil-nerd-commenter
-;; Copyright (C) 2013 Chen Bin
+;; Copyright (C) 2013-2015, Chen Bin
;; Author: Chen Bin <[email protected]>
;; URL: http://github.com/redguardtoo/evil-nerd-commenter
-;; Version: 1.5.12
+;; Version: 1.5.14
;; Keywords: commenter vim line evil
;;
;; This file is not part of GNU Emacs.
@@ -69,9 +69,6 @@ Save in REGISTER or in the kill-ring with YANK-HANDLER."
(eq type 'line))
(evil-first-non-blank)))
-(define-key evil-normal-state-map evilnc-hotkey-comment-operator
'evilnc-comment-operator)
-(define-key evil-visual-state-map evilnc-hotkey-comment-operator
'evilnc-comment-operator)
-
(provide 'evil-nerd-commenter-operator)
;;; evil-nerd-commenter-operator.el ends here
diff --git a/evil-nerd-commenter.el b/evil-nerd-commenter.el
index 8d078bb0bb..a050135eaa 100644
--- a/evil-nerd-commenter.el
+++ b/evil-nerd-commenter.el
@@ -1,6 +1,6 @@
;;; evil-nerd-commenter --- Comment/uncomment lines efficiently. Like Nerd
Commenter in Vim
-;; Copyright (C) 2013 Chen Bin
+;; Copyright (C) 2013-2015, Chen Bin
;; Author: Chen Bin <[email protected]>
;; URL: http://github.com/redguardtoo/evil-nerd-commenter
@@ -31,14 +31,8 @@
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
-;;; WARNING:
-
-;; Emacs v24.4 has some issue if and only if you install evil-nerd-commenter
from package manager (elpa/melpa/...).
-;;
-;; This can be *easily resolved* by running below command line in shell,
-;; find ~/.emacs.d -type f -iwholename '*/evil-nerd-commenter*.elc' | xargs rm
-
;;; Commentary:
+
;;
;; This program emulates nerd-commenter.vim by Marty Grenfell.
;;
@@ -90,14 +84,8 @@
;;; Code:
-;; Example, press ",,a{" will change C code:
-;; {printf("hello");} => /* {printf("hello");}*/
-;; google "vim text object for more syntax"
-(defcustom evilnc-hotkey-comment-operator ",," "The hot key for
evilnc-comment-operator to (un)comment text object"
- :type 'string
- :group 'evil-nerd-commenter)
-
-(defvar evilnc-invert-comment-line-by-line nil "if t then invert region
comment status line by line")
+(defvar evilnc-invert-comment-line-by-line nil
+ "if t then invert region comment status line by line")
;; shamelessly copied from goto-line
(defun evilnc--goto-line (line)
@@ -532,10 +520,14 @@ or 'C-u 3 M-x
evilnc-quick-comment-or-uncomment-to-the-line' to comment to the l
(defun evilnc-default-hotkeys ()
"Set the hotkeys of evil-nerd-comment"
(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)
+
+ ;; Install key bindings for evil
(eval-after-load 'evil
'(progn
(define-key evil-normal-state-map ",ci"
'evilnc-comment-or-uncomment-lines)
@@ -544,7 +536,14 @@ or 'C-u 3 M-x
evilnc-quick-comment-or-uncomment-to-the-line' to comment to the l
(define-key evil-normal-state-map ",cc" 'evilnc-copy-and-comment-lines)
(define-key evil-normal-state-map ",cp"
'evilnc-comment-or-uncomment-paragraphs)
(define-key evil-normal-state-map ",cr" 'comment-or-uncomment-region)
- (define-key evil-normal-state-map ",cv"
'evilnc-toggle-invert-comment-line-by-line))))
+ (define-key evil-normal-state-map ",cv"
'evilnc-toggle-invert-comment-line-by-line)))
+
+ ;; Install operator for evil text objects
+ (eval-after-load 'evil-nerd-commenter-operator
+ '(progn
+ (define-key evil-normal-state-map ",," 'evilnc-comment-operator)
+ (define-key evil-visual-state-map ",," 'evilnc-comment-operator)))
+ )
;; Attempt to define the operator on first load.
;; Will only work if evil has been loaded
diff --git a/pkg.sh b/pkg.sh
index 5707a77170..245d08623b 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-pkg=evil-nerd-commenter-1.5.13
+pkg=evil-nerd-commenter-1.5.14
mkdir $pkg
cp README.org $pkg
cp *.el $pkg