Feature Request: File/Scope Specific Line Endings

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Feature Request: File/Scope Specific Line Endings

René Schwaiger
Hi,

I recently created a [TextMate bundle][] for [ABNF][]. The [RFC][] that describes the current version of ABNF explicitly states that the standard uses CRLF (Carriage Return + Line Feed) for line endings.

[TextMate bundle]: http://github.com/sanssecours/ABNF.tmbundle
[ABNF]: http://en.wikipedia.org/wiki/Augmented_Backus–Naur_Form
[RFC]: https://tools.ietf.org/html/rfc5234

TextMate already supports different line endings in the “Save Dialog”. This works quite well, as far as I can tell. We can also explicitly tell TextMate to always use specific line endings via “Preferences” → “Files” → “Line Endings”. If we set this option to “CRLF” then TextMate adds the entry

   lineEndings      = '\r\n'

to the global properties file `Global.tmProperties`. However, in both the current development version of TextMate (2.0-beta.12.26), and the lastest normal release (TextMate 2.0-beta.12.4), this feature does not seem to work as expected:

---

# Steps to Reproduce

1. Set line Endings to “CRLF” in “Preferences…”
2. Create a new file via `mate test.txt`
3. Enter the following text in the new document

       line 1
       line 2

4. Check the line endings via the command `file test.txt`

# Expected Result

The `file` utility displays the following output:

   test.txt: ASCII text, with CRLF line terminators

# Actual Result

The `file` utility displays the following output:

   test.txt: ASCII text

---

Maybe I am doing something wrong here?

I would also expect that the default “Save Dialog” reflects the line ending option currently set via “Preferences…”. This seems not to be the case. If I save a new document via `⇧` + `⌘` + `S`, TextMate always shows “LF” as default option for line endings. Again, maybe this might be a problem with my expectations on how the system works.

After this long  introduction :o) here is my feature request. It would be very nice if it would be possible to set scope- and file-specific line endings. For example, I want to create a new “Settings” item set to the scope `source.abnf` that contains the following code:

   { lineEndings = '\r\n'; }

The “TextMate Settings” grammar currently marks `lineEndings` as invalid key. I suspect this feature is currently not available/implemented? If this is correct, then please consider this a (low priority) request to add this feature.

Kind regards,
 René

_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Feature Request: File/Scope Specific Line Endings

Allan Odgaard-4

On 1 Nov 2016, at 17:08, René Schwaiger wrote:

[…] Maybe I am doing something wrong here?

This is definitely a regression and should be fixed in v2.0-beta.12.29 (hold option down when selecting Check for Updates from the TextMate menu).

As for doing a scope specific setting, what you can do is use .tm_properties and have something like:

[ source.abnf ]
lineEndings = "\r\n"

I assume you would prefer the scope setting so that you can include it in the bundle.

I think it would be better to “rethink” the settings system a little, I’d like to consolidate scope settings and .tm_properties as the former is less friendly for the user but more powerful. This is a long-term goal.

If you think it is appropriate to default all source.abnf files to use \r\n then I would accept a PR for this addition to https://github.com/textmate/textmate/blob/master/Applications/TextMate/resources/Default.tmProperties — as you can see in this file, we already have a few “defaults” for various languages (mainly about soft tabs and tab size).



_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Feature Request: File/Scope Specific Line Endings

René Schwaiger
Hi Allan,

> On 1 Nov 2016, at 14:51 , Allan Odgaard <[hidden email]> wrote:
>
> On 1 Nov 2016, at 17:08, René Schwaiger wrote:
>
>
> […] Maybe I am doing something wrong here?
>
> This is definitely a regression and should be fixed in v2.0-beta.12.29 (hold option down when selecting Check for Updates from the TextMate menu).

thank you for the fast response. The setting now works correctly.

> As for doing a scope specific setting, what you can do is use .tm_properties and have something like:
>
> [ source.abnf ]
> lineEndings = "\r\n"
>
> I assume you would prefer the scope setting so that you can include it in the bundle.
>
> I think it would be better to “rethink” the settings system a little, I’d like to consolidate scope settings and .tm_properties as the former is less friendly for the user but more powerful. This is a long-term goal.
>
> If you think it is appropriate to default all source.abnf files to use \r\n then I would accept a PR for this addition to https://github.com/textmate/textmate/blob/master/Applications/TextMate/resources/Default.tmProperties — as you can see in this file, we already have a few “defaults” for various languages (mainly about soft tabs and tab size).

Sounds great. I will (try to) open a pull request tomorrow.

Kind regards,
  René

_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Loading...