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: Wed, 25 Jan 2017 04:59:59 +0300 Message-ID: <7c472ad4-7a80-3747-3661-3dcdafce2c04@yandex.ru> References: <6d48deda-1d14-2d50-ca86-c89f35bf37db@yandex.ru> <77f1f91d-2f8c-0509-7a16-50bae68f3883@jacksonrayhamilton.com> <447f307f-e226-e6a5-f62a-88bcdcda74df@yandex.ru> <79cc5841-8480-b2fd-eeb7-ff2bf33a0e68@yandex.ru> <004301d2755a$b9f62b30$2de28190$@gmail.com> 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 1485309672 3047 195.159.176.226 (25 Jan 2017 02:01:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 25 Jan 2017 02:01:12 +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 Wed Jan 25 03:01:08 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 1cWCtW-0000E8-Hw for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Jan 2017 03:01:06 +0100 Original-Received: from localhost ([::1]:56829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWCtb-0006XC-Ql for geb-bug-gnu-emacs@m.gmane.org; Tue, 24 Jan 2017 21:01:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWCtV-0006WI-F2 for bug-gnu-emacs@gnu.org; Tue, 24 Jan 2017 21:01:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWCtS-0002nN-Bs for bug-gnu-emacs@gnu.org; Tue, 24 Jan 2017 21:01:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43028) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cWCtS-0002nD-7X for bug-gnu-emacs@gnu.org; Tue, 24 Jan 2017 21:01:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cWCtR-0007us-Qr for bug-gnu-emacs@gnu.org; Tue, 24 Jan 2017 21:01:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Jan 2017 02:01:01 +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.148530960930343 (code B ref 24896); Wed, 25 Jan 2017 02:01:01 +0000 Original-Received: (at 24896) by debbugs.gnu.org; 25 Jan 2017 02:00:09 +0000 Original-Received: from localhost ([127.0.0.1]:41227 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWCsb-0007tK-Eu for submit@debbugs.gnu.org; Tue, 24 Jan 2017 21:00:09 -0500 Original-Received: from mail-lf0-f65.google.com ([209.85.215.65]:36647) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWCsa-0007sJ-EK for 24896@debbugs.gnu.org; Tue, 24 Jan 2017 21:00:08 -0500 Original-Received: by mail-lf0-f65.google.com with SMTP id h65so19035614lfi.3 for <24896@debbugs.gnu.org>; Tue, 24 Jan 2017 18:00:08 -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=uVzS70GzwFc+rYYLHhgCNjDmSH5IwIr7YZzBbQchUM4=; b=LMLp1eQsmE7PRX9W+t76KxX3/Dio1BEAUvf8SYP7jUAbsZOPhZxzPrYrfPii/aSzOa znkTx4I06BgWX3b0LbRZHwv7jj9bprSzaI/UGjQ9f3U2ppAhlH2mMwY8W1mxlT2Rc21v LWfJ8+WQuME4wSh13Lnalzowya2InCLndpCIDuHBBikUAK00Nq3ERLT92XhVCZO1Dlff xjeSbpKVa3Wqb9BYhFLNWhZ8Ru+WS8qPUfiqppomArGe/Q9ejk20B3zpZ0ze+5AHRHig wR2NnuMYS5Rxakwo1MxBagvplNmU/rfEolX4z0g2LIYoQOSnaqKxWn59g3p+zvY61Vrn ZKcg== 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=uVzS70GzwFc+rYYLHhgCNjDmSH5IwIr7YZzBbQchUM4=; b=jCeBgs3DQ+tFOtKCM01tALCjACTcQXptrxr+SMyEIDoliPCUWtZyzRf0Fg0ZuKOf4/ 2RMASJ1gIT+S9pIqNJ8rUQSKabVgGS+aPH6BODI7Sl0Hk1SWu6gUIRGDbq5sARM4bytc MQYImigmIqq/omi4XGZuBIYpn1UzCCLQbuwEhRVqRa8TY2aEifbkEWL8ziuPwFj/OeUI s3pSSsWMqXwH/XdQv9pOJ/aOMjwy2Q9+J0KjXU0/BG7dam3XLl/yBRUBlqTox84Qan1K mLmLAvTlLZVSToK2SOvZ1/9R9TSyKqfniwaIY+yngk+M7W4A60eG+EfItdHcI9LwvvA9 PQsA== X-Gm-Message-State: AIkVDXJMwlJyDByABMe7Vq8XzFxJS3rnO/qu5/ceXDnu6otCdpGfcKVoJ2v2oguINHxqDQ== X-Received: by 10.25.33.21 with SMTP id h21mr10767109lfh.114.1485309601347; Tue, 24 Jan 2017 18:00:01 -0800 (PST) Original-Received: from [192.168.1.174] ([178.252.127.239]) by smtp.googlemail.com with ESMTPSA id n20sm7921989lfn.5.2017.01.24.17.59.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 18:00:00 -0800 (PST) In-Reply-To: <004301d2755a$b9f62b30$2de28190$@gmail.com> 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:128431 Archived-At: On 23.01.2017 12:26, Felipe Ochoa wrote: > It's actually worked very well. I had an issue once where indenting an entire region took several passes to get right, but now I'm not able to reproduce it :( Unreproducible wonky behavior might be the result of busting syntax-ppss cache. > But it seems to me that the js*-mode and sgml-*-mode syntax tables are already incompatible (namely, "<" and ">", which are causing all this grief!). Right. For now, we seem to have avoided the problem because sgml-indent-line does not call syntax-ppss. > Would introducing this additional incompatibility cause more problems? ...so if you change the syntax table just around the call to sgml-calculate-indent (not the whole js-jsx-indent-line), it shouldn't make things worse. > This sounds like a bit of a headache. E.g., indenting a region would require binding and unbinding the cache carefully as you stepped into and out of JSX. What if we just scrap the syntax-ppss cache altogether? Would the performance penalty be too great? Let-binding the cache variables to nil around the call to sgml-calculate-indent might be fast enough, because multiple calls to syntax-ppss (if any) inside that functions will still be amortized. But this is really going to be more useful when sgml-calculate-indent starts using syntax-ppss, which really might never happen. So the previous solution (changing the syntax table only where needed) might be preferable in the meantime. > This is based on a rough heuristic that essentially backtracks looking for "[(,]\n *<" (it also handles comments). This misses any JSX which is not at the start of the line, and it only tells us the start of the tag, not the end or where the body ends. I think sgml-skip-tag-forward could help with the last one. > In js2 and rjsx there is of course the full parser to give us this information. Like Jackson mentioned, probably not a good idea. > I think we could use a regex like the following to identify JSX start tokens: > > (rx (seq (or (any "-+*/%=>) be realistically expected before a JSX literal? And it seems like the << operator would cause a false positive. I like the general direction, though. > We could use a similar regex to find the ">" that close JSX tags: sgml-skip-tag-forward seems like the more reliable option to me. Although it might work worse on invalid code. > Is it possible to run syntax-ppss using different tables for different parts of the buffer? If you perform the previously mentioned cache fiddling, yes. If not, then the answer is maybe, and that depends on how and when you'll be calling it. So maybe you should get into the underlying mechanics first.