How to find the screen size of my system in Emacs?

I use the same .emacs for several machines, operating systems and platforms. I would like the default frame size of Emacs when called to be relative to the available screen size (for example, 96 lines work very well on the 1600x1200 desktop, but on a 1280x800 laptop I need to specify no more than 68 lines).

Is there an emacslisp expression that returns the width and height of the system screen?

Update: I just found a similar question , but for some reason neither (width x-display-pixel-width) nor (width-pixel-width) could be found in my GNU Emacs 23.2 on Windows XP. Continuing to explore ...

+3
source share
3 answers

I am running Gnu Emacs 23.2.1 on XP Pro, and the functions

(x-display-pixel-width)

and

(x-display-pixel-height) 

both work fine. They are part of source c and must be present.

Can you run emacs outside of a terminal that it trusts?

Here is the documentation from my current emacs:

x-display-pixel-height is a built-in function in the source code C.

(x-display-pixel-height &optional TERMINAL)

Return the height in pixels of the TERMINAL X-display. The optional TERMINAL argument indicates which display to ask. TERMINAL must be a terminal object, frame, or display name (string). If omitted or not, it means that the selected frame display.

In addition, I have a whole library of convenient functions that will help you when calibrating and moving the emacs frame, if you're interested.

+2
source

I do it badly for an older version.

(tool-bar-mode nil)

(mapc (lambda (x) (add-to-list 'default-frame-alist x))
   (list
          (cons 'top 0) (cons 'left 0)
          (cons 'font "-outline-Courier New-normal-r-normal-normal-11-82-96-96-c-*-iso10646-1")
          (cons 'height 67) (cons 'width 176)
))

.emacs, - -frame-alist. -.

+2

.emacs:

(set-frame-size  (selected-frame)  96 (/ (* (x-display-pixel-height) 46) 600) ) 

, eval-buffer .emacs, Windows XP Emacs, .

, (selected-frame) ( ), :

(setq initial-frame-alist
    '((top . 1) (left . 288) (width . 96) (height . (/ (* (x-display-pixel-height) 46) 600))))

, eval-buffer read.emacs. Emacs ( , ). Weird.

. :

C:\emacs-23.2\bin\runemacs.exe -geometry 96x78+240+0

, , , .

+1
source

Source: https://habr.com/ru/post/1760350/


All Articles