shell命令
emacsclient -n -e '(make-remember-frame)'
作品。
但是Applecript
do shell script "emacsclient -n -e '(make-remember-frame)'"
只返回
emacsclient: can't find socket; have you started the server?
To start the server in Emacs, type \"M-x server-start\".
emacsclient: No socket or alternate editor. Please use:
--socket-name
--server-file (or environment variable EMACS_SERVER_FILE)
--alternate-editor (or environment variable ALTERNATE_EDITOR)
答案 0 :(得分:0)
我很少使用它,但它在过去成功地用于各种目的。也许您可以根据自己的需要进行修改。 init.el
或.emacs
文件必须包含(server-start)
才能使一切正常。我在第一次激活Emacs
时会加载很多东西,所以我需要在调用emacsclient
之前延迟5秒 - 如果你的Emacs加载速度更快,你可以向下调整延迟。如果Emacs已经运行,则无需延迟。您可以注释掉say
生成的口头消息 - 我今天早上使用它们来测试条件并对脚本进行微调。该脚本在第4行包含一个命令行示例,该示例调用两个Emacs函数。当然,您的Emacs
和emacsclient
的路径需要调整到您在计算机上安装它们的任何位置。
# `(server-start)` must be inside `init.el` or `.emacs` file.
# This script can be used in the terimal: osascript path-to-script arguments
# Terminal Example:
# osascript /Users/HOME/.0.data/.0.emacs/.emacsclient.applescript "-e '(progn (dired \"/Applications\") (message \"Hello-World\!\"))'"
on run argv
set arg to item 1 of argv
set emacs to application "Emacs"
set appIsRunning to emacs is running
if appIsRunning then
say "Emacs is already running."
do shell script "/Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/MacOS/bin/emacsclient " & arg
else
tell application "/Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/MacOS/Emacs" to activate
say "Please wait five seconds for Emacs to load."
delay 5
do shell script "/Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/MacOS/bin/emacsclient " & arg
end if
end run