在mac上,在特定的监视器中打开Emacs框架? [英] On mac, open an Emacs frame in a specific monitor?

查看:131
本文介绍了在mac上,在特定的监视器中打开Emacs框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:我使用带双显示器的mac。当我启动Emacs时,它始终在主显示器(我的macbook pro上的一个)中打开,这不是我想看的。是否有任何elisp功能在特定的显示器中打开一个新的框架,以便在emacs启动后,我可以在两个显示器中都有框架?



或者,有没有办法让Emacs从外部监视器启动(如果存在)?



BTW,我的Emacs是来自emacsforosx.com的24.1.1。

解决方案

您的显示器上的可见区域具有连续的坐标空间。主显示屏的左上角(带有菜单栏的左上角)为(0,0)。因此,在特定显示器上打开框架只是在特定位置打开框架的特殊情况。



首先将框架移动到所需位置,然后使用(frame-parameters)以获取顶部/左侧的值。通常,(frame-parameters)的结果是一个alist(成对列表),如下所示:

 (...(上54)(左107)...)

但是,如果在主显示屏上方或左侧显示显示屏,则该显示屏上的窗口的顶部/左侧值将为负数。 Emacs的GUI支持,最初来自X11,没有任何负坐标的概念。如果您尝试使用负值,Emacs将它们解释为相对于主显示屏的底部/右侧,可能不是您想要的。



框架参数用于处理这种情况:当存储负顶/左值时,相应的列表项是三个项目的列表。例如:

 (...(top + -51)(left + -1674)...)

通常您可以直接将这些项目提供给 make-frame ,但它不明白这个黑客。相反,您可以制作框架,并通过修改其参数立即移动框架。例如,我的左边是一个1680x1050的显示屏,略高于我的主显示屏,所以这个显示器上显示一个新的框架:

 (modify-frame-parameters(make-frame)'((top + -51)(left + -1674)))

我个人使用 Moom ,因为它更容易使用,更灵活我在Emacs中创建一个新的框架,其中包含 Cx 5 2 ,然后使用Moom键盘快捷键将其移动到另一个显示屏,或者我想要的任何地方。


Background: I use a mac with dual monitor. When I start Emacs, it always opens in the "main" monitor (the one on my macbook pro), which is not the one I want to look at. Is there any elisp function to open a new frame in a specific monitor, so that I can have frames in both monitors after emacs starts?

Or, is there any way to let Emacs starts in the external monitor (if it exists)?

BTW, my Emacs is 24.1.1 from emacsforosx.com.

解决方案

The visible area across your displays has a contiguous coordinate space. The top left of the main display (the one with the menu bar on it) is (0, 0). So, opening a frame on a specific display is just a special case of opening a frame in a particular location.

First move the frame where you want it, then use (frame-parameters) to get the top/left values. Normally the result of (frame-parameters) is an alist (list of pairs), something like this:

(... (top . 54) (left . 107) ...)

But if you have displays above or to the left of the main display, the top/left values for windows on that display will be negative. Emacs's GUI support, coming originally from X11, didn't have any concept of negative coordinates. If you try to use negative values, Emacs interprets them as relative to the bottom/right of the main display instead — probably not what you want.

There's a hack in the frame parameter alist to handle this situation: when storing negative top/left values, the corresponding list items are a list of three items instead. For example:

(... (top + -51) (left + -1674) ...)

Normally you can provide these items directly to make-frame, but it doesn't understand this hack. Instead, you can make the frame and immediately move it by modifying its parameters. For example, I've got a 1680x1050 display to the left and slightly above my main display, so this works to display a new frame on that display:

(modify-frame-parameters (make-frame) '((top + -51) (left + -1674)))

Personally I just use Moom, since it's easier to use and more flexible. I create a new frame with C-x 5 2 in Emacs then use Moom keyboard shortcuts to move it to another display, or wherever else I want it.

这篇关于在mac上,在特定的监视器中打开Emacs框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆