From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?utf-8?Q?Jostein=20Kj=C3=B8nigsen?= Newsgroups: gmane.emacs.devel Subject: Regarding Emacs, js.el, template-strings and syntax-tables Date: Thu, 24 Aug 2017 08:56:07 +0200 Message-ID: <1503557767.41308.1083341824.4A2103C1@webmail.messagingengine.com> Reply-To: jostein@kjonigsen.net NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_----------=_1503557767413080" Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1503557787 4955 195.159.176.226 (24 Aug 2017 06:56:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 24 Aug 2017 06:56:27 +0000 (UTC) Cc: ldd@lddubeau.com To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 24 08:56:20 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dkm3r-0000d2-3L for ged-emacs-devel@m.gmane.org; Thu, 24 Aug 2017 08:56:15 +0200 Original-Received: from localhost ([::1]:46937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkm3x-0005vf-Th for ged-emacs-devel@m.gmane.org; Thu, 24 Aug 2017 02:56:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkm3q-0005vG-UB for emacs-devel@gnu.org; Thu, 24 Aug 2017 02:56:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkm3n-0003p5-Qs for emacs-devel@gnu.org; Thu, 24 Aug 2017 02:56:14 -0400 Original-Received: from out2-smtp.messagingengine.com ([66.111.4.26]:35299) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkm3n-0003mf-E8 for emacs-devel@gnu.org; Thu, 24 Aug 2017 02:56:11 -0400 Original-Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id F012720BF3; Thu, 24 Aug 2017 02:56:07 -0400 (EDT) Original-Received: from web5 ([10.202.2.215]) by compute6.internal (MEProxy); Thu, 24 Aug 2017 02:56:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= secure.kjonigsen.net; h=cc:content-transfer-encoding :content-type:date:from:message-id:mime-version:reply-to:subject :to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=Qe6nc79M1aWfx1 S0KQn2UmhZx4ebwrKWcB+CHUmLPeo=; b=EdfFMNcx3KDoGJNHK7yV+nH/PfD9Iv oSt2PRFG3+CcwGBu46yJoQk2hbNJiMn2HbBg4ni9tu4LIwASOHTCde4gIOejrco3 uACyErdDkxjQ606EaMqjKhkz128j4qmIXXW/drTP5YuLLLBMFYUq9FSDWf3MZGWY McUj6v0q2gi12iOwUbWTOaiOCxPs01JUfX/OfYbTpQEjUrVuXcfCAi5D7bcIgHqU 8xMnysFu5iHGnLZGEqLkY2NxJmCMyqn4SYEC73td7ixBprXqQOnW26+lLKkMyOib /sKJ/uxEk75E4qMhblFPpFGxte6WyeELOIySmDjgkPB4QRcIoagNyduQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:reply-to:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=Qe6nc79M1aWfx1S0K Qn2UmhZx4ebwrKWcB+CHUmLPeo=; b=SooSOGM5xKVWpvT3h3zAteoCLTIXtFTc1 yabEh5+X9arwZMs3YDm/mWg6d30jnwKoXB1ElgRczDQY8TNBNDhxvJMMLaRZc2Sm ELr6WSsRyHkyOkeQff3WAcgU/DopgMD4mchGvpxLedbFeLUYKmHL6ZVJUFTFWotV VmRCnkc/7HvjIlUzFX38M6CoSUEFtAifsEKW4mn1POL9k3FwpPk8BdYnv5yGfI92 menxrpn2a2dWoTRpIYeDTltgIcm2c/A+Q9rH9lnS2+B3C+x2RVfMTaKMXKs0cAXr PvqgOqB4WY8FdkqdICdQdSljBHfje7cngqNlcAW1IlFUUGq8i1DWg== X-ME-Sender: Original-Received: by mailuser.nyi.internal (Postfix, from userid 99) id C86FB9E2E8; Thu, 24 Aug 2017 02:56:07 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface - ajax-13b5a8c9 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.26 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:217752 Archived-At: This is a multi-part message in MIME format. --_----------=_1503557767413080 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Hey everyone. First off, while the subject of the examples employed in this email are all related to ECMAScript, the kind of syntax-statements discussed is in no way new or unique to ECMAScript. Off hand I know at least TypeScript and C# supports this too, not to mention many web-based templating languages, like Jekyll. But everyone seems to love JavaScript, so lets use that as an example. Newer version of ECMAScript supports in-string templating. That is, you can escape the string-sequence and insert computational expressions inside the string-literal. This allows a cleaner syntax than composing the string using concatenation. As an example, instead of: > function getGreeting(name) { > let greeting =3D "Hello, " + name + "!"; > return greeting; > } you can write: > function getGreeting(name) { > let greeting =3D `Hello, ${name}!`; > return greeting; > } For more details on this feature, MDN has a good write-up[1].=20 Now for the problem: >From what I can see js.el does not support this new syntax yet, so that everything inside the string is treated (and highlighted) semantically as a string. Another area where similar problems exist, but with comments (as opposed to string) is JSDoc[2]. In combination with other minor-modes like flyspell-prog-mode which spell- checks strings and comments, this can quickly get annoying. It also means syntax-based analysis for things like auto-completion will simply not trigger. This is a problem many major-modes needs to handle (as such I'm here speaking as a package maintainer for MELPA package typescript.el). It would be nice if Emacs at its core had mechanisms which made supporting this kind of syntax easier. Fundamentally, we would need a way to escape an on-going string or comment, and end that escape-sequence until either we have a new escape- sequence or the original string/comment delimiter to finally terminate the string/comment. To the best of my knowledge, and please correct me if I'm wrong, this all involves fundamental syntax, and it would be best to handle this with syntax-tables if possible. But last time I read the documentation on syntax-tables, there was no way for to escape ongoing strings or comments using syntax-tables (and again, please correct me if I'm wrong!) I'm sure if Emacs supported this at its core, it would be much easier in major-mode implementations to support these kind of syntaxes. Is any work being done to extend syntax-tables to support this? Is any work being done to support template-strings in js.el? -- Cheers Jostein Kj=C3=B8nigsen jostein@kjonigsen.net =F0=9F=8D=B5 jostein@gmail.com https://jostein.kjonigsen.net Links: 1. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Temp= late_literals 2. http://usejsdoc.org/about-getting-started.html --_----------=_1503557767413080 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="utf-8"
Hey everyone.

First off, while the subject of the examples employed in this email ar= e all related to ECMAScript, the kind of syntax-statements discussed is in = no way new or unique to ECMAScript. Off hand I know at least TypeScript and= C# supports this too, not to mention many web-based templating languages, = like Jekyll.

But everyone seems to love JavaScript, so lets use that as an example.= Newer version of ECMAScript supports in-string templating. That is, you ca= n escape the string-sequence and insert computational expressions inside th= e string-literal. This allows a cleaner syntax than composing the string us= ing concatenation.

As an example, instead of:

function getGreeting(name) {
    let greeting =3D "Hello, " + name + "!";
    return greeting;
}

you can write:

function getGreeting(name) {
    let greeting =3D `Hello, ${name}!`;
    return greeting;
}

For more details on this feature, MDN has a good = write-up.

Now for the problem:

From what I can see js.el does not support this new syntax yet, so tha= t everything inside the string is treated (and highlighted) semantically as= a string. Another area where similar problems exist, but with comments (as= opposed to string) is JSDoc.

In combination with other minor-modes like flyspell-prog-mode which sp= ell-checks strings and comments, this can quickly get annoying. It also mea= ns syntax-based analysis for things like auto-completion will simply not tr= igger.

This is a problem many major-modes needs to handle (as such I'm here s= peaking as a package maintainer for MELPA package typescript.el). It would = be nice if Emacs at its core had mechanisms which made supporting this kind= of syntax easier.

Fundamentally, we would need a way to escape an on-going string or com= ment, and end that escape-sequence until either we have a new escape-sequen= ce or the original string/comment delimiter to finally terminate the string= /comment.

To the best of my knowledge, and please correct me if I'm wrong, this = all involves fundamental syntax, and it would be best to handle this with s= yntax-tables if possible. But last time I read the documentation on syntax-= tables, there was no way for to escape ongoing strings or comments using sy= ntax-tables (and again, please correct me if I'm wrong!)

I'm sure if Emacs supported this at its core, it would be much easier = in major-mode implementations to support these kind of syntaxes.

Is any work being done to extend syntax-tables to support this?

Is any work being done to support template-strings in js.el?

--
Cheers=
Jostein Kj=C3=B8nigsen



--_----------=_1503557767413080--