Permalink
Browse files

first import

  • Loading branch information...
0 parents commit b4fcadabd9ae56dc878c63e0078b08a0d3dd319b @redguardtoo committed Jan 7, 2013
Showing with 141 additions and 0 deletions.
  1. +26 −0 .gitignore
  2. +42 −0 README.org
  3. +2 −0 evil-nerd-commenter-pkg.el
  4. +60 −0 evil-nerd-commenter.el
  5. +11 −0 pkg.sh
@@ -0,0 +1,26 @@
+### /Users/cb/.gitignore-boilerplates/Global/Emacs.gitignore
+
+*~
+\#*\#
+/.emacs.desktop
+/.emacs.desktop.lock
+.elc
+auto-save-list
+tramp
+.\#*
+
+# Org-mode
+.org-id-locations
+*_archive
+
+
+### /Users/cb/.gitignore-boilerplates/Global/Vim.gitignore
+
+.*.sw[a-z]
+*.un~
+Session.vim
+.netrwhist
+
+*.tar
+*.elc
+
@@ -0,0 +1,42 @@
+* evil-nerd-commenter (current version 0.0.1)
+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.
+* 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.
+
+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.
+* Usage
+Example 1:
+"M-x evilnc-comment-or-uncomment-lines" comment/uncomment current line.
+
+Example 2:
+"C-u NUM M-x evilnc-comment-or-uncomment-lines" comment/uncomment next NUM lines.
+
+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.
+
+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).
+* Contact me
+You can report bugs at [[https://github.com/redguardtoo/evil-nerd]]-commenter. My email is <chenbin DOT sh AT gmail>.
+* License
+Copyright (C) 2012 Chen Bin
+
+Author: Chen Bin <chenbin DOT sh AT gmail DOT com
+
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this program. If not, see [[http://www.gnu.org/licenses/]].
+
@@ -0,0 +1,2 @@
+(define-package "evil-nerd-commenter" "0.0.1"
+ "Comment/uncomment lines efficiently. Like Nerd Commenter in Vim")
@@ -0,0 +1,60 @@
+;;; evil-nerd-commenter --- Comment/uncomment lines efficiently. Like Nerd Commenter in Vim
+
+;; Copyright (C) 2012 Chen Bin
+;; Author: Chen Bin <chenbin.sh@gmail.com>
+;; URL: http://github.com/redguardtoo/evil-nerd-commenter
+;; Keywords: commenter vim line evil
+;; Version: 0.0.1
+
+;; 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.
+
+;;; Code:
+
+;;;###autoload
+(defun evilnc-comment-or-uncomment-lines (&optional NUM)
+ "Comment or uncomment lines.
+ Case 1: If no region selected, comment/uncomment on current line. if NUM>1, comment/uncomment
+ extra N-1 lines from next line
+ Case 2: If a region selected, the region is expand to make sure the region contain
+ whole lines. Then we comment/uncomment the expanded region. NUM is ignored."
+ (interactive "p")
+ (if (not (region-active-p))
+ (let ((b (line-beginning-position))
+ e)
+ (save-excursion
+ (forward-line (- NUM 1))
+ (setq e (line-end-position))
+ (comment-or-uncomment-region b e)
+ )
+ )
+ ;; expand selected region
+ (save-excursion
+ (let ((b (region-beginning))
+ (e (region-end))
+ )
+ (goto-char b)
+ (setq b (line-beginning-position))
+ (goto-char e)
+ (setq e (line-end-position))
+ (comment-or-uncomment-region b e)))
+ ))
+
+;;;###autoload
+(defun evilnc-default-hotkeys ()
+ "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
+ (if (fboundp 'evil-leader/set-key)
+ ;; same as nerd commenter in vim
+ (evil-leader/set-key "ci" 'evilnc-comment-or-uncomment-lines))
+ )
+
+(provide 'evil-nerd-commenter)
11 pkg.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+pkg=evil-nerd-commenter-0.0.1
+mkdir $pkg
+cp README.org $pkg
+cp *.el $pkg
+if [[ `uname -s` == *Darwin* ]]; then
+ COPYFILE_DISABLE="" tar cvf $pkg.tar $pkg/
+else
+ tar cvf $pkg.tar $pkg/
+fi
+rm -rf $pkg/

0 comments on commit b4fcada

Please sign in to comment.