[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-nerd-commenter b8ac35fe01 225/235: add evilnc-yank-an
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-nerd-commenter b8ac35fe01 225/235: add evilnc-yank-and-comment-operator |
Date: |
Thu, 6 Jan 2022 02:59:50 -0500 (EST) |
branch: elpa/evil-nerd-commenter
commit b8ac35fe019df5602c31912f65303a3d8ad0066c
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
add evilnc-yank-and-comment-operator
---
README.org | 2 ++
evil-nerd-commenter-operator.el | 31 +++++++++++++++++++++++--------
evil-nerd-commenter.el | 8 +++++---
pkg.sh | 2 +-
4 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/README.org b/README.org
index da9b7d50b7..8f5d2a8f76 100644
--- a/README.org
+++ b/README.org
@@ -255,6 +255,8 @@ Example 7: ",,it", comment the region inside html tags (all
html major modes are
** evilnc-copy-and-comment-operator
=evilnc-copy-and-comment-operator= is another evil-mode operator. Instead of
commenting out the text in the operator-range, it inserts an copy of the text
in the range and comments out that copy. Its hot key is ",.". For example,
",.," to comment out the current line.
+** evilnc-yank-and-comment-operator
+Operator to comment or uncomment the text and yank the original text at the
same time.
* Tips
** Yank in evil-mode
You can yank to line 99 using hotkey =y99G= or =y99gg=. That's the feature
from evil-mode.
diff --git a/evil-nerd-commenter-operator.el b/evil-nerd-commenter-operator.el
index 24f8ecde80..63a32d1349 100644
--- a/evil-nerd-commenter-operator.el
+++ b/evil-nerd-commenter-operator.el
@@ -174,10 +174,8 @@ Or expand the region to contain whole lines if it's not
comment and certain cond
(if (and (called-interactively-p 'any) (eq type 'line))
(evil-first-non-blank)))
-(evil-define-operator evilnc-copy-and-comment-operator (begin end)
- "Inserts a commented copy of the text from BEGIN to END."
- :move-point (not evilnc-original-above-comment-when-copy-and-comment)
- (interactive "<r>")
+(defun evilnc-comment-or-uncomment-region-then-action (begin end commenter
&optional action)
+ "Comment/uncomment between BEGIN and END using COMMENTER, then take ACTION."
(evil-with-single-undo
;; yank original text
(evil-yank-lines begin end nil 'lines)
@@ -189,17 +187,34 @@ Or expand the region to contain whole lines if it's not
comment and certain cond
(cond
(evilnc-original-above-comment-when-copy-and-comment
(let* ((p (point)))
- (comment-region begin end)
+ (funcall commenter begin end)
(goto-char begin)
- (evil-paste-before 1)
+ (when action (funcall action))
(goto-char p)))
(t
(goto-char end)
- (evil-paste-before 1)
+ (when action (funcall action))
;; actual comment operation should happen at last
;; or else begin end will be screwed up
- (comment-region begin end)))))
+ (funcall commenter begin end)))))
+
+(evil-define-operator evilnc-yank-and-comment-operator (begin end)
+ "(Un)comment and yank the text from BEGIN to END."
+ :move-point (not evilnc-original-above-comment-when-copy-and-comment)
+ (interactive "<r>")
+ (evilnc-comment-or-uncomment-region-then-action begin
+ end
+
evilnc-comment-or-uncomment-region-function))
+
+(evil-define-operator evilnc-copy-and-comment-operator (begin end)
+ "Inserts a commented copy of the text from BEGIN to END."
+ :move-point (not evilnc-original-above-comment-when-copy-and-comment)
+ (interactive "<r>")
+ (evilnc-comment-or-uncomment-region-then-action begin
+ end
+ 'comment-region
+ (lambda ()
(evil-paste-before 1))))
(defun evilnc-one-line-comment-p (begin end)
"Test if text between BEGIN and END is one line comment."
diff --git a/evil-nerd-commenter.el b/evil-nerd-commenter.el
index 4bb77eae05..f7c9965b7d 100644
--- a/evil-nerd-commenter.el
+++ b/evil-nerd-commenter.el
@@ -3,7 +3,7 @@
;; Author: Chen Bin <chenbin DOT sh AT gmail.com>
;; URL: http://github.com/redguardtoo/evil-nerd-commenter
-;; Version: 3.5.3
+;; Version: 3.5.4
;; Package-Requires: ((emacs "24.4"))
;; Keywords: convenience evil
;;
@@ -88,7 +88,9 @@
;; - Place the commented out text above original text
;; - Or place the original text above commented out text
;;
-;; We defined comment text object "c" which can have multi-lines.
+;; `evilnc-yank-and-comment-operator' (un)comment&yank text in one shot.
+;;
+;; Comment text object "c" is defined. It can have multi-lines.
;; Press "vac" to select outer object (comment with limiters).
;; Press "vic" to select inner object (comment without limiter).
;;
@@ -760,7 +762,7 @@ Then we operate the expanded region. NUM is ignored."
(defun evilnc-version ()
"The version number."
(interactive)
- (message "3.5.3"))
+ (message "3.5.4"))
(defvar evil-normal-state-map)
(defvar evil-visual-state-map)
diff --git a/pkg.sh b/pkg.sh
index 890a7c3b1f..9aa89b386a 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,6 +1,6 @@
#!/bin/bash
name=evil-nerd-commenter
-version=3.5.3
+version=3.5.4
pkg=$name-$version
mkdir $pkg
cp *.el $pkg
- [nongnu] elpa/evil-nerd-commenter 341f78551b 182/235: Fix regression for non-visual modes., (continued)
- [nongnu] elpa/evil-nerd-commenter 341f78551b 182/235: Fix regression for non-visual modes., ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 36304a689b 184/235: tested in Emacs 24.4, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 65bb73ec49 171/235: Update README.org to reflect changes in c68ad3346f528d1cabaef76e3944748e2b8f68b2, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter aa34d89797 185/235: add unit test and CI, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter f7b082d5b2 186/235: add build status into README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 00840b3da4 198/235: Merge pull request #103 from mamapanda/master, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter fa40dab8d2 208/235: know the text object before operate on it, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 4387407615 209/235: fixed key binding setup, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 60b8862864 210/235: clean code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter b7fc023492 220/235: fixed: `add-to-list’ can’t use lexical var `cands’, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter b8ac35fe01 225/235: add evilnc-yank-and-comment-operator,
ELPA Syncer <=
- [nongnu] elpa/evil-nerd-commenter b8a2601117 006/235: some tip, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter ef643d604d 007/235: updated README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter d3581dcf64 014/235: workaround autoconf.el comment bug, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 72965eab13 019/235: remove warning when installing package, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter a074fed790 033/235: Added check for evil-define-operator, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 71995b8ac3 034/235: Updated readme, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 0e24866151 048/235: updated README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter f3d4f7ef29 070/235: better integration with org-mode v1.3.0, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 1edf652fc6 086/235: explain how NOT to use comma as leader key, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter befd4da216 117/235: Comment operator should not be filling registers and kill-ring, ELPA Syncer, 2022/01/06