I have a multi-screen display. Within emacs (GNU Emacs 24.2.1 (i386-mingw-nt6.1.7601) on Windows 7), how can I determine the number of physical screens, and cause things to happen on different screens? For example, I might want to open a new frame in a different screen, or I might want to move the frame in which Emacs is starting to another screen.
Within emacs, how do I reference the physical screens?
I'm not sure if these functions work on Windows, but on Linux and Mac OS X you can use:
x-display-screens
: Number of monitorsx-display-pixel-width
: Current screen (screen that contains Emacs windows) widthx-display-pixel-height
: Current screen heightset-frame-width
andset-frame-height
: resizeset-frame-position
: Move frame
For example if you want to create a new frame in another screen, you can do:
(when (and (display-graphic-p) (= (display-screens) 2))
(make-frame)
(set-frame-position (selected-frame) 1280 0))
Where 1280 is the width of your first screen.
You can also take a look at my setup github.com/tungd/dotfiles/blob/master/emacs/init.el#L278 –
Alcock
It looks like x-display-screens doesn't work on my Emacs implementation on Windows. It returns "1 (#o1, #x1)", and I have three screens. Display-screens returns the same thing. –
Interlaminate
What about
x-display-pixel-width
? If it returns something like the total width of your screens then that would still be useful. –
Alcock Unfortunately, x-display-pixel-width appears to just provide the width of the current screen for Windows. –
Interlaminate
Have you tried the official binary over here: ftp.gnu.org/gnu/emacs/windows. If that still not working then you might have to wait for 24.4 when native support for this is added (
frame-monitor-attributes
and display-monitor-attributes-list
) –
Alcock I haven't yet. Thanks for providing me a giggle. When I looked at that site, I read, "Unfortunately, on Windows 95 and 98, ..." It looks like they need to update their site even more than I need to update my Emacs. –
Interlaminate
My Emacs does seem to have some awareness of the Windows screens. posn-at-x-y returns "(#<window 3 on .emacs> ..." However, the describe-function on it says "posn-at-x-y is a built-in function in `C source code'", so I don't yet see how I can leverage that to get at the available screens. –
Interlaminate
Checkout pos-tip.el code (http://www.emacswiki.org/emacs/pos-tip.el)
It says it works in X and Windows so probably you could find some compatible layer in it.
Thanks for the pointer, but it looks to me that it is using x-display-pixel-width and friends to do screen calculations. I didn't see anything that looked like it was cognizant of Windows screens. –
Interlaminate
Did you try using it? Why not install and use it first to see if it works? –
Stopwatch
© 2022 - 2024 — McMap. All rights reserved.