[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-nerd-commenter 29513d6c3b 004/235: now can comment to
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-nerd-commenter 29513d6c3b 004/235: now can comment to specified line |
Date: |
Thu, 6 Jan 2022 02:59:30 -0500 (EST) |
branch: elpa/evil-nerd-commenter
commit 29513d6c3b4158b0640bf0452e2902bf1b5ed7e3
Author: chen bin <chenbin.sh@gmail.com>
Commit: chen bin <chenbin.sh@gmail.com>
now can comment to specified line
---
README.org | 29 +++++++++++++++++++++-------
evil-nerd-commenter-pkg.el | 2 +-
evil-nerd-commenter.el | 47 ++++++++++++++++++++++++++++++++++++----------
pkg.sh | 2 +-
4 files changed, 61 insertions(+), 19 deletions(-)
diff --git a/README.org b/README.org
index 86edf09656..a6bbaf9b66 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-nerd-commenter (current version 0.0.1)
+* evil-nerd-commenter (current version 0.0.2)
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.
@@ -9,26 +9,41 @@ Say you want to comment out nine lines. Instead pressing
"C-space M-9 C-n M-;",
* Install
cpputils-cmake is already uploaded to [[http://marmalade-repo.org/]]. So the
best way to install it is using Emacs' package manager.
* Set up
-Nothing to set up. There is only one command
"evilnc-comment-or-uncomment-lines". Just use it.
+Nothing to set up.
You may use the hotkeys defined in evil-nerd-commenter by add following line
into ~/.emacs:
#+BEGIN_SRC elisp
(evilnc-default-hotkeys)
#+END_SRC
-The hotkey is "M-;" in emacs normal mode and "<Leader>ci" (",ci") in evil-mode.
+I prefer vi key binds. So I use [[http://emacswiki.org/emacs/Evil][evil-mode]]
and evil-leader.
+
+Here is my configuration for evil-mode:
+#+BEGIN_SRC elisp
+(require 'evil)
+(require 'evil-leader)
+(setq evil-leader/leader "," evil-leader/in-all-states t)
+(evil-leader/set-key
+ "ci" 'evilnc-comment-or-uncomment-lines
+ "cc" 'evilnc-comment-or-uncomment-to-the-line
+ )
+#+END_SRC
* Usage
+These are available commands:
+- evilnc-comment-or-uncomment-lines :: comment/uncomment lines.
+- evilnc-comment-or-uncomment-to-the-line :: comment/uncomment from current
line to the specified line.
+
Example 1:
-"M-x evilnc-comment-or-uncomment-lines" comment/uncomment current line.
+"C-u NUM M-x evilnc-comment-or-uncomment-lines", comment/uncomment next NUM
lines.
Example 2:
-"C-u NUM M-x evilnc-comment-or-uncomment-lines" comment/uncomment next NUM
lines.
+Select a region and "M-x evilnc-comment-or-uncomment-lines". The region will
automatically expand to contain whole lines. Then comment/uncomment the region.
Example 3:
-Select a region and "M-x evilnc-comment-or-uncomment-lines". The region will
automatically expand to contain whole lines. Then comment/uncomment the region.
+If you use [[http://emacswiki.org/emacs/Evil][evil-mode]] and get the package
evil-leader installed. Comment 9 lines could be as easily as type "9<Leader>ci"
(only four keys).
Example 4:
-If you use [[http://emacswiki.org/emacs/Evil][evil-mode]] and get the package
evil-leader installed. Comment 9 lines could be as easily as type "9,ci" (only
four keys).
+"C-u 56 M-x evilnc-comment-or-uncomment-to-the-line", comment/uncomment from
current line to line 56.
* Contact me
You can report bugs at [[https://github.com/redguardtoo/evil-nerd]]-commenter.
My email is <chenbin DOT sh AT gmail>.
* License
diff --git a/evil-nerd-commenter-pkg.el b/evil-nerd-commenter-pkg.el
index 6eac290ce4..cb1b99eb3e 100644
--- a/evil-nerd-commenter-pkg.el
+++ b/evil-nerd-commenter-pkg.el
@@ -1,2 +1,2 @@
-(define-package "evil-nerd-commenter" "0.0.1"
+(define-package "evil-nerd-commenter" "0.0.2"
"Comment/uncomment lines efficiently. Like Nerd Commenter in
Vim")
diff --git a/evil-nerd-commenter.el b/evil-nerd-commenter.el
index fa0885d3e1..0bce1dba07 100644
--- a/evil-nerd-commenter.el
+++ b/evil-nerd-commenter.el
@@ -4,19 +4,50 @@
;; Author: Chen Bin <chenbin.sh@gmail.com>
;; URL: http://github.com/redguardtoo/evil-nerd-commenter
;; Keywords: commenter vim line evil
-;; Version: 0.0.1
+;; Version: 0.0.2
;; This file is not part of GNU Emacs.
;; This file is free software (GPLv3 License)
;; How to set it up:
-;; 1. There is ONLY one command "evilnc-comment-or-uncomment-lines".
-;; 2. "evilnc-default-hotkeys" will assign hotkey "M-;" for emacs normal mode
and "<Leader>ci" for evil-mode.
-;; 3. Calling (evilnc-default-hotkeys) is NOT needed if you define your own
hotkey.
+;; 1. "evilnc-default-hotkeys" will assign hotkey "M-;" for emacs normal mode
and "<Leader>ci" for evil-mode.
+;; 2. Calling (evilnc-default-hotkeys) is NOT needed if you define your own
hotkey.
+;;
+;; How to use:
+;; 1. "evilnc-comment-or-uncomment-lines" - comment/uncomment lines.
+;; 2. "evilnc-comment-or-uncomment-to-the-line" - comment/uncomment from
current line to the specified line
;;; Code:
+;; shamelessly copied from goto-line
+(defun evilnc-goto-line (line)
+ (save-restriction
+ (widen)
+ (goto-char (point-min))
+ (if (eq selective-display t)
+ (re-search-forward "[\n\C-m]" nil 'end (1- line))
+ (forward-line (1- line))))
+ )
+
+;;;###autoload
+(defun evilnc-comment-or-uncomment-to-the-line (&optional LINENUM)
+ "Comment or uncomment from the current line to the LINENUM line"
+ (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)))
+ (comment-or-uncomment-region b e)
+ )
+ )
+ ))
+
;;;###autoload
(defun evilnc-comment-or-uncomment-lines (&optional NUM)
"Comment or uncomment lines.
@@ -51,11 +82,7 @@
"Set the hotkeys of evil-nerd-comment"
(interactive)
(global-set-key "\M-;" 'evilnc-comment-or-uncomment-lines)
- ;; set hot key for evil-mode, package evil-leader is needed
- (eval-after-load 'evil-leader
- '(progn
- ;; same as nerd commenter in vim
- (evil-leader/set-key "ci" 'evilnc-comment-or-uncomment-lines))
- ))
+ (global-set-key "\M-:" 'evilnc-comment-or-uncomment-to-the-line)
+ )
(provide 'evil-nerd-commenter)
diff --git a/pkg.sh b/pkg.sh
index b12ef1c731..7ae5d5fb77 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-pkg=evil-nerd-commenter-0.0.1
+pkg=evil-nerd-commenter-0.0.2
mkdir $pkg
cp README.org $pkg
cp *.el $pkg
- [nongnu] elpa/evil-nerd-commenter 29990d314c 177/235: enable evil text object usage by default, (continued)
- [nongnu] elpa/evil-nerd-commenter 29990d314c 177/235: enable evil text object usage by default, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter a6d492b819 193/235: support inline comment for rust-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 7e48e61207 197/235: Make evilnc-comment-and-copy-operator create only one undo entry, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 16561277ae 200/235: comment html tag in more web templates, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter cc8b254723 216/235: optimize performance, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 2730820b9c 224/235: fixed: evil-copy-and-comment-operator does not copy in visual-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter e32519bc75 231/235: remove travis setup, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 6bc41317ba 233/235: doc, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 2133167e06 232/235: clean code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 63baf2d1c7 235/235: Merge pull request #124 from rafauke/feature/treat-tsx-as-jsx, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 29513d6c3b 004/235: now can comment to specified line,
ELPA Syncer <=
- [nongnu] elpa/evil-nerd-commenter 1a93b64203 016/235: typo in README.org, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 6e560d6956 024/235: no evil-leader, upgraded to 0.0.9, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 8a3b13ed0b 018/235: updated README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 59586d7e0b 027/235: updated doc on comment paragraphs, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter d279beb83d 035/235: Updated description, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter c9d325bb3f 037/235: Moved operator to evil section, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 223d99372d 039/235: Added check for comment operator being bound, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 229ed115d2 041/235: Streamlined evil section, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter c05e0ff2a4 045/235: Added "comment to line" evil example, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 96093a934d 049/235: fixed: eval-expression hotkey occupied, ELPA Syncer, 2022/01/06