简体   繁体   English

使emacs在新缓冲区(NOT帧)中打开文件并激活/来到前面的别名?

[英]Alias to make emacs open a file in a new buffer (NOT frame) and be activated/come to front?

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 . 使用该代码,em file.txt将激活,但不会打开该文件 And I get '22:23: syntax error: Expected end of line but found unknown token. 我得到'22:23:语法错误:预期行结束但发现未知令牌。 (-2741)' (-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. 工作正常,然后它将打开文件,但显然不会将emacs带到前面。


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. 不激活emacs ....我不知道发生了什么。


I am happy to fix this either with alias code, or with .emacs code 我很高兴用别名代码或.emacs代码修复此问题


edit: see comments for another thing tried. 编辑:看到另一件尝试的评论。

Try this: 尝试这个:

(setq ns-pop-up-frames nil)

Works fine for me. 对我来说很好。

Found it here 在这里找到它

I have the following in my .bashrc sourced by my .profile : 我的.profile来源的.bashrc有以下内容:

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

And in my .emacs custom area: 在我的.emacs自定义区域:

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

Or if you don't like to Mx customize-variable your way into it, as Jeff said: 或者,如果你不喜欢Mx customize-variable ,那么杰夫说:

(setq ns-pop-up-frames nil)

I didn't need any AppleScript to do this; 我不需要任何AppleScript来做这件事; although I noticed you were missing the end tell ? 虽然我注意到你错过了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. 无论如何,对我来说就像一个魅力,弹出Emacs打开,或者如果有的话,使用现有的窗口,并且它在顶部,并且终端仍然准备好进行更多输入。

可能问题是你需要逃避引号,像这样吗?

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

You can use: 您可以使用:

emacsclient -nt somefile

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 http://www.gnu.org/software/emacs/manual/html_node/emacs/emacsclient-Options.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM