Subject: bug#19946: 24.4; js-mode, indentation

From: Jostein Kjønigsen <[email-masked]>
Date: Sun, 20 Mar 2016 20:47:44 +0100

On Sun, Mar 20, 2016, at 08:18 PM, Dmitry Gutov wrote:
> On 03/20/2016 09:01 PM, Jostein Kjønigsen wrote:
> 
> It's not an argument, it's an observation: clearly we, as a project, 
> haven't made a decision to properly support mixed-newline files.

Fair enough.

>> By following the cardinal rule of good software, that is produce the
>> least amont of astonishment, cc-mode does what's right: it produces the
>> expected outcome, no matter what kind of file it's working with.
> 
> Hmm, does this help?
> 
> diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
> index 15a52ba..dffdb77 100644
> --- a/lisp/progmodes/js.el
> +++ b/lisp/progmodes/js.el
> @@ -578,6 +578,7 @@ js-mode-syntax-table
>       (c-populate-syntax-table table)
>       (modify-syntax-entry ?$ "_" table)
>       (modify-syntax-entry ?` "\"" table)
> +    (modify-syntax-entry ?\C-M " " table)
>       table)
>     "Syntax table for `js-mode'.")
> 

That works for me, at least in js-mode.

While not a general solution to all weird files one might encounter
while working in Emacs, it at least makes js-files behave as expected.
And in a fairly reusable manner too: I can copy this code and I'm home
free.

Would pushing this up to cc-mode's c-populate-syntax-table function also
be considered an option? Or does that just sound on overall way too
risky?

-- 
Jostein Kjønigsen
[email-masked] / [email-masked]