4

到目前为止我所拥有的是

alias em="open -a /Applications/Emacs.app "$@" && osascript -e 'tell application "Emacs.app" to activate'"

但我很难过。

使用该代码, em file.txt 将激活,但不会打开文件。我得到 '22:23: syntax error: Expected end of line but found unknown token. (-2741)'


正在做

alias em=open -a /Applications/Emacs.app "$@"

工作正常,然后它会打开文件,但显然不会把 emacs 带到前面。


出于某种奇怪的原因

osascript -e 'tell application "Emacs.app" to activate'

不激活emacs....我不知道发生了什么。


我很高兴使用别名代码或 .emacs 代码解决此问题


编辑:查看评论以尝试另一件事。

4

4 回答 4

11

尝试这个:

(setq ns-pop-up-frames nil)

对我来说很好。

在这里找到

于 2012-02-05T16:51:56.193 回答
2

问题可能是您需要像这样转义引号吗?

alias em="open -a /Applications/Emacs.app \"$@\" && osascript -e 'tell application \"Emacs.app\" to activate'"
于 2011-05-20T09:48:55.290 回答
2

我的.bashrc来源中有以下内容.profile

alias emacs='open -a /Applications/Emacs.app "$@"'

在我的.emacs自定义区域中:

(custom-set-variables
 ;; yadda yadda
 ;;...
 '(ns-pop-up-frames nil))

或者,如果您不喜欢M-x customize-variable自己的方式,正如 Jeff 所说:

(setq ns-pop-up-frames nil)

我不需要任何 AppleScript 来执行此操作;虽然我注意到你错过了end tell?无论如何,这对我来说就像一个魅力,弹出 Emacs 打开,或者使用现有的窗口(如果有的话),它在顶部,终端仍然准备好接受更多输入。

于 2014-03-18T17:31:35.447 回答
0

您可以使用:

emacsclient -nt somefile

在您的终端中,它将使用您现有的框架而不是新的客户端框架在新缓冲区中打开指定的文件。

http://www.gnu.org/software/emacs/manual/html_node/emacs/emacsclient-Options.html

于 2014-03-06T02:33:47.263 回答