branch: elpa/evil-nerd-commenter
commit a4ef4ec548587a16a27a7725fca68db80e8aac3d
Author: Chen Bin <[email protected]>
Commit: Chen Bin <[email protected]>
document on comment paragraph
---
README.org | 21 +++++++++++++++++++++
evil-nerd-commenter.el | 19 +++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/README.org b/README.org
index 09d7a57a07..cec99eb394 100644
--- a/README.org
+++ b/README.org
@@ -126,6 +126,27 @@ Customize =evilnc-html-comment-end= and
=evilnc-html-comment-end= to use differe
Or you can use =evilnc-comment-or-uncomment-html-paragraphs= to
comment/uncomment paragraphs containing html tags.
Paragraph is text separated by empty lines.
+
+
+Sample to combine =evilnc-comment-or-uncomment-html-paragraphs= and
=evilnc-comment-or-uncomment-paragraphs=:
+#+begin_src elisp
+(defun my-evilnc-comment-or-uncomment-paragraphs (&optional num)
+ "Comment or uncomment NUM paragraphs which might contain html tags."
+ (interactive "p")
+ (unless (featurep 'evil-nerd-commenter) (require 'evil-nerd-commenter))
+ (let* ((paragraph-region (evilnc--get-one-paragraph-region))
+ (html-p (save-excursion
+ (sgml-skip-tag-backward 1)
+ (let* ((line (buffer-substring-no-properties
(line-beginning-position)
+
(line-end-position))))
+ ;; current paragraph does contain html tag
+ (if (and (>= (point) (car paragraph-region))
+ (string-match-p (format "^[ \t]*\\(%s\\)?[
\t]*<[a-zA-Z]+"
+ (regexp-quote
evilnc-html-comment-start)) line))
+ t)))))
+ (if html-p (evilnc-comment-or-uncomment-html-paragraphs num)
+ (evilnc-comment-or-uncomment-paragraphs num))))
+#+end_src
*** evilnc-toggle-comment-empty-lines
Toggle the flag to comment/uncomment empty lines.
diff --git a/evil-nerd-commenter.el b/evil-nerd-commenter.el
index f1a129fe7f..f8b6519d6a 100644
--- a/evil-nerd-commenter.el
+++ b/evil-nerd-commenter.el
@@ -85,6 +85,25 @@
;; `evilnc-comment-or-uncomment-html-paragraphs' comment/uncomment paragraphs
;; containing html tags.
;;
+;; Sample to combine `evilnc-comment-or-uncomment-html-paragraphs' and
+;; `evilnc-comment-or-uncomment-paragraphs':
+;; (defun my-evilnc-comment-or-uncomment-paragraphs (&optional num)
+;; "Comment or uncomment NUM paragraphs which might contain html tags."
+;; (interactive "p")
+;; (unless (featurep 'evil-nerd-commenter) (require 'evil-nerd-commenter))
+;; (let* ((paragraph-region (evilnc--get-one-paragraph-region))
+;; (html-p (save-excursion
+;; (sgml-skip-tag-backward 1)
+;; (let* ((line (buffer-substring-no-properties
(line-beginning-position)
+;;
(line-end-position))))
+;; ;; current paragraph does contain html tag
+;; (if (and (>= (point) (car paragraph-region))
+;; (string-match-p (format "^[ \t]*\\(%s\\)?[
\t]*<[a-zA-Z]+"
+;; (regexp-quote
evilnc-html-comment-start)) line))
+;; t)))))
+;; (if html-p (evilnc-comment-or-uncomment-html-paragraphs num)
+;; (evilnc-comment-or-uncomment-paragraphs num))))
+;;
;; 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',