0

I want to create a new document in TexShop at a specific directory. The documentation says for the command make it has the option at location specifier. I have not been able to see anywhere in the documentation what actually qualifies as a "location specifier". I have tried alias [some path] but only gotten the results can't make into type location specifier or File alias X wasn't found (if it is a new filename I append to the end of the path). I have also tried it with just the path as text without alias, with the same results. What other kind of location specifier could there be? Or is there some strange rule that you have to create the file in the Finder first before calling TexShop's make new document command?

tell application "TeXShop"

make new document at alias "Users:jukhamil:Desktop:apples.tex"

end tell

Error message:

File alias Users:jukhamil:Desktop:apples.tex wasn’t found.

1 Answer 1

0

the at location specifier does not refer to the file system but to the list of the documents of the application like in

make new document at the beginning of documents
make new document at the end of documents

Instead you should set the path property and save eventually.

tell application "TeXShop"
    log (count of documents) -- n
    set p to (POSIX path of (path to desktop folder)) & "foo.tex"
    set the_document to make new document with properties {path:p}
    tell the_document to save
    log (count of documents) -- n+2 whereas n+1 was expected
end tell

However, you should notice that until version 4.27 at least

1) TeXShop creates one window but 2 documents, meaning that iterating over the documents with AppleScript will loop twice as you can test by running

tell application "TeXShop"
    set ds to documents
    repeat with d in ds
        log name of d as text
    end repeat
end tell

2) TeXShop does not use the location specifier properly

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.