【发布时间】:2017-08-08 18:28:13
【问题描述】:
我想打开一个在Finder中选择的组织模式文件,方法是双击它。但由于我在 daemon-mode 中使用 Emacs,我想为此使用 emacsclient 命令。
因此,主要想法是将命令 emacsclient -c posixPathToFile 包装在 AppleScript App 中以打开它。
tell application "Finder"
set fileAlias to the selection as alias
set fileName to name of fileAlias
set posixPath to POSIX path of fileAlias
end tell
-- tell application "Emacs" to activate
try
do shell script "/usr/local/bin/emacsclient -c " & quoted form of posixPath
end try
我知道有些set 命令是不需要的。假设此脚本保存为Xemacs.app,并且我将此应用程序关联到始终打开.org 文件。
通过双击文件无法使用此应用程序,而是如果我在 Finder 中选择文件,然后单独调用 Xemacs.app。为什么 ?我对 AppleScript 没有足够的信心来弄清楚会发生什么。
所以解决方法是使用 Automator 服务
on run {input, parameters}
set posixPath to POSIX path of input
tell application "iTerm" to do shell script "/usr/local/bin/emacsclient -c " & quoted form of posixPath
return input
end run
服务保存为'Open in Emacs'
现在选择一个文件并右键单击并调用服务>“在 Emacs 中打开”工作并打开文件。
第一种方法有什么问题?
【问题讨论】:
-
如何使用 platypus 制作一个应用程序并从那里运行您的脚本,然后让您最喜欢的文件类型与该 platypus 应用程序相关联?
-
想法是不要使用第三方工具
-
这是一个名为“Mac 上的 Emacsdaemon 和 Emacsclient”的相关主题,其中有几个示例:emacs.stackexchange.com/questions/141/…,这是 reddit 上的另一个相关主题:reddit.com/r/emacs/comments/1wu2ja/… Google关键字:“emacsclient automator app emacs finder”
-
谢谢,我已经找到了这些链接,但没有一个真正回答我的问题,而且 Ascrpit 和我的一样。我的问题是如何连接组件以便双击打开文件。自动化方法只是一种临时方法。解决方法。
标签: macos emacs automator emacsclient