all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: monnier@iro.umontreal.ca
Cc: 20915@debbugs.gnu.org
Subject: bug#20915: 25.0.50; [js-mode] electric annoyances
Date: Mon, 29 Jun 2015 03:26:07 +0200	[thread overview]
Message-ID: <87bnfzwbio.fsf@gmx.us> (raw)
In-Reply-To: <jwvsi9b1fve.fsf-monnier+emacsbugs@gnu.org> (Stefan Monnier's message of "Sun, 28 Jun 2015 21:12:15 -0400")

Hi,

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Electric layout doesn't always quite work to my liking in js-mode.
>>
>
>> Start with Emacs -q and try the following example.
>>
>>       x.map(function(d) {return f(x);});
>>
>> When electric layout mode is on this is typed as
>>
>>      x.map(function(d){
>>          return f(d);
>>      };
>
> I can't think of any way Emacs could guess that you want to keep this as
> a single line.  Any idea?

I don't know if this is possible.  Perhaps via js2 since it knows more
about semantics.

What about differentiating between functions saved to a var or an object
slot:

    var foo = function(a,b){...};
    baz.f = function(a,b){...};

Versus functions that are not saved.

    [1,2,3].map(function(d){...});

Is that identifiable and desirable?

I'm expect Dmitry has a better understanding of this issue.

>> Typing the *third line*, I get something like (with electric indent and
>> electric layout):
>>
>> plot.scale.y = d3.scale.ordinal()
>>                        .domain(bar.ybins)
>>     .rangeRoundBands([plot.height, 0
>> 		     ], 0.1);
>
> electric-indent-mode presumes indentation works correctly.  In this
> case, I think we clearly have an indentation bug (can someone imagine
> a sane programmer who'd want the above indentation?), so the thing to do
> is to fix the indentation code.

And you would not consider the lonely "]" an stylistic annoyance?  That, I
guess, is the work of electric layout.

>> I don't know if it is even possible for electric indent mode to somehow
>> guess that things are indented to an unknown style....
>
> I can't imagine how.  You can tell Emacs, tho, by disabling
> electric-indent-(local-)mode.

Of course.  I can also remove some of the most unpleasant characters in
electric-indent-chars...

Rasmus

-- 
C is for Cookie





  reply	other threads:[~2015-06-29  1:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-28 11:46 bug#20915: 25.0.50; [js-mode] electric annoyances Rasmus
2015-06-28 14:41 ` Eli Zaretskii
2015-06-28 14:50   ` Rasmus
2015-06-28 14:56     ` Eli Zaretskii
2015-06-28 17:50   ` Dmitry Gutov
2015-06-28 17:59     ` Eli Zaretskii
2015-06-28 18:12       ` Dmitry Gutov
2015-06-28 18:24         ` Eli Zaretskii
2015-06-28 18:54           ` Dmitry Gutov
2015-06-28 20:16             ` Eli Zaretskii
2015-06-29  1:12 ` Stefan Monnier
2015-06-29  1:26   ` Rasmus [this message]
2015-06-29  8:49     ` Dmitry Gutov
2015-06-29 11:02       ` Rasmus
2015-06-29  8:33   ` Dmitry Gutov
2015-06-29 13:18     ` Stefan Monnier
2015-06-29 14:05       ` Dmitry Gutov
2015-06-30 14:07         ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bnfzwbio.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --cc=20915@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.