Loading ...
Sorry, an error occurred while loading the content.

Re: Requiring files to end with a newline

Expand Messages
  • michael_j_barber
    Ah, but it is intrinsic to languages and standards! Most relevant here is that POSIX defines a text file as being terminated with a newline. Various programs
    Message 1 of 11 , Jan 10, 2008
    • 0 Attachment
      Ah, but it is intrinsic to languages and standards! Most relevant here is that POSIX defines
      a text file as being terminated with a newline. Various programs do make the assumption
      that they're working on text files that meet the definition, although most do cleanly handle
      files where the final newline is missing. Quite a few editors can enforce the condition; off
      the top of my head, vi, emacs, Eclipse, Alpha, Smultron.

      It's not just a personal preference. Quite the contrary - I'd prefer if all the tools I used
      were indifferent to whether there was a newline at end of file.

      Your suggested workaround is interesting, but doesn't sound very practical - attaching
      folder actions everywhere it might be needed sounds like it would only work on a rather
      small scale. I can think of a couple of other external approaches as well, none wholly
      satisfactory (e.g., a stay-open AppleScript that periodically checks each open SEE
      document, wrapping version control check-in to add a missing final newline,...).

      At any rate, I've filed a feature request through the Coding Monkeys' bug tracker.

      --- In SubEthaEdit@yahoogroups.com, Alexander Henket <ahenket@...> wrote:
      >
      >
      > Your requirement is not something that is intrinsic to any language or
      > standard, but just something you want done. As such I would not expect
      > any editor at all to support that. To me this is like requiring to
      > have two open lines between "Dear sirs," and the rest of the letter.
      > It is not something you would expect an editor to enforce, it is a
      > procedural thing for the user.
      >
      > Maybe you could make it a folder action with AppleScript and the sed
      > command? I would not know if folder actions could work upon save, but
      > if so it might be an option. It would even work beyond SubEthaEdit in
      > that case.
      >
      > Regards,
      >
      > Alexander
      >
      > Op 10 jan 2008, om 09:05 heeft michael_j_barber het volgende geschreven:
      >
      > > OK, I'll bite: how do you enforce it? The mechanics of adding a line
      > > feed are not a
      > > challenge. Invoking it automatically on every save - and preferably
      > > in a mode dependent
      > > fashion - is the hard part.
      > >
      > > I'll take it that SubEthaEdit cannot do this. I quite disagree with
      > > your expectation, though:
      > > I'd definitely expect this to be handled by an editor that works in
      > > a Unix environment,
      > > seeing as several command line tools treat the line feed as line
      > > terminators, not line
      > > separators.
      > >
      > > --- In SubEthaEdit@yahoogroups.com, Alexander Henket <ahenket@>
      > > wrote:
      > > >
      > > >
      > > > That sounds like a content requirement that I would not expect
      > > > SubEthaEdit itself to handle. However with the aforementioned sed
      > > > option or any other third party solution, you could still enforce
      > > it.
      > > >
      > > > Alexander Henket
      > > >
      > > > Op 9 jan 2008, om 10:09 heeft michael_j_barber het volgende
      > > geschreven:
      > > >
      > > > > I believe you have misread me. In the Format menu, you can set the
      > > > > line endings to be
      > > > > carriage returns, line feeds, or both. However, the file itself
      > > > > should end with a line feed,
      > > > > which is not enforced by setting "Use Unix/Mac OS X Line Endings
      > > > > (LF)". I'm looking for a
      > > > > way to require that.
      > > > >
      > > > > --- In SubEthaEdit@yahoogroups.com, Alexander Henket <ahenket@>
      > > > > wrote:
      > > > > >
      > > > > >
      > > > > > Under the Format menu you will find what you are looking for
      > > on per
      > > > > > document basis. In the Preferences you can set it for all new
      > > > > documents.
      > > > > >
      > > > > > Regards
      > > > > >
      > > > > > Alexander Henket
      > > > > >
      > > > > > Op 7 jan 2008, om 18:51 heeft michael_j_barber het volgende
      > > > > geschreven:
      > > > > >
      > > > > > > Standard convention for Unix files is that they should end
      > > with a
      > > > > > > newline. Is there any
      > > > > > > combination of settings that will get SubEthaEdit to do this?
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > >
      > > > >
      > > > >
      > > > >
      > > >
      > >
      > >
      > >
      >
    • Alexander Henket
      I did not know about the Posix requirement. It sounds like silly requirement, but if it is a standard, than so be it. A lot of great minds thought about Posix,
      Message 2 of 11 , Jan 10, 2008
      • 0 Attachment

        I did not know about the Posix requirement. It sounds like silly requirement, but if it is a standard, than so be it. A lot of great minds thought about Posix, so who am I to judge that.

        I hope for your sake the feature request will be taken into account.

        Regards,

        Alexander Henket


        Op 10 jan 2008, om 17:37 heeft michael_j_barber het volgende geschreven:

        Ah, but it is intrinsic to languages and standards! Most relevant here is that POSIX defines 
        a text file as being terminated with a newline. Various programs do make the assumption 
        that they're working on text files that meet the definition, although most do cleanly handle 
        files where the final newline is missing. Quite a few editors can enforce the condition; off 
        the top of my head, vi, emacs, Eclipse, Alpha, Smultron. 

        It's not just a personal preference. Quite the contrary - I'd prefer if all the tools I used 
        were indifferent to whether there was a newline at end of file.

        Your suggested workaround is interesting, but doesn't sound very practical - attaching
        folder actions everywhere it might be needed sounds like it would only work on a rather 
        small scale. I can think of a couple of other external approaches as well, none wholly 
        satisfactory (e.g., a stay-open AppleScript that periodically checks each open SEE 
        document, wrapping version control check-in to add a missing final newline,...) . 

        At any rate, I've filed a feature request through the Coding Monkeys' bug tracker. 

        --- In SubEthaEdit@ yahoogroups. com, Alexander Henket <ahenket@... > wrote:
        >
        > 
        > Your requirement is not something that is intrinsic to any language or 
        > standard, but just something you want done. As such I would not expect 
        > any editor at all to support that. To me this is like requiring to 
        > have two open lines between "Dear sirs," and the rest of the letter. 
        > It is not something you would expect an editor to enforce, it is a 
        > procedural thing for the user.
        > 
        > Maybe you could make it a folder action with AppleScript and the sed 
        > command? I would not know if folder actions could work upon save, but 
        > if so it might be an option. It would even work beyond SubEthaEdit in 
        > that case.
        > 
        > Regards,
        > 
        > Alexander
        > 
        > Op 10 jan 2008, om 09:05 heeft michael_j_barber het volgende geschreven:
        > 
        > > OK, I'll bite: how do you enforce it? The mechanics of adding a line 
        > > feed are not a
        > > challenge. Invoking it automatically on every save - and preferably 
        > > in a mode dependent
        > > fashion - is the hard part.
        > >
        > > I'll take it that SubEthaEdit cannot do this. I quite disagree with 
        > > your expectation, though:
        > > I'd definitely expect this to be handled by an editor that works in 
        > > a Unix environment,
        > > seeing as several command line tools treat the line feed as line 
        > > terminators, not line
        > > separators.
        > >
        > > --- In SubEthaEdit@ yahoogroups. com, Alexander Henket <ahenket@> 
        > > wrote:
        > > >
        > > >
        > > > That sounds like a content requirement that I would not expect
        > > > SubEthaEdit itself to handle. However with the aforementioned sed
        > > > option or any other third party solution, you could still enforce 
        > > it.
        > > >
        > > > Alexander Henket
        > > >
        > > > Op 9 jan 2008, om 10:09 heeft michael_j_barber het volgende 
        > > geschreven:
        > > >
        > > > > I believe you have misread me. In the Format menu, you can set the
        > > > > line endings to be
        > > > > carriage returns, line feeds, or both. However, the file itself
        > > > > should end with a line feed,
        > > > > which is not enforced by setting "Use Unix/Mac OS X Line Endings
        > > > > (LF)". I'm looking for a
        > > > > way to require that.
        > > > >
        > > > > --- In SubEthaEdit@ yahoogroups. com, Alexander Henket <ahenket@>
        > > > > wrote:
        > > > > >
        > > > > >
        > > > > > Under the Format menu you will find what you are looking for 
        > > on per
        > > > > > document basis. In the Preferences you can set it for all new
        > > > > documents.
        > > > > >
        > > > > > Regards
        > > > > >
        > > > > > Alexander Henket
        > > > > >
        > > > > > Op 7 jan 2008, om 18:51 heeft michael_j_barber het volgende
        > > > > geschreven:
        > > > > >
        > > > > > > Standard convention for Unix files is that they should end 
        > > with a
        > > > > > > newline. Is there any
        > > > > > > combination of settings that will get SubEthaEdit to do this?
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > >
        > > > >
        > > > >
        > > > >
        > > >
        > >
        > >
        > >
        >


      • michael_j_barber
        POSIX does contain a fair share of silliness - there s a lot of history driving it, too. It s not strictly a requirement, though, but rather a definition.
        Message 3 of 11 , Jan 10, 2008
        • 0 Attachment
          POSIX does contain a fair share of silliness - there's a lot of history driving it, too. It's not
          strictly a requirement, though, but rather a definition. Nothing prevents programs from
          handling both text-files-per-definition and text-files-but-for-the-final-newline, and
          most do handle both. It can be a real puzzle when you run into one that doesn't, though!

          --- In SubEthaEdit@yahoogroups.com, Alexander Henket <ahenket@...> wrote:
          >
          >
          > I did not know about the Posix requirement. It sounds like silly
          > requirement, but if it is a standard, than so be it. A lot of great
          > minds thought about Posix, so who am I to judge that.
          >
          > I hope for your sake the feature request will be taken into account.
          >
          > Regards,
          >
          > Alexander Henket
          >
          >
          > Op 10 jan 2008, om 17:37 heeft michael_j_barber het volgende geschreven:
          >
          > > Ah, but it is intrinsic to languages and standards! Most relevant
          > > here is that POSIX defines
          > > a text file as being terminated with a newline. Various programs do
          > > make the assumption
          > > that they're working on text files that meet the definition,
          > > although most do cleanly handle
          > > files where the final newline is missing. Quite a few editors can
          > > enforce the condition; off
          > > the top of my head, vi, emacs, Eclipse, Alpha, Smultron.
          > >
          > > It's not just a personal preference. Quite the contrary - I'd prefer
          > > if all the tools I used
          > > were indifferent to whether there was a newline at end of file.
          > >
          > > Your suggested workaround is interesting, but doesn't sound very
          > > practical - attaching
          > > folder actions everywhere it might be needed sounds like it would
          > > only work on a rather
          > > small scale. I can think of a couple of other external approaches as
          > > well, none wholly
          > > satisfactory (e.g., a stay-open AppleScript that periodically checks
          > > each open SEE
          > > document, wrapping version control check-in to add a missing final
          > > newline,...).
          > >
          > > At any rate, I've filed a feature request through the Coding
          > > Monkeys' bug tracker.
          > >
          > > --- In SubEthaEdit@yahoogroups.com, Alexander Henket <ahenket@>
          > > wrote:
          > > >
          > > >
          > > > Your requirement is not something that is intrinsic to any
          > > language or
          > > > standard, but just something you want done. As such I would not
          > > expect
          > > > any editor at all to support that. To me this is like requiring to
          > > > have two open lines between "Dear sirs," and the rest of the letter.
          > > > It is not something you would expect an editor to enforce, it is a
          > > > procedural thing for the user.
          > > >
          > > > Maybe you could make it a folder action with AppleScript and the sed
          > > > command? I would not know if folder actions could work upon save,
          > > but
          > > > if so it might be an option. It would even work beyond SubEthaEdit
          > > in
          > > > that case.
          > > >
          > > > Regards,
          > > >
          > > > Alexander
          > > >
          > > > Op 10 jan 2008, om 09:05 heeft michael_j_barber het volgende
          > > geschreven:
          > > >
          > > > > OK, I'll bite: how do you enforce it? The mechanics of adding a
          > > line
          > > > > feed are not a
          > > > > challenge. Invoking it automatically on every save - and
          > > preferably
          > > > > in a mode dependent
          > > > > fashion - is the hard part.
          > > > >
          > > > > I'll take it that SubEthaEdit cannot do this. I quite disagree
          > > with
          > > > > your expectation, though:
          > > > > I'd definitely expect this to be handled by an editor that works
          > > in
          > > > > a Unix environment,
          > > > > seeing as several command line tools treat the line feed as line
          > > > > terminators, not line
          > > > > separators.
          > > > >
          > > > > --- In SubEthaEdit@yahoogroups.com, Alexander Henket <ahenket@>
          > > > > wrote:
          > > > > >
          > > > > >
          > > > > > That sounds like a content requirement that I would not expect
          > > > > > SubEthaEdit itself to handle. However with the aforementioned
          > > sed
          > > > > > option or any other third party solution, you could still
          > > enforce
          > > > > it.
          > > > > >
          > > > > > Alexander Henket
          > > > > >
          > > > > > Op 9 jan 2008, om 10:09 heeft michael_j_barber het volgende
          > > > > geschreven:
          > > > > >
          > > > > > > I believe you have misread me. In the Format menu, you can
          > > set the
          > > > > > > line endings to be
          > > > > > > carriage returns, line feeds, or both. However, the file
          > > itself
          > > > > > > should end with a line feed,
          > > > > > > which is not enforced by setting "Use Unix/Mac OS X Line
          > > Endings
          > > > > > > (LF)". I'm looking for a
          > > > > > > way to require that.
          > > > > > >
          > > > > > > --- In SubEthaEdit@yahoogroups.com, Alexander Henket
          > > <ahenket@>
          > > > > > > wrote:
          > > > > > > >
          > > > > > > >
          > > > > > > > Under the Format menu you will find what you are looking for
          > > > > on per
          > > > > > > > document basis. In the Preferences you can set it for all
          > > new
          > > > > > > documents.
          > > > > > > >
          > > > > > > > Regards
          > > > > > > >
          > > > > > > > Alexander Henket
          > > > > > > >
          > > > > > > > Op 7 jan 2008, om 18:51 heeft michael_j_barber het volgende
          > > > > > > geschreven:
          > > > > > > >
          > > > > > > > > Standard convention for Unix files is that they should end
          > > > > with a
          > > > > > > > > newline. Is there any
          > > > > > > > > combination of settings that will get SubEthaEdit to do
          > > this?
          > > > > > > > >
          > > > > > > > >
          > > > > > > > >
          > > > > > > >
          > > > > > >
          > > > > > >
          > > > > > >
          > > > > >
          > > > >
          > > > >
          > > > >
          > > >
          > >
          > >
          > >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.