From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#30421: 25.3; desktop.el: Steal lock when no living "emacs" process owns it Date: Sat, 03 Mar 2018 13:33:14 +0200 Message-ID: <834llxv1fp.fsf@gnu.org> References: <871shram2i.fsf@gmail.com> <83mv0f1q6t.fsf@gnu.org> <87r2prpl05.fsf@gmail.com> <87zi4fa4ft.fsf@users.sourceforge.net> <838tbz1o8k.fsf@gnu.org> <87mv0f5urq.fsf@gmail.com> <837erj1m46.fsf@gnu.org> <87k1vj5tju.fsf@gmail.com> <834lmn1k5h.fsf@gnu.org> <876073e5d9.fsf@gmail.com> <83wozjz79c.fsf@gnu.org> <87bmgv2vvk.fsf@gmail.com> <87o9kpn9pq.fsf@gmail.com> <83po55e4md.fsf@gnu.org> <87r2pkilsj.fsf@gmail.com> <83fu60cb82.fsf@gnu.org> <87r2pilesx.fsf@gmail.com> <831shib6e3.fsf@gnu.org> <83k1v24qpl.fsf@gnu.org> <878tbi2mvm.fsf@gmail.com> <83fu5q2lqh.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1520076733 14046 195.159.176.226 (3 Mar 2018 11:32:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 3 Mar 2018 11:32:13 +0000 (UTC) Cc: 30421@debbugs.gnu.org, npostavs@users.sourceforge.net To: Pierre Neidhardt Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Mar 03 12:32:09 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1es5Oa-0002xC-2U for geb-bug-gnu-emacs@m.gmane.org; Sat, 03 Mar 2018 12:32:08 +0100 Original-Received: from localhost ([::1]:39718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1es5Qc-0007uZ-Ga for geb-bug-gnu-emacs@m.gmane.org; Sat, 03 Mar 2018 06:34:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1es5QV-0007uG-6I for bug-gnu-emacs@gnu.org; Sat, 03 Mar 2018 06:34:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1es5QQ-0006rR-82 for bug-gnu-emacs@gnu.org; Sat, 03 Mar 2018 06:34:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33975) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1es5QQ-0006rM-4A for bug-gnu-emacs@gnu.org; Sat, 03 Mar 2018 06:34:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1es5QP-0007aj-UQ for bug-gnu-emacs@gnu.org; Sat, 03 Mar 2018 06:34:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 03 Mar 2018 11:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30421 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30421-submit@debbugs.gnu.org id=B30421.152007679429124 (code B ref 30421); Sat, 03 Mar 2018 11:34:01 +0000 Original-Received: (at 30421) by debbugs.gnu.org; 3 Mar 2018 11:33:14 +0000 Original-Received: from localhost ([127.0.0.1]:41872 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1es5Pd-0007Zf-0i for submit@debbugs.gnu.org; Sat, 03 Mar 2018 06:33:14 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:37754) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1es5Pb-0007ZS-3D for 30421@debbugs.gnu.org; Sat, 03 Mar 2018 06:33:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1es5PV-0006O9-1y for 30421@debbugs.gnu.org; Sat, 03 Mar 2018 06:33:06 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:49563) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1es5PP-0006LI-V5; Sat, 03 Mar 2018 06:32:59 -0500 Original-Received: from [176.228.60.248] (port=4582 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1es5PP-0003Q2-A7; Sat, 03 Mar 2018 06:32:59 -0500 In-reply-to: <83fu5q2lqh.fsf@gnu.org> (message from Eli Zaretskii on Sat, 24 Feb 2018 22:09:26 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:143874 Archived-At: > Date: Sat, 24 Feb 2018 22:09:26 +0200 > From: Eli Zaretskii > Cc: 30421@debbugs.gnu.org, npostavs@users.sourceforge.net > > > I correctly get prompted if I want to load the desktop then. > > OK, thanks for testing. > > So like I said, we need a new hook, which would be called when the > server creates a frame, but doesn't switch to any new buffers in that > frame. Can you see if the patch below gives good results? It should work both when you invoke emacsclient with one or more file names, or without any file names. In both cases, the new hook server-after-make-frame-hook should be invoked, with the new frame being the selected frame. If you run your code in that new hook, you should get prompted whether you want to load the desktop, regardless whether or not you specify files for emacscilent to visit. diff --git a/lisp/server.el b/lisp/server.el index a892203..ff03cbe 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -188,6 +188,13 @@ server-switch-hook :group 'server :type 'hook) +(defcustom server-after-make-frame-hook nil + "Hook run when the Emacs server creates a client frame. +The created frame is selected when the hook is called." + :group 'server + :type 'hook + :version "27.1") + (defcustom server-done-hook nil "Hook run when done editing a buffer for the Emacs server." :group 'server @@ -1336,9 +1343,11 @@ server-execute ((or isearch-mode (minibufferp)) nil) ((and frame (null buffers)) + (run-hooks 'server-after-make-frame-hook) (message "%s" (substitute-command-keys "When done with this frame, type \\[delete-frame]"))) ((not (null buffers)) + (run-hooks 'server-after-make-frame-hook) (server-switch-buffer (car buffers) nil (cdr (car files))) (run-hooks 'server-switch-hook) (unless nowait