别名使 emacs 在新缓冲区(不是框架)中打开文件并被激活/来到前面?
到目前为止我所拥有的是
alias em="open -a /Applications/Emacs.app "$@" && osascript -e 'tell application "Emacs.app" to activate'"
但我很困惑。
使用该代码,em file.txt 将激活,但不会打开该文件。我得到 '22:23: 语法错误: 预期行尾但发现未知标记。 (-2741)'
工作
alias em=open -a /Applications/Emacs.app "$@"
正常,然后它将打开文件,但显然不会将 emacs 带到前面。
由于某种奇怪的原因
osascript -e 'tell application "Emacs.app" to activate'
没有激活 emacs...我不知道发生了什么。
我很高兴使用别名代码或 .emacs 代码
编辑来修复此问题:请参阅尝试的另一件事的评论。
What I have so far is
alias em="open -a /Applications/Emacs.app "$@" && osascript -e 'tell application "Emacs.app" to activate'"
But I am stumped.
With that code, em file.txt will activate, but won't open the file. And I get '22:23: syntax error: Expected end of line but found unknown token. (-2741)'
Doing
alias em=open -a /Applications/Emacs.app "$@"
Works fine and then it will open the file, but obviously not bring emacs to the front.
And for some strange reason
osascript -e 'tell application "Emacs.app" to activate'
doesn't activate emacs.... I have no idea what is going on.
I am happy to fix this either with alias code, or with .emacs code
edit: see comments for another thing tried.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
试试这个:
对我来说效果很好。
在此处找到了它
Try this:
Works fine for me.
Found it here
问题可能是您需要像这样转义引号吗?
Could the problem be that you need to escape you quotes, like this?
我的
.bashrc
中有以下内容,由我的.profile
提供:在我的
.emacs
自定义区域中:或者如果您不喜欢正如 Jeff 所说:
我不需要任何 AppleScript 来做到这一点;虽然我注意到你错过了
结束告诉
?不管怎样,它对我来说就像一个魅力,弹出 Emacs 打开,或者使用现有的窗口(如果有的话),并且它位于顶部,并且终端仍然准备好接受更多输入。I have the following in my
.bashrc
sourced by my.profile
:And in my
.emacs
custom area:Or if you don't like to
M-x customize-variable
your way into it, as Jeff said:I didn't need any AppleScript to do this; although I noticed you were missing the
end tell
? Anyway, works like a charm for me, pops Emacs open, or uses the existing window if there is one, and it's on top, and the Terminal remains ready for more input.使用:
您可以在终端中
,这将使用现有框架而不是新的客户端框架在新缓冲区中打开指定文件。 http://www.gnu.org/software/emacs /manual/html_node/emacs/emacsclient-Options.html
You can use:
in your terminal, which would open specified file(s) in new buffer using your existing frame rather than a new client frame.
http://www.gnu.org/software/emacs/manual/html_node/emacs/emacsclient-Options.html