From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id KAMjAnvGF2askgAA62LTzQ:P1 (envelope-from ) for ; Thu, 11 Apr 2024 13:16:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id KAMjAnvGF2askgAA62LTzQ (envelope-from ) for ; Thu, 11 Apr 2024 13:16:11 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1712834171; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=gTxeZBowdFu1Xb/ac7Y9/QppbGk8k7xJfI9gpXnmJV0=; b=no2ZCn97UritZzBvIVhZ/DSRUVeI7h1uhKpLbj+t60F7qbKc+d6ju6YmfrQyedS41m1TiV SAq2BmHNfdD5AoNrBKRhyjV3aV86qcnV37W2q+8Rie/jh673lYqnbdEIfkFuIt3eJFTcyi Jg1pbwHQRMA/QyVa03iTUf/OHsFxf2aaQLgByetCEA06JvVDRBXRj4xa5szCbVzVcGMZKO YmMaZSqWI5M7ZM+DvK67ndY6yS2fBmvrxlQqVhhFtslLqABa9NKm19SMF9R/CSw66G/Rhu ldTeva3TI34WcsUYShq4djXpLuIUJSFnYBctmdk42XNilNFx2+R6yDn91DE2vA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1712834171; a=rsa-sha256; cv=none; b=ttJNINyBspUsoYgSrt9SQrQqgIYWlhVpIPwVOlN6d3xuxEElmmw+dasIFyA+CiEANFnGls NPgGz86pyS6cWwXQCtEXqdRRadwIQnDDIERYUpP9aJ6q+JTh0yrMXYkGde3VB+w+yVKl8A 5yqofAts8GVp6HSNFLEJLWF+VyPlNdzOrBE39quLBFgmol0GiToB5ag6Zeqp7aT2lVIfbL NJfm/+YhqTHFY32S7cVt51XikaLxb7Sc4tPVPv22OmFJGtpm667dQCwYDNMUrwOlk5m54u EnIcLTaFplAeBNSWFzSbxEIeR/HtSc3ccdnYIoBGWwXcWNSs2DnpuUl1g5Fdsg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D376561051 for ; Thu, 11 Apr 2024 13:16:10 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rusP8-00049Q-Hi; Thu, 11 Apr 2024 07:15:42 -0400 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 1rusP4-00048w-9f for guix-devel@gnu.org; Thu, 11 Apr 2024 07:15:39 -0400 Received: from 9.mo582.mail-out.ovh.net ([87.98.171.146]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rusP1-0002jp-4V for guix-devel@gnu.org; Thu, 11 Apr 2024 07:15:37 -0400 Received: from director11.ghost.mail-out.ovh.net (unknown [10.108.25.16]) by mo582.mail-out.ovh.net (Postfix) with ESMTP id 4VFcYv1Yxyz1Ghw for ; Thu, 11 Apr 2024 11:15:31 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-snqvd (unknown [10.110.178.220]) by director11.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 912B31FE47; Thu, 11 Apr 2024 11:15:30 +0000 (UTC) Received: from ngraves.fr ([37.59.142.97]) by ghost-submission-6684bf9d7b-snqvd with ESMTPSA id MpcFH1LGF2ZQyQAAXhXXkQ (envelope-from ); Thu, 11 Apr 2024 11:15:30 +0000 X-OVh-ClientIp: 81.67.146.208 To: guix-devel@gnu.org, emacs-devel@gnu.org Cc: Andrew Tropin , Stefan Monnier Subject: [Nicolas Graves] [PATCH v6 01/10] rde: emacs: Start emacs in --daemon mode, with shepherd and pid-file References: <20240410234923.29319-2-ngraves@ngraves.fr> <875xwotg35.fsf@trop.in> Date: Thu, 11 Apr 2024 13:15:27 +0200 Message-ID: <87zfu0m9ps.fsf@ngraves.fr> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Ovh-Tracer-Id: 14290766045462454965 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrudehkedgfeelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufhffkfggtgesmhdtreertddttdenucfhrhhomheppfhitgholhgrshcuifhrrghvvghsuceonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqeenucggtffrrghtthgvrhhnpeehgfeuheejudffuefhtefgleetvdelieevhedthfduveefteegueeuvddulefgkeenucfkphepuddvjedrtddrtddruddpkedurdeijedrudegiedrvddtkedpfeejrdehledrudegvddrleejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpehnghhrrghvvghssehnghhrrghvvghsrdhfrhdpnhgspghrtghpthhtohepuddprhgtphhtthhopehguhhigidquggvvhgvlhesghhnuhdrohhrghdpoffvtefjohhsthepmhhoheekvddpmhhouggvpehsmhhtphhouhht Received-SPF: pass client-ip=87.98.171.146; envelope-from=ngraves@ngraves.fr; helo=9.mo582.mail-out.ovh.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Nicolas Graves From: Nicolas Graves via "Development of GNU Guix and the GNU System distribution." Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: guix-devel-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -8.97 X-Spam-Score: -8.97 X-Migadu-Queue-Id: D376561051 X-Migadu-Scanner: mx13.migadu.com X-TUID: s3XNqjfAvv2S --=-=-= Content-Type: text/plain Hi Guix, Emacs, As promised to Stefan a few months ago, here's a use case of Shepherd/Emacs implementation that we developped in RDE. We're using the --daemon option on the Shepherd side to launch the server in the background, include code in Emacs configuration to make it create a pid-file as soon as the server has started, and redefine kill-emacs to be managed by the Shepherd. Originally I asked Stefan because I wasn't happy with the current Emacs/Shepherd interaction possibilities, as Emacs doesn't provide a native --pid-file option. He advised me to share once we found a solution to highlight the situation, here it is. Cheers, Nicolas -------------------- Start of forwarded message -------------------- From: Nicolas Graves To: ~abcdw/rde-devel@lists.sr.ht Cc: ngraves@ngraves.fr Subject: [PATCH v6 01/10] rde: emacs: Start emacs in --daemon mode, with shepherd and pid-file Date: Thu, 11 Apr 2024 01:48:13 +0200 --- src/rde/features/emacs.scm | 42 ++++++++++++++++++++++++++++++++- src/rde/home/services/emacs.scm | 9 ++++--- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/rde/features/emacs.scm b/src/rde/features/emacs.scm index 7d055377..74ba306e 100644 --- a/src/rde/features/emacs.scm +++ b/src/rde/features/emacs.scm @@ -440,7 +440,47 @@ Prefix argument can be used to kill a few words." ;; Configure ediff for window manager. (setq ediff-diff-options "-w" ediff-split-window-function 'split-window-horizontally - ediff-window-setup-function 'ediff-setup-windows-plain)) + ediff-window-setup-function 'ediff-setup-windows-plain) + + ;; Configure emacs background server. + ,@(if (get-value 'emacs-server-mode? config) + `((add-hook + 'emacs-startup-hook + (lambda () + (when server-mode + (advice-add + 'kill-emacs :override + (lambda (&optional arg restart) + "\ +Make GNU Shepherd kill the Emacs server. + +If RESTART is non-nil, instead of just exiting at the end, herd will restart +an Emacs server. ARG is ignored. + +Note: This is added through RDE. Redefining a primitive is not advised in +Emacs, but this one is high-level (present in few other functions), and +tested." + (interactive) + (if restart + (call-process-shell-command + (concat "herd restart emacs-" server-name) + nil 0) + (call-process-shell-command + (concat "herd stop emacs-" server-name) + nil 0)))) + ;; Tell shepherd that emacs is started through pid-file. + (with-temp-file (concat (getenv "XDG_RUNTIME_DIR") + "/emacs/" server-name ".pid") + (insert (number-to-string (emacs-pid))))))) + (add-hook + 'kill-emacs-hook + (lambda () + (when server-mode + (let ((pidfile (concat (getenv "XDG_RUNTIME_DIR") + "/emacs/" server-name ".pid"))) + (when (file-exists-p pidfile) + (delete-file pidfile))))))) + '())) #:summary "General settings, better defaults" #:commentary "\ It can contain settings not yet moved to separate features." diff --git a/src/rde/home/services/emacs.scm b/src/rde/home/services/emacs.scm index 9b0b37af..95156a4d 100644 --- a/src/rde/home/services/emacs.scm +++ b/src/rde/home/services/emacs.scm @@ -188,11 +188,14 @@ Same as @code{init-el}, but result will go to @file{early-init.el}.")) (start #~(make-forkexec-constructor (list #$(file-append (home-emacs-configuration-emacs config) - "/bin/emacs") #$(format #f "--fg-daemon=~a" name)) + "/bin/emacs") #$(format #f "--daemon=~a" name)) #:log-file (string-append (getenv "XDG_STATE_HOME") "/log" - "/emacs-" #$(symbol->string name) ".log"))) - (stop #~(make-kill-destructor)))) + "/emacs-" #$(symbol->string name) ".log") + #:pid-file (string-append (getenv "XDG_RUNTIME_DIR") "/emacs/" + #$(symbol->string name) ".pid"))) + (stop #~(make-kill-destructor)) + (respawn? #f))) (define (add-emacs-shepherd-service config) (if (not (null? (home-emacs-configuration-emacs-servers config))) -- 2.41.0 -------------------- End of forwarded message -------------------- -------------------- Start of forwarded message -------------------- From: Andrew Tropin To: Nicolas Graves , ~abcdw/rde-devel@lists.sr.ht Cc: ngraves@ngraves.fr Subject: Re: [PATCH v6 00/10] Emacs server background mode. Date: Thu, 11 Apr 2024 12:15:58 +0300 --=-=-= Content-Type: multipart/signed; boundary="==-=-=" --==-=-= Content-Type: text/plain Content-Disposition: inline On 2024-04-11 01:48, Nicolas Graves wrote: > v6 of the previous patch series, rebased and squased > > Nicolas Graves (10): > rde: emacs: Start emacs in --daemon mode, with shepherd and pid-file > rde: emacs: Add smart emacs-client-alternate-editor > rde: emacs: Make minibuffer programs fail without emacs-server > rde: sway: Add shepherd value > rde: emacs: Use absolute path for herd binary > rde: wm: Sort package modules > rde: swaynotificationcenter: Add value libnotify > rde: emacs: Move emacs-minibuffer-program to feature value > rde: emacs: Make emacs-minibuffer-program depend on config > rde: emacs: Propagate herd and libnotify paths > > src/rde/features/emacs-xyz.scm | 6 +- > src/rde/features/emacs.scm | 168 +++++++++++++++++++++------- > src/rde/features/password-utils.scm | 3 +- > src/rde/features/wm.scm | 38 ++++--- > src/rde/features/xdisorg.scm | 4 +- > src/rde/home/services/emacs.scm | 9 +- > 6 files changed, 165 insertions(+), 63 deletions(-) Very nice, works flawlessly so far and notifications, when server is starting are great. No more half-way loaded emacsclient. Thank you very much for you work! Great job, Nicolas! -- Best regards, Andrew Tropin --==-=-= Content-Type: application/pgp-signature; name=signature.asc Content-Transfer-Encoding: base64 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRSXpCQUVCQ2dBZEZpRUVLRUdheGxBNGRF REg2Uy82SWdqU0NWakIzckFGQW1ZWHFrNEFDZ2tRSWdqU0NWakIKM3JCNlFoQUFrV2xGTndFMDdR cURVbjJmT0dsczN3TVE3d3JDVURXcjhMdVpuRTRVbWMwT2NWdE1xZlR5UFlTVApPTU9KNmJwN2Ni TTdGbmNzT0o2WXFiMjRwWDF5Y1VDQ01BMXEwWmQ0UFBleDRGaUhBRFpCVFk5cm54NHZxY2x0CmMy TnhMd0dqZ0RnbGErbURmbDNoRm5UZ1R6T0cybU10MFpPYkE1OFlSNmFyRzMvUm1SNWxwdmZlYWp2 UzIySWwKVXppWllFWXRJcnRBcW82eW5NbW9lTHIveUpXeEp5TGVxZEZuMnlFbEFjQ0lIYXBhbkRH WHBVRm1iN0d1ODYrMQpIMkF6VUhtUG5iZ09ad1BqMmUvZWNJUDdxeURHcW5IUGdxd09aYXl2M2Fj d3l1R01CcXRjWGRVN3VwSU5HeDlTCldFekcyZXp3WUMxVGJVeDRvQWFqT0N1dU1xQUp2YU5WaFhm MitvUFcxb1Q5OVVlemlGYURQVTRseWh6Rm16MlMKbjRodlJ5ZlVqem5yRzVBeVA3QnpQTEVtbjBF SkJDa2luR3Q5NnNaQWsvYVg5Vll3SzRPZk9Yd0lvZ0ZLTU5sawo1K0lEbWZYMTNuYTlFb2ErSWZK RjJQRWxVa1FWVVFtQUJPRlBNOTlmVDJsZmtCVlFlUHlYRWxsVlFUYStyNzgzCnpnd3lzTnFJb0tl TnZNc1NSQXpCTEhrekFwekRSSUJqZEM4VVlpUG5mcEk4WUFMcXpqbGx6dEVuSmFMTWdsZkQKY3BP aDZRcTdLSU1ENndOeG91YlQyVkxOMzV4TWtLQkdHNWFOYlQrbDJRdWdIT1hRejBnaHNWY1A1azhM blhMdApzSTJXakdWS1VwSU5RTEdTa0llV3VqRDlyT2ZEenBRNWdYWDNNUk5COTNHQTZtK3BtSjQ9 Cj1XK0xFCi0tLS0tRU5EIFBHUCBTSUdOQVRVUkUtLS0tLQ== --==-=-=-- --=-=-= Content-Type: text/plain -------------------- End of forwarded message -------------------- -- Best regards, Nicolas Graves --=-=-=--