emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/evil-nerd-commenter 9f15aec3ce 056/235: support negative a


From: ELPA Syncer
Subject: [nongnu] elpa/evil-nerd-commenter 9f15aec3ce 056/235: support negative argument v1.2.6
Date: Thu, 6 Jan 2022 02:59:34 -0500 (EST)

branch: elpa/evil-nerd-commenter
commit 9f15aec3ce18e49adeb9bab4681ade982542cc41
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>

    support negative argument v1.2.6
---
 README.org                 |  6 +++---
 evil-nerd-commenter-pkg.el |  2 +-
 evil-nerd-commenter.el     | 33 ++++++++++++++++++++++-----------
 pkg.sh                     |  2 +-
 4 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/README.org b/README.org
index dc8fe0f80b..fb0215c35d 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-nerd-commenter (current version 1.2.5)
+* evil-nerd-commenter (current version 1.2.6)
 
 *Please note this program could be used independently without evil-mode!*
 
@@ -87,9 +87,9 @@ If you don't use emacs package manager (Why?) to install 
evil-nerd-commenter the
 
 * Usage
 Here are available commands. They are not dependent on 
[[http://emacswiki.org/emacs/Evil][evil-mode]]:
-- evilnc-comment-or-uncomment-lines :: comment/uncomment lines.
+- evilnc-comment-or-uncomment-lines :: comment/uncomment lines. This command 
supports negative arguments.
 - evilnc-comment-or-uncomment-to-the-line :: comment/uncomment from current 
line to the specified line.
-- evilnc-copy-and-comment-lines :: copy and paste lines, then comment out 
original lines
+- evilnc-copy-and-comment-lines :: copy and paste lines, then comment out 
original lines. This command supports negative arguments.
 - evilnc-comment-or-uncomment-paragraphs :: comment/uncomment paragraphs which 
separated by empty lines
 - evilnc-toggle-comment-empty-lines :: toggle the flag to comment/uncomment 
empty lines
 - evilnc-copy-to-line :: Copy from the current line to the user specified 
line, *for non-evil user only, you need set hot key for it*
diff --git a/evil-nerd-commenter-pkg.el b/evil-nerd-commenter-pkg.el
index d85ec5dd06..57015839ac 100644
--- a/evil-nerd-commenter-pkg.el
+++ b/evil-nerd-commenter-pkg.el
@@ -1,2 +1,2 @@
-(define-package "evil-nerd-commenter" "1.2.5"
+(define-package "evil-nerd-commenter" "1.2.6"
                 "Comment/uncomment lines efficiently. Like Nerd Commenter in 
Vim")
diff --git a/evil-nerd-commenter.el b/evil-nerd-commenter.el
index 4e0ae52335..1570c0a957 100644
--- a/evil-nerd-commenter.el
+++ b/evil-nerd-commenter.el
@@ -4,7 +4,7 @@
 
 ;; Author: Chen Bin <chenbin.sh@gmail.com>
 ;; URL: http://github.com/redguardtoo/evil-nerd-commenter
-;; Version: 1.2.5
+;; Version: 1.2.6
 ;; Keywords: commenter vim line evil
 ;;
 ;; This file is not part of GNU Emacs.
@@ -265,28 +265,40 @@ Paragraphs are separated by empty lines."
 
 ;;;###autoload
 (defun evilnc-comment-or-uncomment-lines (&optional NUM)
-  "Comment or uncomment lines.
+  "Comment or uncomment NUM lines. NUM could be negative.
    Case 1: If no region selected, comment/uncomment on current line. if NUM>1, 
comment/uncomment
    extra N-1 lines from next line
    Case 2: If a region selected, the region is expand to make sure the region 
contain
    whole lines. Then we comment/uncomment the expanded region. NUM is ignored."
   (interactive "p")
-  (evilnc--operation-on-lines-or-region '(lambda (b e)
-                                           (evilnc--fix-buggy-major-modes)
-                                           (comment-or-uncomment-region b e)
-                                           )
-                                        NUM)
-  )
+  ;; donot move the cursor
+  (save-excursion
+    ;; support negative number
+    (when (< NUM 0)
+      (forward-line (1+ NUM))
+      (setq NUM (- 0 NUM)))
+
+    (evilnc--operation-on-lines-or-region '(lambda (b e)
+                                             (evilnc--fix-buggy-major-modes)
+                                             (comment-or-uncomment-region b e)
+                                             )
+                                          NUM)))
 
 ;;;###autoload
 (defun evilnc-copy-and-comment-lines (&optional NUM)
-  "Copy and paste lines. Then comment original lines.
+  "Copy and paste NUM lines. Then comment the original lines. 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: If a region selected, the region is expand to make sure the region 
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)
@@ -296,8 +308,7 @@ Paragraphs are separated by empty lines."
         (insert-before-markers str)
         (comment-region beg end)
         ))
-   NUM)
-  )
+   NUM))
 
 ;; {{ for non-evil user only
 ;;;###autoload
diff --git a/pkg.sh b/pkg.sh
index 0eb793b5e3..9db4fb37ca 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-pkg=evil-nerd-commenter-1.2.5
+pkg=evil-nerd-commenter-1.2.6
 mkdir $pkg
 cp README.org $pkg
 cp *.el $pkg



reply via email to

[Prev in Thread] Current Thread [Next in Thread]