branch: elpa/evil-nerd-commenter
commit 337c66f37601c0825206976d287e10f8df279d6a
Author: Chen Bin <[email protected]>
Commit: Chen Bin <[email protected]>
web-mode is supported v1.5.0
---
README.org | 4 ++--
evil-nerd-commenter-pkg.el | 2 +-
evil-nerd-commenter.el | 36 +++++++++++++++++++++++++++++++++---
pkg.sh | 2 +-
4 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/README.org b/README.org
index d1e0b7016c..6bc5296d68 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-nerd-commenter (v1.4.0)
+* evil-nerd-commenter (v1.5.0)
*This program could be used independently WITHOUT evil-mode!*
@@ -206,7 +206,7 @@ Example 5: ",,ao" to comment out the current symbol, or
",,aW" to comment out th
Example 6: ",,w" comment to the beginning of the next word, ",,e" to the end
of the next word, ",,b" to the beginning of the previous word.
-Example 7: ",,it", comment the region inside html tags (all html major modes
are supported except web-mode)
+Example 7: ",,it", comment the region inside html tags (all html major modes
are supported , *including web-mode*)
* Tips
** Tip 1, Yank in evil-mode
diff --git a/evil-nerd-commenter-pkg.el b/evil-nerd-commenter-pkg.el
index d3f9881ab6..0a91152109 100644
--- a/evil-nerd-commenter-pkg.el
+++ b/evil-nerd-commenter-pkg.el
@@ -1,2 +1,2 @@
-(define-package "evil-nerd-commenter" "1.4.0"
+(define-package "evil-nerd-commenter" "1.5.0"
"Comment/uncomment lines efficiently. Like Nerd Commenter in
Vim")
diff --git a/evil-nerd-commenter.el b/evil-nerd-commenter.el
index c9a97bab34..da64600677 100644
--- a/evil-nerd-commenter.el
+++ b/evil-nerd-commenter.el
@@ -4,7 +4,7 @@
;; Author: Chen Bin <[email protected]>
;; URL: http://github.com/redguardtoo/evil-nerd-commenter
-;; Version: 1.4.0
+;; Version: 1.5.0
;; Keywords: commenter vim line evil
;;
;; This file is not part of GNU Emacs.
@@ -247,7 +247,37 @@
))
(defun evilnc--comment-or-uncomment-region (beg end)
- (evilnc--working-on-region beg end 'comment-or-uncomment-region))
+ (cond
+ ((string= major-mode "web-mode")
+ ;; web-mode comment only works when region selected
+ ;; uncomment only works when region not selected
+ ;; test three sample point, comment or uncomment
+ (cond
+ ((and (save-excursion
+ (goto-char beg)
+ (goto-char (line-end-position))
+ (web-mode-is-comment))
+ (web-mode-is-comment (/ (+ beg end) 2))
+ (save-excursion
+ (goto-char end)
+ (goto-char (line-beginning-position))
+ (web-mode-is-comment))
+ )
+ ;; don't know why, but we need goto the middle of comment
+ ;; in order to uncomment, or else trailing spaces will be appended
+ (goto-char (/ (+ beg end) 2))
+ (web-mode-uncomment (/ (+ beg end) 2))
+ )
+ (t
+ (when (not (region-active-p))
+ (push-mark beg t t)
+ (goto-char end))
+ (web-mode-comment (/ (+ beg end) 2)))
+ )
+ )
+ (t
+ (evilnc--working-on-region beg end 'comment-or-uncomment-region))
+ ))
(defun evilnc--current-line-num ()
(save-restriction
@@ -471,7 +501,7 @@ Save in REGISTER or in the kill-ring with YANK-HANDLER."
(cond
((eq type 'block)
(let ((newpos (evilnc--extend-to-whole-comment beg end) ))
- (evil-apply-on-block #'comment-or-uncomment-region (nth 0 newpos)
(nth 1 newpos) nil)
+ (evil-apply-on-block #'evilnc--comment-or-uncomment-region (nth 0
newpos) (nth 1 newpos) nil)
)
)
((and (eq type 'line)
diff --git a/pkg.sh b/pkg.sh
index 68e3783578..d902c04914 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-pkg=evil-nerd-commenter-1.4.0
+pkg=evil-nerd-commenter-1.5.0
mkdir $pkg
cp README.org $pkg
cp *.el $pkg