From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: How to get DISPLAY of emacsclient? Date: Tue, 29 Nov 2022 21:44:02 -0500 Message-ID: References: <973588ef-d931-47a0-66d3-f8d70d92bd57@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9821"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Max Nikulin , emacs-devel@gnu.org To: chad Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Nov 30 03:44:59 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p0D5n-0002Md-7R for ged-emacs-devel@m.gmane-mx.org; Wed, 30 Nov 2022 03:44:59 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0D50-0002QW-Jd; Tue, 29 Nov 2022 21:44:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0D4z-0002QL-1y for emacs-devel@gnu.org; Tue, 29 Nov 2022 21:44:09 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0D4x-0004lY-7l for emacs-devel@gnu.org; Tue, 29 Nov 2022 21:44:08 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 4C56780390; Tue, 29 Nov 2022 21:44:05 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 46E068025B; Tue, 29 Nov 2022 21:44:03 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1669776243; bh=YjT8erqbXYKPfQkzEUiIQ1kYSFE9qxGC21Ud7K02c14=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=NN59T1AreVooOC7vOp4yCSDZ2VMxPmMtrNIbqYLdOwKWfvI6LLT1xqxpdWHAULfX8 iV2gv1ltURLqUNyTPWNPWMU2HzoKlPpYwHWj+foNOLh/Zgpg0DXyqOdxfZvxYRolQ5 hxHG5C7n/aFdRTr0DrpTynV4hKrPf5L+y3shGB0FKo2vuPAp7lFTKB6uQyXTu2DyZp 4Q1RGQv2zJ5ytYiZA9FkfQClQguSxoQFbYW0gstkBftm36puEkoeI59b1NeeGzGKdh gBoy2WF9RYAzdLcVTZ8KUxcKylTfdW9EiHm8vclUpxxU+LiqIe4v5U9bbaMO5UzPRc eW6Q0VIYZUbOg== Original-Received: from pastel (unknown [104.247.241.157]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 19D3F12031F; Tue, 29 Nov 2022 21:44:03 -0500 (EST) In-Reply-To: (chad's message of "Tue, 29 Nov 2022 19:41:11 -0500") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:300743 Archived-At: chad [2022-11-29 19:41:11] wrote: > On Tue, Nov 29, 2022 at 1:11 PM Max Nikulin wrote: >> [...] >> Add to user notes content of X selection when emacs is started as >> daemong with no frames and the user prefers to avoid distraction due to >> creation of a new frame. > In general, you seem to assume that there's no way for emacs to create a > new X11 frame object without it being immediately visible to the user. In > my experience, that's only true in the limited subset of cases where the > user has chosen a window manager that enforces that choice. Further, that > wasn't the default when I last looked -- but that was quite some time ago, > and I don't know about the current options/defaults for common X11-based > display systems of today. Can anyone shed some light on this? `xclip.el` (from GNU ELPA) uses: (defun xclip--hidden-frame () (or xclip--hidden-frame (setq xclip--hidden-frame (make-frame-on-display (getenv "DISPLAY") '((visibility . nil) (user-position . t) (left . 0) (top . 0) (no-other-frame . t)))))) I haven't heard of a problem with that yet, but it probably hasn't been widely tested (and it is specific to X11). > This is a fundamentally different case from "the user wants to use a > non-graphical X11-based mechanism that emacs normally doesn't enable until > emacs actually connects to a working X11 display", and I think it should be > possible to get emacs to make that connection without necessarily popping > up a window that the user doesn't want. server.el also does something similar to xclip-mode, tho with simpler code: (defun server-select-display (display) ;; If the current frame is on `display' we're all set. ;; Similarly if we are unable to open frames on other displays, there's ;; nothing more we can do. (unless (or (not (fboundp 'make-frame-on-display)) (server--on-display-p (selected-frame) display)) ;; Otherwise, look for an existing frame there and select it. (dolist (frame (frame-list)) (when (server--on-display-p frame display) (select-frame frame))) ;; If there's no frame on that display yet, create and select one. (unless (server--on-display-p (selected-frame) display) (let* ((buffer (generate-new-buffer " *server-dummy*")) (frame (make-frame-on-display display ;; Make it display (and remember) some dummy buffer, so ;; we can detect later if the frame is in use or not. `((server-dummy-buffer . ,buffer) ;; This frame may be deleted later (see ;; server-unselect-display) so we want it to be as ;; unobtrusive as possible. (visibility . nil))))) (select-frame frame) (set-window-buffer (selected-window) buffer) frame)))) This code has been used a lot more widely, but in many/most cases we end up making that frame visible soon after, so there might be cases where it is not 100% unobtrusive but users don't notice it. Stefan