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

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

[nongnu] elpa/evil-nerd-commenter da42daecb7 055/235: new: copy and kill


From: ELPA Syncer
Subject: [nongnu] elpa/evil-nerd-commenter da42daecb7 055/235: new: copy and kill to specific line for non-evil users, v 1.2.5
Date: Thu, 6 Jan 2022 02:59:34 -0500 (EST)

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

    new: copy and kill to specific line for non-evil users, v 1.2.5
---
 README.org                 |  6 ++++--
 evil-nerd-commenter-pkg.el |  2 +-
 evil-nerd-commenter.el     | 41 ++++++++++++++++++++++++++++++++++++++++-
 pkg.sh                     |  2 +-
 4 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/README.org b/README.org
index daec79d8ba..dc8fe0f80b 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-nerd-commenter (current version 1.2.4)
+* evil-nerd-commenter (current version 1.2.5)
 
 *Please note this program could be used independently without evil-mode!*
 
@@ -92,6 +92,8 @@ Here are available commands. They are not dependent on 
[[http://emacswiki.org/em
 - evilnc-copy-and-comment-lines :: copy and paste lines, then comment out 
original lines
 - 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*
+- evilnc-kill-to-line :: Kill from the current line to the user specified 
line, *for non-evil user only, you need set hot key for it*
 
 Example 1:
 "C-u NUM M-x evilnc-comment-or-uncomment-lines", comment/uncomment next NUM 
lines.
@@ -106,7 +108,7 @@ Example 4:
 "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 5:
-"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:
+"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 
as below:
 #+BEGIN_SRC javascript
 var myJson={
   "key1":"v1",
diff --git a/evil-nerd-commenter-pkg.el b/evil-nerd-commenter-pkg.el
index 8cfd88824d..d85ec5dd06 100644
--- a/evil-nerd-commenter-pkg.el
+++ b/evil-nerd-commenter-pkg.el
@@ -1,2 +1,2 @@
-(define-package "evil-nerd-commenter" "1.2.4"
+(define-package "evil-nerd-commenter" "1.2.5"
                 "Comment/uncomment lines efficiently. Like Nerd Commenter in 
Vim")
diff --git a/evil-nerd-commenter.el b/evil-nerd-commenter.el
index bcc13126db..4e0ae52335 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.4
+;; Version: 1.2.5
 ;; Keywords: commenter vim line evil
 ;;
 ;; This file is not part of GNU Emacs.
@@ -299,6 +299,45 @@ Paragraphs are separated by empty lines."
    NUM)
   )
 
+;; {{ for non-evil user only
+;;;###autoload
+(defun evilnc-copy-to-line (&optional LINENUM)
+  "Copy from the current line to the LINENUM line, for non-evil user only"
+  (interactive "p")
+  (if (not (region-active-p))
+      (let ((b (line-beginning-position))
+            (e (line-end-position)))
+        (save-excursion
+          (evilnc--goto-line LINENUM)
+          (if (< (line-beginning-position) b)
+              (setq b (line-beginning-position)))
+          (if (> (line-end-position) e)
+              (setq e (line-end-position)))
+          (kill-new (buffer-substring-no-properties b e))
+          )
+        )
+    ))
+
+;;;###autoload
+(defun evilnc-kill-to-line (&optional LINENUM)
+  "Kill from the current line to the LINENUM line, for non-evil user only"
+  (interactive "p")
+  (if (not (region-active-p))
+      (let ((b (line-beginning-position))
+            (e (line-end-position)))
+        (save-excursio;; n
+          (evilnc--goto-line LINENUM)
+          (if (< (line-beginning-position) b)
+              (setq b (line-beginning-position)))
+          (if (> (line-end-position) e)
+              (setq e (line-end-position)))
+          (kill-region b (+ 1 e)) ; +1 because we need remove the CR
+          )
+        )
+    ))
+
+;; }}
+
 ;;;###autoload
 (defun evilnc-default-hotkeys ()
   "Set the hotkeys of evil-nerd-comment"
diff --git a/pkg.sh b/pkg.sh
index 0e27324165..0eb793b5e3 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-pkg=evil-nerd-commenter-1.2.4
+pkg=evil-nerd-commenter-1.2.5
 mkdir $pkg
 cp README.org $pkg
 cp *.el $pkg



reply via email to

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