2015-03-25 79 views
0

我希望做的是有一个自动机脚本用Emacs打开一个文件时,我拖动文件到它,并把终端的前面。运行的Emacs使用AppleScript和打开文件

现在,当我尝试输入设置为〜/桌面/ test.txt的做到这一点,它要么打开了主页,或将其与〜/桌面/ testtxt结束。我做错了吗?有一个更好的方法吗?

这就是我现在所拥有的:

set thePath to POSIX path of input 
tell application "Terminal" to do script "emacs" 
tell application "System Events" 
    tell process "Terminal" 
     activate 
     delay 2 
     keystroke "x" using control down 
     delay 1 
     keystroke "f" using control down 
     delay 1 
     keystroke thePath 
     delay 1 
     keystroke return 
     delay 1 

    end tell 
    end tell 

    return input 
end run 

回答

0

使用文件路径作为参数传递给emacs

on run {input} 
    tell application "Terminal" 
     repeat with i in input 
      do script "emacs " & quoted form of POSIX path of i 
     end repeat 
     activate 
    end tell 
    return input 
end run