From 45c1be62a1e92f3e688495880664a13d042e718c Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Thu, 22 Oct 2020 15:20:04 +0200 Subject: [PATCH] Comment JSX lines using JSX syntax * lisp/progmodes/js.el (js-jsx--comment-region): New function (bug#41696). (js-jsx-mode): Use it. --- lisp/progmodes/js.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 5c50e2accdf..f3cfbbb948f 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -4656,8 +4656,19 @@ could set `js-jsx-syntax' to t in your init file, or in a one of the aforementioned options instead of using this mode." :group 'js (js-jsx-enable) + (setq-local comment-region-function #'js-jsx--comment-region) (js-use-syntactic-mode-name)) +(defun js-jsx--comment-region (beg end &optional arg) + (if (or (js-jsx--context) + (save-excursion + (skip-chars-forward " \t") + (js-jsx--looking-at-start-tag-p))) + (let ((comment-start "{/* ") + (comment-end " */}")) + (comment-region-default beg end arg)) + (comment-region-default beg end arg))) + ;;;###autoload (defalias 'javascript-mode 'js-mode) (eval-after-load 'folding -- 2.39.2