From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Felipe Ochoa Newsgroups: gmane.emacs.bugs Subject: bug#24896: JSX prop indentation after fat arrow Date: Fri, 6 Jan 2017 18:44:43 +0100 Message-ID: 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: multipart/alternative; boundary=001a1135be2cb96f740545709214 X-Trace: blaine.gmane.org 1483724764 29436 195.159.176.226 (6 Jan 2017 17:46:04 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 6 Jan 2017 17:46:04 +0000 (UTC) Cc: 24896@debbugs.gnu.org, Jackson Ray Hamilton To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jan 06 18:45:59 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 1cPYaI-0005WB-57 for geb-bug-gnu-emacs@m.gmane.org; Fri, 06 Jan 2017 18:45:46 +0100 Original-Received: from localhost ([::1]:54248 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPYaK-0002WM-QB for geb-bug-gnu-emacs@m.gmane.org; Fri, 06 Jan 2017 12:45:48 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPYZd-00028B-5z for bug-gnu-emacs@gnu.org; Fri, 06 Jan 2017 12:45:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cPYZZ-0002W9-V0 for bug-gnu-emacs@gnu.org; Fri, 06 Jan 2017 12:45:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58187) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cPYZZ-0002Vi-Qa for bug-gnu-emacs@gnu.org; Fri, 06 Jan 2017 12:45:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cPYZZ-0002CU-Ib for bug-gnu-emacs@gnu.org; Fri, 06 Jan 2017 12:45:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Felipe Ochoa Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 06 Jan 2017 17:45: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.14837246928427 (code B ref 24896); Fri, 06 Jan 2017 17:45:01 +0000 Original-Received: (at 24896) by debbugs.gnu.org; 6 Jan 2017 17:44:52 +0000 Original-Received: from localhost ([127.0.0.1]:45353 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cPYZQ-0002Br-02 for submit@debbugs.gnu.org; Fri, 06 Jan 2017 12:44:52 -0500 Original-Received: from mail-ua0-f176.google.com ([209.85.217.176]:33663) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cPYZN-0002Be-Np for 24896@debbugs.gnu.org; Fri, 06 Jan 2017 12:44:50 -0500 Original-Received: by mail-ua0-f176.google.com with SMTP id i68so307987706uad.0 for <24896@debbugs.gnu.org>; Fri, 06 Jan 2017 09:44:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=GR1z6y94b0MRwhbXuiy6JascDfLC4B4vrOXwA12bQjk=; b=B1eupi4CZbLoBeMBiqxJLvML4qKLX2nZUc0M2+xCRVfPMtS7LuUHo1TvVLTvBEUCTw kj+M6bgXvHUHHBydlOquNCluyu+mOsvstQt9wFSnBoRIzfaHi6JGH76FA23a2Jwu79bp EaGaxIce6ok3NHuBcbQcRk5RGvMDpsn9CEQeRrRM7cehBTjKavG5pyxeXY6sXe18Wv9J 25IBFaDUX481pLwa/EzUHLcrbuFUnDrKkNoPhAriCnDWXCkRUOod5fCQLAnTIZYEqW1K oo34XPos42cRGqSIOLmIpLkUpoGWLuiLs/FVMLQLgbXnUMTz7/V+FCukpAxAvNmyhVRN cUKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=GR1z6y94b0MRwhbXuiy6JascDfLC4B4vrOXwA12bQjk=; b=AcxgujeeOXM5tAZJbRQOENBf/D1IYkwg+aIqiLjm8qvf2g0AVrSNHO9/jjEbh8phD7 z55gU4N1YiBdaNThXYDHRWS9/g/06iLtcw+q4ONgWnjQiFCDkQTOOEORbyo/C1dnFufV 1b0XxsWneDHx/oyt7hJNmDTccgxRQ++XNGpSk/+JZ2PLR0N+SYP/39PFb3IVEQ/Hwlm7 6/7koBO/o0LeZJUHvURwmGyRhHBecDwjXYTcY//acBVD00NqSvkVyRS64ogfNaKykMht yTJOImXXDm80ZRsvBd/bKXYQ4Vi31rhEXt+Vr+VlYlc2wovvwjSwqZtKiz4lPSdMPX6L l0nA== X-Gm-Message-State: AIkVDXJzkaZJfuGE3ZZUuwvVUbEn1Unsh6ktPnG7A1Y/s3HfgXwLUe97DVb1XQlliQBa6CE1+5Py3m1Z0X18VQ== X-Received: by 10.159.34.111 with SMTP id 102mr5811875uad.160.1483724683831; Fri, 06 Jan 2017 09:44:43 -0800 (PST) Original-Received: by 10.176.74.85 with HTTP; Fri, 6 Jan 2017 09:44:43 -0800 (PST) In-Reply-To: <447f307f-e226-e6a5-f62a-88bcdcda74df@yandex.ru> 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:127849 Archived-At: --001a1135be2cb96f740545709214 Content-Type: text/plain; charset=UTF-8 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. 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: (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))) (advice-add 'js-jsx-indent-line :around 'advice-js-jsx-indent-line) and have gotten good results so far. This works for js-mode and js2-mode. If you're both happy with this approach, I'll convert the advice into a patch for `js-jsx-indent-line' and will send along! On Fri, Dec 9, 2016 at 1:18 AM, Dmitry Gutov wrote: > On 08.12.2016 13:12, Felipe Ochoa wrote: > > syntax-propertize-function is outside my limited knowledge of emacs >> internals. But to the extent that one could say "Outside of comments and >> strings, propertize `=>' as punctuation," I imagine that would fix it. >> > > Yes, it can help with that. > > Also, this may be a dumb question, but are the tests in the "manual" >> directory meant to be run manually? If not, how would I run the tests >> there? >> > > You can e.g. 'cd test/manual/indent' and run 'make js-jsx.js.test', to > compare the indentation in js-jsx.js against what the current js.el does. > > And then finally, should I just email a patch with the proposed change & >> tests for this? >> > > An email with a diff attached could be enough. > > But if you wanted to include a "proper" commit message as well, see > CONTRIBUTE in the top directory. > --001a1135be2cb96f740545709214 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
So I've thought about this some more, and realize= d that this won't fix everything. There are still issues with greater-t= han and less-than as binary operators. Maybe a better idea is to give '= {' and '}' comment syntax ('<' and '>') s= o that SGML ignores all the bracketed JS stuff. I've been trialing this= with the following:

(defvar js-jsx-tag-syntax-table
=C2=A0 (let = ((table (make-syntax-table sgml-tag-syntax-table)))
=C2=A0=C2=A0=C2=A0 (= modify-syntax-entry ?\{ "<" table)
=C2=A0=C2=A0=C2=A0 (modi= fy-syntax-entry ?\} ">" table)
=C2=A0=C2=A0=C2=A0 table))
(defun advice-js-jsx-indent-line (orig-fun)
=C2=A0 (interactive)=C2=A0 (let ((sgml-tag-syntax-table js-jsx-tag-syntax-table))
=C2=A0= =C2=A0=C2=A0 (apply orig-fun nil)))

(advice-add 'js-jsx-indent-l= ine :around 'advice-js-jsx-indent-line)

and have gotten go= od results so far. This works for js-mode and js2-mode. If you're both = happy with this approach, I'll convert the advice into a patch for `js-= jsx-indent-line' and will send along!


On Fri, Dec 9, 2016 at 1:1= 8 AM, Dmitry Gutov <dgutov@yandex.ru> wrote:
On 08.12.2016 13:12, Felipe Ochoa wrote:=

syntax-propertize-function is outside my limited knowledge of emacs
internals. But to the extent that one could say "Outside of comments a= nd
strings, propertize `=3D>' as punctuation," I imagine that woul= d fix it.

Yes, it can help with that.

Also, this may be a dumb question, but are the tests in the "manual&qu= ot;
directory meant to be run manually? If not, how would I run the tests there= ?

You can e.g. 'cd test/manual/indent' and run 'make js-jsx.js.te= st', to compare the indentation in js-jsx.js against what the current j= s.el does.

And then finally, should I just email a patch with the proposed change &= ;
tests for this?

An email with a diff attached could be enough.

But if you wanted to include a "proper" commit message as well, s= ee CONTRIBUTE in the top directory.

--001a1135be2cb96f740545709214--