From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christian Jauvin Newsgroups: gmane.emacs.devel Subject: Re: Commenting out some JSX code section with Emacs 27 js-mode Date: Fri, 2 Oct 2020 17:01:08 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000126af905b0b670b5" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16987"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Oct 02 23:02:51 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kOSCY-0004J2-9R for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Oct 2020 23:02:50 +0200 Original-Received: from localhost ([::1]:52454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOSCX-0003Xc-8y for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Oct 2020 17:02:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOSBP-00033I-EN for emacs-devel@gnu.org; Fri, 02 Oct 2020 17:01:39 -0400 Original-Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:54894) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kOSBN-0001W8-2V for emacs-devel@gnu.org; Fri, 02 Oct 2020 17:01:39 -0400 Original-Received: by mail-pj1-x1034.google.com with SMTP id j19so1716099pjl.4 for ; Fri, 02 Oct 2020 14:01:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=De2rHwom6+GENvK5RhEDdDhxWpPBn84j9K/vNb3Kjtw=; b=kGMecS0DuMU+2xeq4hkL4b684VRNaYwpemMSkhEksHfuz6LH/8VT9KhfUqjZwwB0C8 etJWp4aNBzvwyXGLr4c4VIsL/ygoT2c1XMfs8xBid2ckNkNYN47+7P4G7BYx5i4VbY6K eiVggPyc+tKWrK71BRZhoNwqfLC/B22clYdD1a5Dun5ET4mwu5HN4bA4yPKmWjeIuPhG dB0dRa/t+X7Bq+UDgS03yzZlupInAvcGj0wnlce8t6EkwG8Txll6wuk8jc1NGAYLqA6q 0BQt0Bt9B8er63JA51EyKTKLZycG/q319ahycO31OVXpjZNQ9IwALum6FapIJdgTxgGT gKYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=De2rHwom6+GENvK5RhEDdDhxWpPBn84j9K/vNb3Kjtw=; b=ghUvI/VIzCk/USVBJ0rvkVR+5mOT4hpGcSYu7bTt5zkQiJQqq37rH/oE/0fped4FbY Xd2sHBSk6nW7EzXcPdL2YsydWeI2ofUzCYZBgBF0YOppOyeMll/KGb5VovjEdwrPFoyR s+S/O0eaJcMLXCqhc4ysehppcVhirABUUhvCTPLr1WiwMusRILauewQF75ViymTcGWLz iych3j6EXfrYT5tEG7zWsHjfhwXZxMV6hi7apiff1AOoRoRCf49rNnfjwfiMBvsvnvtr hu5j5d0OEVivxg4kdDV8fZRA1BsMiLPKBaYHhy1VtsIfaFEQ2NtN/uvceNuWwKqAMXbU K+PA== X-Gm-Message-State: AOAM5336mjOuD42rTlPi0p1iwofpvh6t5Ftx71MNW7V5W33V0E3Oj/Ms vCIpJQpFbaCAsC+8mFxZa9eNgOTZF1wELkNcYOY= X-Google-Smtp-Source: ABdhPJx/jWKzW9Ycceqm7OZB8C2M8ooL0eoMw6nozafEsTOAvREXdsnuEUHZh6C073UEdZcTV/EXn1udzmPVfO4Q9Uo= X-Received: by 2002:a17:90a:f310:: with SMTP id ca16mr1030659pjb.223.1601672494343; Fri, 02 Oct 2020 14:01:34 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=cjauvin@gmail.com; helo=mail-pj1-x1034.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:256973 Archived-At: --000000000000126af905b0b670b5 Content-Type: text/plain; charset="UTF-8" > > (add-hook 'js-mode-hook > (lambda () > (setq-local comment-start "{/* ") > (setq-local comment-end " */}"))) > It now works for JSX, but breaks on regular JS code (inside the same .jsx file): const [open, setOpen] = React.useState(false); const [options, setOptions] = React.useState([]); becomes: {/* const [open, setOpen] = React.useState(false); */} {/* const [options, setOptions] = React.useState([]); */} Would there be a way for the comment function to know whether it is in a JSX block or not, and act accordingly? --000000000000126af905b0b670b5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
(add-hook 'js-mode-hook
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (lambda ()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq-local comment-start "{= /* ")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq-local comment-end=C2=A0 =C2= =A0" */}")))

It now works for= JSX, but breaks on regular JS code (inside the same .jsx file):
=
const [open, setOpen] =3D React.useState(false);
const [o= ptions, setOptions] =3D React.useState([]);

be= comes:

{/* const [open, setOpen] =3D React.useStat= e(false); */}
{/* const [options, setOptions] =3D React.useState([]); */= }

Would there be a way for the comment functio= n to know whether it is in a JSX block or not, and act accordingly?



--000000000000126af905b0b670b5--