branch: elpa/jade-mode
commit c8532a66f600ad3dfc62ae34007091cb5c7f9da6
Author: Shander Lam <[email protected]>
Commit: Shander Lam <[email protected]>

    Support comment-dwim for single line comment syntax.
---
 jade-mode.el | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/jade-mode.el b/jade-mode.el
index 02c1f9f47d..cb02ecd43b 100644
--- a/jade-mode.el
+++ b/jade-mode.el
@@ -25,6 +25,17 @@
   "If line contains only spaces."
   (string-match-p "^[ ]*$" (jade-line-as-string)))
 
+;; command to comment/uncomment text
+(defun jade-comment-dwim (arg)
+  "Comment or uncomment current line or region in a smart way.
+For detail, see `comment-dwim'."
+  (interactive "*P")
+  (require 'newcomment)
+  (let (
+        (comment-start "//") (comment-end "")
+        )
+    (comment-dwim arg)))
+
 (setq jade-font-lock-keywords
       `((,"!!!\\( ?[A-Za-z0-9\-\_]*\\)?" 0 font-lock-comment-face) ;; doctype
         (,"#\\(\\w\\|_\\|-\\)*" . font-lock-variable-name-face) ;; id
@@ -71,6 +82,9 @@
   ;; keymap
   (use-local-map jade-mode-map)
 
+  ;; modify the keymap
+  (define-key jade-mode-map [remap comment-dwim] 'jade-comment-dwim)
+
   ;; highlight syntax
   (setq font-lock-defaults '(jade-font-lock-keywords)))
 

Reply via email to