[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-nerd-commenter 01a98a20c5 144/235: users choose the s
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-nerd-commenter 01a98a20c5 144/235: users choose the style they prefer when copy and comment |
Date: |
Thu, 6 Jan 2022 02:59:43 -0500 (EST) |
branch: elpa/evil-nerd-commenter
commit 01a98a20c536a575ee5bc897f38116155154d5fe
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
users choose the style they prefer when copy and comment
---
README.org | 14 +++++++++-----
evil-nerd-commenter-operator.el | 22 +++++++++++++++-------
evil-nerd-commenter.el | 33 +++++++++++++++++++++++++--------
pkg.sh | 2 +-
4 files changed, 50 insertions(+), 21 deletions(-)
diff --git a/README.org b/README.org
index b795ba2119..e8642eaae8 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-nerd-commenter (v2.3.2)
+* evil-nerd-commenter (v2.3.3)
[[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]]
@@ -188,11 +188,11 @@ Example 7: ",,it", comment the region inside html tags
(all html major modes are
=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.
* Tips
-** Tip 1, Yank in evil-mode
+** Yank in evil-mode
You can yank to line 99 using hotkey =y99G= or =y99gg=. That's the feature
from evil-mode.
Please read vim manual on "text objects and motions".
-** Tip 2, change comment style
+** Change comment style
For example, if you prefer double slashes =//= instead of slash-stars =/* ...
*/= in =c-mode=, insert below code into your =~/.emacs=:
#+BEGIN_SRC elisp
(add-hook 'c-mode-common-hook
@@ -203,13 +203,17 @@ For example, if you prefer double slashes =//= instead of
slash-stars =/* ... */
#+END_SRC
Thanks for [[https://github.com/mcandre][Andrew Pennebaker (aka mcandre)]]
providing this tip.
-** Tip 3, comment code snippet
+** Comment code snippet
Please install [[https://github.com/redguardtoo/evil-matchit][evil-matchit]].
You can press =vi=%= to select a region between tags and press =M-;= to comment
the region.
Most popular programming languages are supported.
-** Tip 4, (un)comment Lisp code
+** Comment and uncomment Lisp code
- Make sure Evil installed
- Press ",,a("
+** Choose the style of copy and comment
+You can setup =evilnc-original-above-comment-when-copy-and-comment= to decide
which style to use when =evilnc-copy-and-comment-lines= or
=evilnc-copy-and-comment-operator=,
+- Place the commented out text above original text
+- Or place the original text above commented out text
* Credits
- [[https://github.com/lalopmak][Lally Oppenheimer (AKA lalopmak)]] added the
support for text-object in Evil
- [[https://github.com/ryuslash][Tom Willemse (AKA ryuslash)]] provided the
fix to make Emacs 24.4 work
diff --git a/evil-nerd-commenter-operator.el b/evil-nerd-commenter-operator.el
index 2cb416c661..dc33932929 100644
--- a/evil-nerd-commenter-operator.el
+++ b/evil-nerd-commenter-operator.el
@@ -4,7 +4,7 @@
;; Author: Chen Bin <chenbin.sh@gmail.com>
;; URL: http://github.com/redguardtoo/evil-nerd-commenter
-;; Version: 2.3.2
+;; Version: 2.3.3
;; Keywords: commenter vim line evil
;;
;; This file is not part of GNU Emacs.
@@ -67,14 +67,22 @@
(evil-define-operator evilnc-copy-and-comment-operator (beg end)
"Inserts an out commented copy of the text from BEG to END."
- :move-point nil
+ :move-point (not evilnc-original-above-comment-when-copy-and-comment)
(interactive "<r>")
- (let ((p (point)))
(evil-yank-lines beg end nil 'lines)
- (comment-region beg end)
- (goto-char beg)
- (evil-paste-before 1)
- (goto-char p)))
+ (cond
+ (evilnc-original-above-comment-when-copy-and-comment
+ (let* ((p (point)))
+ (comment-region beg end)
+ (goto-char beg)
+ (evil-paste-before 1)
+ (goto-char p)))
+ (t
+ (goto-char end)
+ (evil-paste-before 1)
+ ;; actual comment operatio should happen at last
+ ;; or else beg end will be screwed up
+ (comment-region beg end))))
(provide 'evil-nerd-commenter-operator)
;;; evil-nerd-commenter-operator.el ends here
diff --git a/evil-nerd-commenter.el b/evil-nerd-commenter.el
index b208b6c72c..0944857dce 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: 2.3.2
+;; Version: 2.3.3
;; Keywords: commenter vim line evil
;;
;; This file is not part of GNU Emacs.
@@ -57,7 +57,7 @@
;;
;; Setup:
;;
-;; 1. If comma is your leader key, as most Vim users do, setup is one liner,
+;; If comma is your leader key, as most Vim users do, setup is one liner,
;; (evilnc-default-hotkeys)
;;
;; If you use evil-leader and its default leader key,
@@ -78,6 +78,11 @@
;; "." 'evilnc-copy-and-comment-operator
;; "\\" 'evilnc-comment-operator)
;;
+;; You can setup `evilnc-original-above-comment-when-copy-and-comment' to
decide which
+;; style to use when `evilnc-copy-and-comment-lines' or
`evilnc-copy-and-comment-operator',
+;; - Place the commented out text above original text
+;; - Or place the original text above commented out text
+;;
;; For certain major modes, you need manual setup to override its original
;; keybindings,
;;
@@ -91,6 +96,10 @@
(autoload 'count-lines "simple")
+(defvar evilnc-original-above-comment-when-copy-and-comment nil
+ "Original text is above commented out when using
`evilnc-copy-and-comment-lines'
+ and `evilnc-copy-and-comment-operator'.")
+
(defvar evilnc-invert-comment-line-by-line nil
"If t then invert region comment status line by line.
Please note it has NOT effect on evil text object!")
@@ -133,7 +142,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.2:
+ ;; See code in (defun comment-search-forward) from emacs 24.2.3.3:
;; (if (not comment-use-syntax)
;; (if (re-search-forward comment-start-skip limit noerror)
;; (or (match-end 1) (match-beginning 0)))
@@ -585,10 +594,18 @@ Then we operate the expanded region. NUM is ignored."
'(lambda (beg end)
(evilnc--fix-buggy-major-modes)
(let* ((str (buffer-substring-no-properties beg end)))
- (goto-char end)
- (newline 1)
- (insert-before-markers str)
- (comment-region beg end)))
+ (cond
+ (evilnc-original-above-comment-when-copy-and-comment
+ (let* ((p (point)))
+ (comment-region beg end)
+ (goto-char beg)
+ (insert-before-markers (concat str "\n"))
+ (goto-char p)))
+ (t
+ (goto-char end)
+ (newline 1)
+ (insert-before-markers str)
+ (comment-region beg end)))))
num))
;;;###autoload
@@ -653,7 +670,7 @@ Then we operate the expanded region. NUM is ignored."
(defun evilnc-version ()
"The version number."
(interactive)
- (message "2.3.2"))
+ (message "2.3.3"))
;;;###autoload
(defun evilnc-default-hotkeys (&optional no-evil-keybindings)
diff --git a/pkg.sh b/pkg.sh
index 851a0a71e8..3cea9135c8 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,6 +1,6 @@
#!/bin/bash
name=evil-nerd-commenter
-version=2.3.2
+version=2.3.3
pkg=$name-$version
mkdir $pkg
cp *.el $pkg
- [nongnu] elpa/evil-nerd-commenter 3ab19bfa4e 052/235: updated README, (continued)
- [nongnu] elpa/evil-nerd-commenter 3ab19bfa4e 052/235: updated README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter c41c462d50 065/235: clean the doc v1.2.8, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter d11aab5454 071/235: tweak README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter b976b45063 073/235: fixed regression bug in 1.3.0, v1.3.1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 31c6e05c89 081/235: updated README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 41910491e7 101/235: updated README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter e7f57427be 109/235: Fixes #45, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 966435bf25 129/235: warn on comment operations NOT implemented in web-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 981c80bb53 131/235: can comment the line mixed with html and snippet, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter d61c6629b4 132/235: updated doc, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 01a98a20c5 144/235: users choose the style they prefer when copy and comment,
ELPA Syncer <=
- [nongnu] elpa/evil-nerd-commenter 92bee71aa6 159/235: fixed typo, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter ef4d595e18 180/235: Modify evilnc--operation-on-lines-or-region for visual line numbers., ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 44b6fd8e09 173/235: add missing require statement, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 4bf2a84ba5 189/235: prefer org-src-lang-modes over language property of org src, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 151ac57475 178/235: fix bugs on commenting html paragraph, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 4f83773eee 190/235: add test for org-land-major-mode needing org-src-lang-modes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter acc0f75cde 192/235: comment in org-src-block will not collapse node, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 27d8fe0bf0 194/235: fixed CI, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 7132693a4c 196/235: fixed test warning, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter f9d2da93de 204/235: inside org src block cursor move after comment, ELPA Syncer, 2022/01/06