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

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

[nongnu] elpa/evil-nerd-commenter 5d9635cc11 028/235: better support for


From: ELPA Syncer
Subject: [nongnu] elpa/evil-nerd-commenter 5d9635cc11 028/235: better support for commenting multiple paragraph, v1.0.0
Date: Thu, 6 Jan 2022 02:59:32 -0500 (EST)

branch: elpa/evil-nerd-commenter
commit 5d9635cc11ab71356bb8cda36b148210de179839
Author: Chen Bin <Chen.Bin@optus.com.au>
Commit: Chen Bin <Chen.Bin@optus.com.au>

    better support for commenting multiple paragraph, v1.0.0
---
 README.org                 | 14 +++++++++---
 evil-nerd-commenter-pkg.el |  2 +-
 evil-nerd-commenter.el     | 55 +++++++++++++++++++++++++++-------------------
 pkg.sh                     |  2 +-
 4 files changed, 45 insertions(+), 28 deletions(-)

diff --git a/README.org b/README.org
index 19f4c1de37..5fd452e8c5 100644
--- a/README.org
+++ b/README.org
@@ -1,9 +1,9 @@
-* evil-nerd-commenter (current version 0.0.10)
+* evil-nerd-commenter (current version 1.0.0)
 As a developer, I often need comment/uncomment lines for debugging or adding 
some short comment in the code block.
 
 As I know, the [[http://www.vim.org/scripts/script.php?script_id=1218][Nerd 
Commenter]] for Vim is the most efficient way to doing this thing. 
Unfortunately, there is no similar plugin in Emacs.
 
-That's why I develop this Nerd Commenter simulator for Emacs people. Besides, 
I'm also adding my own utilities into this plugin. For example, I added a 
command to comment *AND* copy lines in version 0.0.10.
+That's why I develop this Nerd Commenter simulator for Emacs people. Besides, 
I'm also adding my own utilities into this plugin. For example, I added a 
command to comment *AND* copy lines in version 1.0.0.
 
 Though this program could be used *independently*, I highly recommend you use 
it with [[http://gitorious.org/evil][evil]].
 
@@ -89,7 +89,15 @@ Example 5:
 "C-u 2 M-x evilnc-copy-and-comment-lines", copy 2 lines and paste them below 
the original line. Then comment out original lines. The focus will be moved to 
the new lines.
 
 Example 6:
-"C-u 2 M-x evilnc-comment-or-uncomment-paragraphs", comment out two paragraphs.
+"C-u 2 M-x evilnc-comment-or-uncomment-paragraphs", comment out two 
paragraphs. This is useful if you have large hunk of data to be commented out:
+#+BEGIN_SRC javascript
+var myJson={
+  "key1":"v1",
+  "key2":"v2",
+  "key3":"v3"
+}
+#+END_SRC
+
 
 * Contact me
 You can report bugs at [[https://github.com/redguardtoo/evil-nerd-commenter]]. 
My email is <chenbin.sh@gmail.com>.
diff --git a/evil-nerd-commenter-pkg.el b/evil-nerd-commenter-pkg.el
index 46403c9bac..d70f75a7f2 100644
--- a/evil-nerd-commenter-pkg.el
+++ b/evil-nerd-commenter-pkg.el
@@ -1,2 +1,2 @@
-(define-package "evil-nerd-commenter" "0.0.10"
+(define-package "evil-nerd-commenter" "1.0.0"
                 "Comment/uncomment lines efficiently. Like Nerd Commenter in 
Vim")
diff --git a/evil-nerd-commenter.el b/evil-nerd-commenter.el
index 978f8f530c..5acab177fe 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: 0.0.10
+;; Version: 1.0.0
 ;; Keywords: commenter vim line evil
 ;;
 ;; This file is not part of GNU Emacs.
@@ -110,8 +110,8 @@
   )
 
 
-(defun evilnc--comment-or-uncomment-one-paragraph ()
-  (let (b e (forward-search-done nil))
+(defun evilnc--get-one-paragraph-region ()
+  (let (b e)
     (save-excursion
       (setq b (re-search-backward "^[ \t]*$" nil t))
       (if b (progn
@@ -122,23 +122,16 @@
         )
       )
     (save-excursion
+
       (setq e (re-search-forward "^[ \t]*$" nil t))
       (if e (progn
               (forward-line -1)
               (setq e (line-end-position))
               )
-        (progn
-          (setq e (point-max))
-          (setq forward-search-done t)
-          )
+        (setq e (point-max))
         )
       )
-    ;; (message "b e: %d %d" b e)
-    (when (<= b e)
-      (evilnc--fix-buggy-major-modes)
-      (comment-or-uncomment-region b e)
-      )
-    (if forward-search-done nil e)
+    (list b e)
     )
   )
 
@@ -150,31 +143,47 @@
 Paragraphs are separated by empty lines."
   (interactive "p")
   (let ((i 0)
-        rlt)
+        rlt
+        (b (point-max))
+        (e 0)
+        )
     (catch 'break
       (while (< i NUM)
         (incf i)
-        (setq rlt (evilnc--comment-or-uncomment-one-paragraph))
+        (setq rlt (evilnc--get-one-paragraph-region))
+        (setq b (if (< (nth 0 rlt) b) (nth 0 rlt) b))
+        (setq e (if (> (nth 1 rlt) e) (nth 1 rlt) e))
 
         ;; prepare for the next paragraph
         (if (and rlt (< i NUM))
             (progn
-              ;; rlt should be the end of last non-empty line
-              (goto-char rlt)
+              ;; e should be the end of last non-empty line
+              (goto-char e)
 
-              ;; (beginning-of-line)
               ;; move to an empty line
               (forward-line)
-              ;; record the empty line position for furture use
-              (setq rlt (line-beginning-position))
 
               ;; move to next non-empty line
               (re-search-forward "^[ \t]*[^ \t]" nil t)
-              (if (<= (line-beginning-position) rlt) (throw 'break i))
+
+              (if (<= (line-beginning-position) e)
+                  (progn
+                    (throw 'break i)
+                    )
+                )
               )
-          (throw 'break i)
+          (progn
+            (throw 'break i)
+            )
           )
-        )))
+        ))
+    (when (<= b e)
+      (save-excursion
+        (evilnc--fix-buggy-major-modes)
+        (comment-or-uncomment-region b e)
+        )
+      )
+    )
   )
 
 ;;;###autoload
diff --git a/pkg.sh b/pkg.sh
index c03ee738bc..a54ec6e501 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-pkg=evil-nerd-commenter-0.0.10
+pkg=evil-nerd-commenter-1.0.0
 mkdir $pkg
 cp README.org $pkg
 cp *.el $pkg



reply via email to

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