emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/evil-nerd-commenter 966435bf25 129/235: warn on comment op


From: ELPA Syncer
Subject: [nongnu] elpa/evil-nerd-commenter 966435bf25 129/235: warn on comment operations NOT implemented in web-mode
Date: Thu, 6 Jan 2022 02:59:41 -0500 (EST)

branch: elpa/evil-nerd-commenter
commit 966435bf2537a6662d07e13182acaf5d338ed8b3
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>

    warn on comment operations NOT implemented in web-mode
---
 README.org             |  2 +-
 evil-nerd-commenter.el | 26 +++++++++++++++++---------
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/README.org b/README.org
index 24da9a76ab..1093a9abc4 100644
--- a/README.org
+++ b/README.org
@@ -181,7 +181,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 , *including web-mode*)
+Example 7: ",,it", comment the region inside html tags (all html major modes 
are supported , *including [[http://web-mode.org/][web-mode]]*)
 
 * Tips
 ** Tip 1, Yank in evil-mode
diff --git a/evil-nerd-commenter.el b/evil-nerd-commenter.el
index 8b9b152c3b..4e45f0ef02 100644
--- a/evil-nerd-commenter.el
+++ b/evil-nerd-commenter.el
@@ -293,8 +293,7 @@ Code snippets embedded in Org-mode is identified and right 
`major-mode' is used.
       (setq lang (or (cdr (assoc (nth 2 info) org-src-lang-modes))
                      (nth 2 info)))
       (setq lang (if (symbolp lang) (symbol-name lang) lang))
-      (setq lang-f (intern (concat lang "-mode")))
-      )
+      (setq lang-f (intern (concat lang "-mode"))))
 
     ;; turn on 3rd party language's major-mode temporarily
     (if lang-f (funcall lang-f))
@@ -318,6 +317,15 @@ Code snippets embedded in Org-mode is identified and right 
`major-mode' is used.
       (goto-char pos))
     ))
 
+(defun evilnc--warn-on-web-mode (is-comment)
+  (let ((comment-operation (concat "web-mode-"
+                                   (if is-comment "comment-" "uncomment-")
+                                   web-mode-engine
+                                   "-block")))
+    (unless (intern-soft comment-operation)
+      (message "defun %s NOT implemented in web-mode! DIY or raise issue to 
its maintainer."
+               comment-operation))))
+
 (defun evilnc--comment-or-uncomment-region (beg end)
   "Comment or uncommment region from BEG to END."
   (cond
@@ -335,22 +343,22 @@ Code snippets embedded in Org-mode is identified and 
right `major-mode' is used.
            (save-excursion
              (goto-char end)
              (back-to-indentation)
-             (evilnc--web-mode-is-comment))
-           )
+             (evilnc--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))
-      )
+      (evilnc--warn-on-web-mode nil)
+      (web-mode-uncomment (/ (+ beg end) 2)))
      (t
       (unless (region-active-p)
         (push-mark beg t t)
         (goto-char end))
+      (evilnc--warn-on-web-mode t)
       (web-mode-comment (/ (+ beg end) 2)))
      ))
-    (t
-     (evilnc--working-on-region beg end 'comment-or-uncomment-region))
-    ))
+   (t
+    (evilnc--working-on-region beg end 'comment-or-uncomment-region))
+   ))
 
 (defun evilnc--current-line-num ()
   "Get current line number."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]