From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#24896: JSX prop indentation after fat arrow Date: Sun, 15 Jan 2017 05:04:51 +0300 Message-ID: <79cc5841-8480-b2fd-eeb7-ff2bf33a0e68@yandex.ru> References: <6d48deda-1d14-2d50-ca86-c89f35bf37db@yandex.ru> <77f1f91d-2f8c-0509-7a16-50bae68f3883@jacksonrayhamilton.com> <447f307f-e226-e6a5-f62a-88bcdcda74df@yandex.ru> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1484446002 11038 195.159.176.226 (15 Jan 2017 02:06:42 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 15 Jan 2017 02:06:42 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:51.0) Gecko/20100101 Thunderbird/51.0 Cc: 24896@debbugs.gnu.org, Jackson Ray Hamilton To: Felipe Ochoa Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jan 15 03:06:37 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1cSaD0-0000La-ET for geb-bug-gnu-emacs@m.gmane.org; Sun, 15 Jan 2017 03:06:14 +0100 Original-Received: from localhost ([::1]:50011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cSaD2-0006Qe-2j for geb-bug-gnu-emacs@m.gmane.org; Sat, 14 Jan 2017 21:06:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cSaCr-0006Nj-Vt for bug-gnu-emacs@gnu.org; Sat, 14 Jan 2017 21:06:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cSaCo-0000Pm-Pl for bug-gnu-emacs@gnu.org; Sat, 14 Jan 2017 21:06:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38889) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cSaCo-0000PY-KZ for bug-gnu-emacs@gnu.org; Sat, 14 Jan 2017 21:06:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cSaCo-0005BC-Af for bug-gnu-emacs@gnu.org; Sat, 14 Jan 2017 21:06:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Jan 2017 02:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24896 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24896-submit@debbugs.gnu.org id=B24896.148444590219838 (code B ref 24896); Sun, 15 Jan 2017 02:06:02 +0000 Original-Received: (at 24896) by debbugs.gnu.org; 15 Jan 2017 02:05:02 +0000 Original-Received: from localhost ([127.0.0.1]:54288 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cSaBq-00059m-4h for submit@debbugs.gnu.org; Sat, 14 Jan 2017 21:05:02 -0500 Original-Received: from mail-lf0-f68.google.com ([209.85.215.68]:33828) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cSaBo-00059Q-Ho for 24896@debbugs.gnu.org; Sat, 14 Jan 2017 21:05:01 -0500 Original-Received: by mail-lf0-f68.google.com with SMTP id q89so9232600lfi.1 for <24896@debbugs.gnu.org>; Sat, 14 Jan 2017 18:05:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=/QIAX4tC4v0RHaKrwZLdPpo7AAYUWcI9YJg66Uqx4mk=; b=prZorZ3MyGKbBC8pXNHScTXv81FDylaVBi0Xlq5pk0ibr2jF3LLQ9Vpl/b4YQhZ6hW pBiGh8X0jo9xDB6vd720J3Wn/2kV/NPDOJJQNQQ5TiVDdzsHsoJqbktjgFHbv6E0lKJ/ puGI5zCw9IRpvPV/HNmt3f7VDO4qgIKLEdSim7x5h+XRb1+AIk0Wy/5gEyacbCLdp3pf dKjFnTAa/nYe+9P6FUOW5q/TYDm0vdJTkPjdtV953D30SzQFwcsvoCHlwMSfD8qe8LUq az7eXsX/AYFNjetY9+/MwRvyTlp7sZnr4TtWKzmSB9yrVdZkHCwAzUejHyOvzCzGGn6L DpDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=/QIAX4tC4v0RHaKrwZLdPpo7AAYUWcI9YJg66Uqx4mk=; b=gUi4VbG1rTYOiignK5wW85NMTwHFXZ9zbuymdm6IN4xbvUIdgYZd1OcyqWdSa6Bxz2 bxLcOK8lCh8ASwa7rkoWj5eRgptNz+OsaibKZZ0jodGN7tKGhxVIHSJym+8/B6Js4JWT BUgqil7lcM3zgTNsi8Kz3Bb0XBOhnLqVzAoIXZQwrIgZ7wt5vFWdmufmlqVLF95uMAGe PSSZy/8WyeJuBSZuE7YA1sganPuYBb3dfqirx0DFK2xygSetqUgNkL3WU5BzG2Udrnfz WqF0VjFeBxld1lOATLjEcJZ0/hawjktRlPJh0wK1YSbZGLQUE8ALNEtorEtIreFByW4T /k0Q== X-Gm-Message-State: AIkVDXKK9tmgLH5fvCbmht74Aj6wL6N+R0T4DUkBaTEqgGLynv2xZB6hWBcXxhbLI79iGQ== X-Received: by 10.25.39.4 with SMTP id n4mr3160938lfn.0.1484445894562; Sat, 14 Jan 2017 18:04:54 -0800 (PST) Original-Received: from [192.168.1.174] ([178.252.127.239]) by smtp.googlemail.com with ESMTPSA id k7sm5469755lfe.26.2017.01.14.18.04.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Jan 2017 18:04:53 -0800 (PST) In-Reply-To: Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:128129 Archived-At: On 06.01.2017 20:44, Felipe Ochoa wrote: > So I've thought about this some more, and realized that this won't fix > everything. There are still issues with greater-than and less-than as > binary operators. Inside XML literals, you mean? > Maybe a better idea is to give '{' and '}' comment > syntax ('<' and '>') so that SGML ignores all the bracketed JS stuff. > I've been trialing this with the following: How's your experience so far? > (defvar js-jsx-tag-syntax-table > (let ((table (make-syntax-table sgml-tag-syntax-table))) > (modify-syntax-entry ?\{ "<" table) > (modify-syntax-entry ?\} ">" table) > table)) > > (defun advice-js-jsx-indent-line (orig-fun) > (interactive) > (let ((sgml-tag-syntax-table js-jsx-tag-syntax-table)) > (apply orig-fun nil))) Here's the problem: js-indent-line uses syntax-ppss. sgml-indent-line doesn't (for now), but js-jsx-indent-line calls js-indent-line in certain contexts. And this is a problem because calling syntax-ppss in different contexts with incompatible (paren-wise) syntax tables will make syntax-ppss cache broken, and lead to likewise broken behaviors. So, one thing we could do here is let-bind the variables that constitute syntax-ppss cache around the call to orig-fun (i.e. around the context where we modify the syntax table). Another, somewhat more difficult approach, would be to try to apply the "<" and ">" syntax classes in syntax-propertize-function, only to occurrences of "{" and "}" inside XML literals. That would require knowing where the said literals begin and end, but we do know that somehow already, seeing as we know which indentation function to choose, right? This way we don't depend on syntax-ppss internals (the cache is not really a public API), and reindenting the whole buffer might be faster, because we would keep syntax-ppss cache around more. Still, not sure how much faster that would be in practice.