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

Re: Extracting plain text from .seetext with Applescript

Expand Messages
  • michael_j_barber
    A simpler approach for saving from a script would be to just have SubEthaEdit save the document directly. For example, to save your file to the desktop, I d do
    Message 1 of 4 , Aug 20, 2008
    • 0 Attachment
      A simpler approach for saving from a script would be to just have SubEthaEdit save the
      document directly. For example, to save your file to the desktop, I'd do this:

      tell application "SubEthaEdit" to save the front document in POSIX file
      "/Users/mjb/Desktop/test.lua"

      No idea if that would help with the zeros you mention, but I'd guess not -- looks more
      like a file encoding issue. Try UTF-8 and see if the problem goes away.

      --- In SubEthaEdit@yahoogroups.com, "Vaughan McAlley" <ockegheim@...> wrote:
      >
      > I've been happily coding with SubEtherEdit for years. I'm curious about the
      > SubEther Text format, which I think would great for keeping track of changes
      > over time.
      >
      > I want to be able to instantly save a plain text version of the file in a
      > relevant place to compile or run. I wrote the following applescript (full
      > source is at http://mcalley.net.au/see/SaveAsPlainText.zip )
      >
      > tell application "SubEthaEdit"
      > set fileContents to plain text of the document of the front window
      > end tell
      >
      > set commentMarker to "--" -- Lua comments
      > set firstLine to first paragraph of fileContents
      > set filePath to trim_line(firstLine, commentMarker, 0)
      > my write_to_file(fileContents, filePath, false)
      >
      > ...the first line of the Lua file contains the path and filename I want to
      > save to (commented):
      >
      > --Macintosh HD:test.lua
      >
      > The result ends up like this:
      > http://mcalley.net.au/see/result.png
      > ...with every data byte preceded by zero. Is there a fix for this, or a
      > simpler way that I haven't been able to find?
      >
      > Thank you,
      > Vaughan
      >
    • ockegheim
      ... Aha, I tried making a symbolic link called test.lua that pointed to plain.txt and it works! As often seems to be the case, it has to be a symbolic link and
      Message 2 of 4 , Aug 20, 2008
      • 0 Attachment
        --- In SubEthaEdit@yahoogroups.com, Martin Pittenauer <map@...> wrote:

        > A simpler way would be to use the plain text copy that is stored
        > within the .seetext for convenience. Seetext files are bundles, a kind
        > of fancy folder that gets treated like a file by the Finder.
        >
        > Besides the documents history, its metadata and QuickLook preview, we
        > also store a redundant plain text version one can access without
        > SubEthaEdit or use for compiling an the like in this folder.
        > To access the plain text you can use (for this example) "lua
        > test.lua.seetext/plain.txt"

        Aha, I tried making a symbolic link called test.lua that pointed to
        plain.txt and it works! As often seems to be the case, it has to be a
        symbolic link and not just a MacOS alias. I suspected there would be a
        simpler way.

        > I just tried your script and it worked as intended on my machine. What
        > encoding does your lua file usually have? Are you working on Tiger or
        > Leopard? Intel or PPC?

        It doesn't matter now, but I'm back in the dark ages with a 2004 eMac
        PPC running Tiger. I use UTF-8 with CRLF line endings for the Windows
        people.

        > All the best,
        > Martin

        Thank you for the prompt replies!
        Vaughan
      Your message has been successfully submitted and would be delivered to recipients shortly.