Applescript 如何在TexShop中创建新文档?
我想在TexShop的特定目录下创建一个新文档。文档中说,对于命令Applescript 如何在TexShop中创建新文档?,applescript,Applescript,我想在TexShop的特定目录下创建一个新文档。文档中说,对于命令make,它在位置说明符处有一个选项。我在文档中的任何地方都看不到什么实际上是“位置说明符”。我尝试了别名[某些路径],但只得到了结果无法生成类型位置说明符或未找到文件别名X(如果它是一个新文件名,我会附加到路径的末尾)。我还尝试了将路径作为文本,而不使用别名,得到了相同的结果。还有什么其他类型的位置说明符?还是有一些奇怪的规则,在调用TexShop的makenewdocument命令之前,必须先在Finder中创建文件 tell
make
,它在位置说明符处有一个选项。我在文档中的任何地方都看不到什么实际上是“位置说明符”。我尝试了别名[某些路径]
,但只得到了结果无法生成类型位置说明符
或未找到文件别名X
(如果它是一个新文件名,我会附加到路径的末尾)。我还尝试了将路径作为文本,而不使用别名
,得到了相同的结果。还有什么其他类型的位置说明符?还是有一些奇怪的规则,在调用TexShop的makenewdocument
命令之前,必须先在Finder中创建文件
tell application "TeXShop"
make new document at alias "Users:jukhamil:Desktop:apples.tex"
end tell
错误消息:
File alias Users:jukhamil:Desktop:apples.tex wasn’t found.
位置说明符处的不是指文件系统,而是指应用程序的文档列表,如
make new document at the beginning of documents
make new document at the end of documents
相反,您应该设置path属性并最终保存
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
但是,您应该注意到,至少在版本4.27之前
1) TeXShop只创建了一个窗口,但创建了两个文档,这意味着使用AppleScript迭代文档将循环两次,而您可以通过运行
tell application "TeXShop"
set ds to documents
repeat with d in ds
log name of d as text
end repeat
end tell
2) TeXShop未正确使用位置说明符