From: Lars Ingebrigtsen Date: Thu, 22 Oct 2020 13:20:04 +0000 (+0200) Subject: Comment JSX lines using JSX syntax X-Git-Tag: emacs-28.0.90~5486 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=45c1be62a1e92f3e688495880664a13d042e718c;p=emacs.git Comment JSX lines using JSX syntax * lisp/progmodes/js.el (js-jsx--comment-region): New function (bug#41696). (js-jsx-mode): Use it. --- 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