branch: elpa/evil-nerd-commenter
commit 54c618aada776bfda0742819ff9e91845a91e095
Author: Chen Bin <[email protected]>
Commit: Chen Bin <[email protected]>

    add `evilnc-comment-and-kill-ring-save`
---
 README.org                      | 15 ++++++++-------
 evil-nerd-commenter-operator.el |  2 +-
 evil-nerd-commenter-pkg.el      |  2 +-
 evil-nerd-commenter.el          | 31 +++++++++++++++++++++++++++----
 pkg.sh                          |  2 +-
 5 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/README.org b/README.org
index 09a6f65a2d..6fbfa884d8 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-nerd-commenter (v2.3)
+* evil-nerd-commenter (v2.3.1)
 
 
[[http://melpa.org/#/evil-nerd-commenter][file:http://melpa.org/packages/evil-nerd-commenter-badge.svg]]
 
[[http://stable.melpa.org/#/evil-nerd-commenter][file:http://stable.melpa.org/packages/evil-nerd-commenter-badge.svg]]
 
@@ -20,7 +20,7 @@ So you strike less keys than the original "M-x comment-dwim".
 
 Live demo:
 
[[https://raw.github.com/redguardtoo/evil-nerd-commenter/master/evil-nerd-commenter-demo.gif]]
-** It will even fix Emacs bug for you
+** It fixes Emacs bug for you
 I'll provide long-term support for *ANY language* in the future. Here is an 
example how I work around 
[[https://github.com/redguardtoo/evil-nerd-commenter/issues/3][a bug in 
autoconf.el]].
 
 ** Perfect integration with org-mode
@@ -61,7 +61,7 @@ Insert following code into you ~/.emacs,
 )
 #+END_SRC
 
-** Assign keybindings manually
+** Assign key bindings manually
 Manual setup is necessary for certain major modes (matlab-mode, for example)
 
 Here is the minimum setup,
@@ -72,9 +72,9 @@ Here is the minimum setup,
 #+end_src
 * Usage
 ** Available commands and hotkeys
-Here are available commands. They are NOT dependent on 
[[http://emacswiki.org/emacs/Evil][evil-mode]]:
+Here are available commands which 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 "\".
+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.
@@ -98,10 +98,11 @@ The hotkey is ",cl" or ",ll" in evil-mode and "C-c l" (C 
means Ctrl key) in emac
 comment/uncomment paragraphs which separated by empty lines
 
 *** evilnc-copy-and-comment-lines
-copy and paste lines, then comment out original lines. This command supports 
negative arguments.
+Copy and paste lines, then comment out original lines. This command supports 
negative arguments.
 
 The hotkey is ",cc" in evil-mode and "C-c c" in emacs normal mode.
-
+*** evilnc-comment-and-kill-ring-save
+Comment lines and insert original lines into =kill-ring=.
 *** evilnc-comment-or-uncomment-to-the-line
 Comment to the specified line. evilnc-quick-comment-or-uncomment-to-the-line 
may be better alternative.
 *** evilnc-toggle-comment-empty-lines
diff --git a/evil-nerd-commenter-operator.el b/evil-nerd-commenter-operator.el
index 272fe4063a..f107036d64 100644
--- a/evil-nerd-commenter-operator.el
+++ b/evil-nerd-commenter-operator.el
@@ -4,7 +4,7 @@
 
 ;; Author: Chen Bin <[email protected]>
 ;; URL: http://github.com/redguardtoo/evil-nerd-commenter
-;; Version: 2.3
+;; Version: 2.3.1
 ;; Keywords: commenter vim line evil
 ;;
 ;; This file is not part of GNU Emacs.
diff --git a/evil-nerd-commenter-pkg.el b/evil-nerd-commenter-pkg.el
index 62c041537b..16ce2d1121 100644
--- a/evil-nerd-commenter-pkg.el
+++ b/evil-nerd-commenter-pkg.el
@@ -1,2 +1,2 @@
-(define-package "evil-nerd-commenter" "2.3"
+(define-package "evil-nerd-commenter" "2.3.1"
                 "Comment/uncomment lines efficiently. Like Nerd Commenter in 
Vim")
diff --git a/evil-nerd-commenter.el b/evil-nerd-commenter.el
index 117f417d5c..678df430ef 100644
--- a/evil-nerd-commenter.el
+++ b/evil-nerd-commenter.el
@@ -4,7 +4,7 @@
 
 ;; Author: Chen Bin <[email protected]>
 ;; URL: http://github.com/redguardtoo/evil-nerd-commenter
-;; Version: 2.3
+;; Version: 2.3.1
 ;; Keywords: commenter vim line evil
 ;;
 ;; This file is not part of GNU Emacs.
@@ -71,7 +71,7 @@
 ;;   "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
+;;   "cc" 'evilnc-copy-and-comment-lines ; Or use 
`evilnc-comment-and-kill-ring-save' instead
 ;;   "cp" 'evilnc-comment-or-uncomment-paragraphs
 ;;   "cr" 'comment-or-uncomment-region
 ;;   "cv" 'evilnc-toggle-invert-comment-line-by-line
@@ -133,7 +133,7 @@ See 
http://lists.gnu.org/archive/html/bug-gnu-emacs/2013-03/msg00891.html.";
     ;; since comment-use-syntax is nil in autoconf.el, the comment-start-skip 
need
     ;; make sure its first parenthesized expression match the string exactly 
before
     ;; the "dnl", check the comment-start-skip in lisp-mode for sample.
-    ;; See code in (defun comment-search-forward) from emacs 24.2.3:
+    ;; See code in (defun comment-search-forward) from emacs 24.2.3.1:
     ;; (if (not comment-use-syntax)
     ;;     (if (re-search-forward comment-start-skip limit noerror)
     ;;     (or (match-end 1) (match-beginning 0)))
@@ -588,6 +588,29 @@ Then we operate the expanded region.  NUM is ignored."
         (comment-region beg end)))
    num))
 
+;;;###autoload
+(defun evilnc-comment-and-kill-ring-save (&optional num)
+  "Comment lines save origin lines into `kill-ring'.
+NUM could be negative.
+
+Case 1: If no region selected, operate on current line.
+;; if NUM>1, comment/uncomment extra N-1 lines from next line
+
+Case 2: Selected region is expanded to make it contain whole lines.
+Then we operate the expanded region.  NUM is ignored."
+  (interactive "p")
+  ;; support negative number
+  (when (< num 0)
+    (forward-line (1+ num))
+    (setq num (- 0 num)))
+
+  (evilnc--operation-on-lines-or-region
+   '(lambda (beg end)
+      (evilnc--fix-buggy-major-modes)
+      (kill-new (buffer-substring-no-properties beg end))
+      (comment-region beg end))
+   num))
+
 ;; {{ for non-evil user only
 ;;;###autoload
 (defun evilnc-copy-to-line (&optional LINENUM)
@@ -627,7 +650,7 @@ Then we operate the expanded region.  NUM is ignored."
 (defun evilnc-version ()
   "The version number."
   (interactive)
-  (message "2.3"))
+  (message "2.3.1"))
 
 ;;;###autoload
 (defun evilnc-default-hotkeys ()
diff --git a/pkg.sh b/pkg.sh
index f22fe02f7e..c4a8478fe5 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-pkg=evil-nerd-commenter-2.3
+pkg=evil-nerd-commenter-2.3.1
 mkdir $pkg
 cp README.org $pkg
 cp *.el $pkg

Reply via email to