[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-nerd-commenter 981c80bb53 131/235: can comment the li
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-nerd-commenter 981c80bb53 131/235: can comment the line mixed with html and snippet |
Date: |
Thu, 6 Jan 2022 02:59:41 -0500 (EST) |
branch: elpa/evil-nerd-commenter
commit 981c80bb53384f93987d03c1b307767f2a68791a
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
can comment the line mixed with html and snippet
---
README.org | 10 +++++--
evil-nerd-commenter-operator.el | 2 +-
evil-nerd-commenter-pkg.el | 2 +-
evil-nerd-commenter.el | 61 +++++++++++++++++++++++++++++------------
pkg.sh | 2 +-
5 files changed, 54 insertions(+), 23 deletions(-)
diff --git a/README.org b/README.org
index e1e6fc33b0..cd3993648f 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-nerd-commenter (v2.2)
+* evil-nerd-commenter (v2.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]]
@@ -93,6 +93,8 @@ copy and paste lines, then comment out original lines. This
command supports neg
The hotkey is ",cc" in evil-mode and "C-c c" in emacs normal mode.
+*** evilnc-comment-or-uncomment-to-the-line
+Comment to the specified line. evilnc-quick-comment-or-uncomment-to-the-line
may be better alternative.
*** evilnc-toggle-comment-empty-lines
toggle the flag to comment/uncomment empty lines.
@@ -128,8 +130,10 @@ For example:
(global-set-key (kbd "C-c C-t C-l") 'evilnc-kill-to-line)
#+END_SRC
-*** evilnc-comment-or-uncomment-to-the-line
-Comment to the specified line. evilnc-quick-comment-or-uncomment-to-the-line
may be better alternative.
+*** evilnc-comment-both-snippet-html
+If a line is snippet wrapped HTML tags in HTML template, only the HTML syntax
is used to comment out the line by default.
+
+But if you `(setq evilnc-comment-both-snippet-html t)`, snippet will be
commented out with its own syntax at first. Then the wrapped html tag will be
comment out using HTML syntax. This flag has effect on all above commands.
[[http://web-mode.org/][Web-mode]] should be enabled to use this flag.
** Examples
*** Comment lines
diff --git a/evil-nerd-commenter-operator.el b/evil-nerd-commenter-operator.el
index 653d5b7c71..272fe4063a 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.2
+;; Version: 2.3
;; Keywords: commenter vim line evil
;;
;; This file is not part of GNU Emacs.
diff --git a/evil-nerd-commenter-pkg.el b/evil-nerd-commenter-pkg.el
index df262ba7c4..62c041537b 100644
--- a/evil-nerd-commenter-pkg.el
+++ b/evil-nerd-commenter-pkg.el
@@ -1,2 +1,2 @@
-(define-package "evil-nerd-commenter" "2.2"
+(define-package "evil-nerd-commenter" "2.3"
"Comment/uncomment lines efficiently. Like Nerd Commenter in
Vim")
diff --git a/evil-nerd-commenter.el b/evil-nerd-commenter.el
index 8d75b51993..04ee1d7d4f 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.2
+;; Version: 2.3
;; Keywords: commenter vim line evil
;;
;; This file is not part of GNU Emacs.
@@ -50,15 +50,13 @@
;; code from current line to line 99 if you current line is 91.
;;
;; Though this program could be used *independently*, though I highly recommend
-;; using it with Evil (http://gitorious.org/evil)
+;; using it with Evil (https://bitbucket.org/lyro/evil/)
;;
;; Evil makes you take advantage of power of Vi to comment lines.
;; For example, you can press key `99,ci` to comment out 99 lines.
;;
;; Setup:
;;
-;; Check https://github.com/redguardtoo/evil-nerd-commenter for more use cases.
-;;
;; Use case 1,
;; If you use comma as leader key, as most Vim users do, setup is one liner,
;; (evilnc-default-hotkeys)
@@ -81,6 +79,8 @@
;; "cv" 'evilnc-toggle-invert-comment-line-by-line
;; "\\" 'evilnc-comment-operator
;; )
+;;
+;; See https://github.com/redguardtoo/evil-nerd-commenter for more use cases.
;;; Code:
@@ -90,6 +90,10 @@
"If t then invert region comment status line by line.
Please note it has NOT effect on evil text object!")
+(defvar evilnc-comment-both-snippet-html nil
+ "Comment both embedded snippet and HTML tag if they are mixed in one line.
+`web-mode' required.")
+
(defun evilnc--count-lines (beg end)
"Assume BEG less than END."
(let (rlt)
@@ -110,8 +114,8 @@ Please note it has NOT effect on evil text object!")
(forward-line (1- line-num)))))
(defun evilnc--web-mode-is-comment (&optional pos)
- "Since `web-mode' remote the API we use, we have to create our own.
-Check whether the code at POS is comment."
+ "Check whether the code at POS is comment.
+`web-mode' removes its API, so create our own."
(unless pos (setq pos (point)))
(not (null (or (eq (get-text-property pos 'tag-type) 'comment)
(eq (get-text-property pos 'block-token) 'comment)
@@ -124,7 +128,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.2:
+ ;; See code in (defun comment-search-forward) from emacs 24.2.3:
;; (if (not comment-use-syntax)
;; (if (re-search-forward comment-start-skip limit noerror)
;; (or (match-end 1) (match-beginning 0)))
@@ -354,16 +358,39 @@ Code snippets embedded in Org-mode is identified and
right `major-mode' is used.
rlt))
(defun evilnc--web-mode-do-current-line ()
- "In web-mode, you have to select the whole before comment or uncomment it."
- (let (line-mid-pos
- (b (line-beginning-position))
- (e (line-end-position)))
+ "In `web-mode', have to select whole line to comment."
+ (let (first-char-is-snippet e)
(save-excursion
- (push-mark e t t)
- (goto-char b)
- (evilnc--warn-on-web-mode (evilnc--web-mode-is-region-comment b e))
- (web-mode-comment-or-uncomment))))
+ (goto-char (line-beginning-position))
+ (skip-chars-forward "[:space:]" (line-end-position))
+ (setq first-char-is-snippet (get-text-property (point) 'block-side)))
+
+ ;; comment the snippet block at first
+ (when (and evilnc-comment-both-snippet-html (not first-char-is-snippet))
+ (save-excursion
+ (let (fired)
+ (goto-char (line-beginning-position))
+ ;; please note (line-beginning-position) is changing in (while)
+ (while (< (point) (line-end-position))
+ (forward-char)
+ (if (get-text-property (point) 'block-side)
+ (when (not fired)
+ (save-excursion
+ (push-mark (1+ (point)) t t)
+ (goto-char (point))
+ (web-mode-comment-or-uncomment))
+ (setq fired t))
+ (setq fired nil))))))
+
+ ;; comment the html line
+ ;; To comment one line ONLY, you need select a line at first,
+ ;; in order to work around web-mode "feature".
+ (push-mark (setq e (line-end-position)) t t)
+ (goto-char (line-beginning-position))
+ (skip-chars-forward "[:space:]" e)
+ (evilnc--warn-on-web-mode (evilnc--web-mode-is-region-comment (point) e))
+ (web-mode-comment-or-uncomment)))
(defun evilnc--web-mode-comment-or-uncomment (beg end)
"Comment/uncomment line by line from BEG to END.
@@ -371,7 +398,7 @@ DO-COMMENT decides we comment or uncomment."
;; end will change when you comment line by line
(let (line-cnt tmp)
- ;; switch beg end if needed
+ ;; make sure beg <= end
(when (> beg end)
(setq tmp beg)
(setq beg end)
@@ -618,7 +645,7 @@ Then we operate the expanded region. NUM is ignored."
(defun evilnc-version ()
"The version number."
(interactive)
- (message "2.2"))
+ (message "2.3"))
;;;###autoload
(defun evilnc-default-hotkeys ()
diff --git a/pkg.sh b/pkg.sh
index 6cee61dc3f..f22fe02f7e 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-pkg=evil-nerd-commenter-2.2
+pkg=evil-nerd-commenter-2.3
mkdir $pkg
cp README.org $pkg
cp *.el $pkg
- [nongnu] elpa/evil-nerd-commenter 1cec61caac 038/235: Removed redundant double information, (continued)
- [nongnu] elpa/evil-nerd-commenter 1cec61caac 038/235: Removed redundant double information, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 1f32941bce 047/235: v1.2.0, ELPA Syncer, 2022/01/06
- [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 <=
- [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, 2022/01/06
- [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