Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Within emacs, how do I reference the physical screens?

Tags:

emacs

emacs24

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.

like image 425
kc2001 Avatar asked Jun 06 '13 12:06

kc2001


2 Answers

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 monitors
  • x-display-pixel-width: Current screen (screen that contains Emacs windows) width
  • x-display-pixel-height: Current screen height
  • set-frame-width and set-frame-height: resize
  • set-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.

like image 99
tungd Avatar answered Oct 14 '22 08:10

tungd


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.

like image 34
tkf Avatar answered Oct 14 '22 08:10

tkf