Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Emacs (as daemon) gives 1 more frame than is opened?

Tags:

emacs

If Emacs was started with "--daemon" then (frame-list) returns 2 frames when only 1 is opened

(frame-list)
(#<frame  *Minibuf-1* - Emacs 24.3.50.1 0x11c7270> #<frame F1 0xb94ac8>)

If you start Emacs without daemon flag - no "F1" buffer will be there.

How to reliably determine what frames were opened by a user? Are there any specific properties?

like image 768
Sergey Avatar asked Jan 16 '14 01:01

Sergey


1 Answers

It's a "physically invisible" frame (even though frame-visible-p says otherwise) associated with initial terminal where the daemon was started. I suspect that a sole reason for its existence is that emacs is not ready to run with no frames at all, and it's hard enough to fix it.

For filtering it out I would use this test:

(string-equal "initial_terminal" (terminal-name <frame>)) 
;;; => t for the "pseudo-"frame created by emacs -daemon

There might be better tests, but as far as I know this one is reliable enough: terminal-name returns something like "/dev/tty" for tty frames and the X11 display name like ":0" for X11 frames (I can't recall what it returns on other platforms, like in a Windows console window, but I believe it can't be "initial_terminal" by accident).

like image 192
Anton Kovalenko Avatar answered Nov 07 '22 01:11

Anton Kovalenko