GNU bug report logs - #24896
JSX prop indentation after fat arrow

Previous Next

Package: emacs;

Reported by: Felipe Ochoa <felipe.nospam.ochoa <at> gmail.com>

Date: Mon, 7 Nov 2016 16:35:02 UTC

Severity: minor

Merged with 26001, 30225, 32158

Found in versions 26.1, 27.0.50

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

Full log


Message #20 received at 24896 <at> debbugs.gnu.org (full text, mbox):

From: Felipe Ochoa <felipe.nospam.ochoa <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 24896 <at> debbugs.gnu.org,
 Jackson Ray Hamilton <jackson <at> jacksonrayhamilton.com>
Subject: Re: bug#24896: JSX prop indentation after fat arrow
Date: Fri, 6 Jan 2017 18:44:43 +0100
[Message part 1 (text/plain, inline)]
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 <dgutov <at> 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 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.
>
[Message part 2 (text/html, inline)]

This bug report was last modified 5 years and 352 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.