GNU bug report logs - #19946
js-mode indentation with mixed Unix/DOS line endings

Previous Next

Package: emacs;

Reported by: jostein <at> kjonigsen.net

Date: Wed, 25 Feb 2015 16:45:03 UTC

Severity: minor

Tags: wontfix

Found in version 24.4

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


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

From: Daniel Colascione <dancol <at> dancol.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>, jostein <at> kjonigsen.net,
 Simen Heggestøyl <simenheg <at> gmail.com>
Cc: Alan Mackenzie <acm <at> muc.de>, 19946 <at> debbugs.gnu.org,
 dan.colascione <at> gmail.com
Subject: Re: bug#19946: 24.4; js-mode, indentation
Date: Sun, 20 Mar 2016 17:08:26 -0700
[Message part 1 (text/plain, inline)]
On 03/20/2016 12:49 PM, Dmitry Gutov wrote:
> On 03/20/2016 09:47 PM, Jostein Kjønigsen wrote:
> 
>>> 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?
> 
> I don't see any problem there, but that's up to Alan.

It don't have any problem teaching specific modes about carriage
returns, but this approach doesn't scale. A better approach, I think,
would be to extend something like ws-butler for dealing with
mixed-line-ending files. On load, we'd transform `\r\n' -> `\n', but
*remember* which `\n's represent `\r\n` and perform the reverse
translation when writing. This way, you'd preserve clowny extra carriage
returns from other people, but see a clean, unified view in Emacs.

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 5 years ago.

Previous Next


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