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

159Re: Requiring files to end with a newline

Expand Messages
  • michael_j_barber
    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?
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > >
      > > > >
      > > > >
      > > > >
      > > >
      > >
      > >
      > >
      >
    • Show all 11 messages in this topic