From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#70958: 30.0.50; eglot-managed-mode hooks not called on shutdown Date: Mon, 27 May 2024 16:45:01 +0100 Message-ID: References: <86y17yz5sr.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26134"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70958@debbugs.gnu.org, Eli Zaretskii , Felician Nemeth , Stefan Monnier To: Troy Brown , GNU bug tracker automated control server Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 27 17:47:21 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1sBcZE-0006YH-QF for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 27 May 2024 17:47:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sBcYp-0008Ll-EG; Mon, 27 May 2024 11:46:55 -0400 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 1sBcYo-0008L6-6U for bug-gnu-emacs@gnu.org; Mon, 27 May 2024 11:46:54 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sBcYn-0005Sq-Q5 for bug-gnu-emacs@gnu.org; Mon, 27 May 2024 11:46:53 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sBcYw-0002TA-7J for bug-gnu-emacs@gnu.org; Mon, 27 May 2024 11:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 May 2024 15:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70958 X-GNU-PR-Package: emacs Original-Received: via spool by 70958-submit@debbugs.gnu.org id=B70958.17168247919454 (code B ref 70958); Mon, 27 May 2024 15:47:02 +0000 Original-Received: (at 70958) by debbugs.gnu.org; 27 May 2024 15:46:31 +0000 Original-Received: from localhost ([127.0.0.1]:45084 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sBcYR-0002SK-57 for submit@debbugs.gnu.org; Mon, 27 May 2024 11:46:31 -0400 Original-Received: from mail-lf1-f53.google.com ([209.85.167.53]:51296) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sBcYO-0002Rv-DZ; Mon, 27 May 2024 11:46:29 -0400 Original-Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-529661f2552so3236157e87.2; Mon, 27 May 2024 08:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716824713; x=1717429513; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8r1lueHInvT70nhh4nDRsPMyl4wbuu2uE0BgEac+v1U=; b=LmuW46ivKSMnOunGAFaxIG4V4ZadX2y2aOhqVMBP2XEgtmUqT8g+koZQ87Jxo4Y4so GOR3NT9eTVxqpZsFfo91LruomiWLcahvUvt73juY2CTk9K71jDOnSLLnKmO+MJS6lUYP JiCG8JYT+gKyRQdwqNERrzds/JVpVj8Mib7rCBT+V6uugAjHDVISBEi839p+hat5vgbg K4khJ4gFbLtXYVDOxZ5fjzAK9MKOiqQQDy6Ia12MDWNfgeL6GgS9sKYuKPcIrAZNTGTp /NkcMHctqkVrsHf2mz9ZNlhGzF4EGjLTvjLqzl23jhKurXxw7LHD7yJora9i9PJXJWH0 JyfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716824713; x=1717429513; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8r1lueHInvT70nhh4nDRsPMyl4wbuu2uE0BgEac+v1U=; b=nKaH1Jb0QtWR3H526c0d1Q/KfzthSrxnGouMeWtYE5wRdiY5bwVL9QfYSUXOOTLOdP 64cFRaNVwSWeI3EeaxZTqUNLbXhNQSwgCg1IFUJ5x2/RwtMQDH9ec6c1zeW3CO9E4xzV GVm0GoUFPKhN2PBBCcllAcOB9kryyzf8eCPPoOIbiDMyONSkQhuEC9jGjtWF1ik7oUxw 4+PXOxiakTCboI35cznIhDNptTEjalqQYAcdjUn36yZwTJA8raVUFLRTV1dZ+zQeW+UO b63Kn7XfI7bq/VVXWeYgxr25Lt6hIqACZ7e7B85hiyFXbt9IYXhkH7Gk4+LKFvIGtleI sE2A== X-Forwarded-Encrypted: i=1; AJvYcCXczykO6gjeZ9Yy3qC5BfH3eUbB/pLLbuWnQ3YrZZ1MBoAQ2bzOyrj2PY3J0SMWguMeckPt4g0SJ9v/5ZUwc0xCMaslRw4yJqjdqLQvX50+wWv0mSEHLWOx/+gOZF6G X-Gm-Message-State: AOJu0YyX5QmjnYdPIaxReBJe9vpAltXJ69+60yfiQCdla8B4UIgs00bH p5DFjmr98iiq0VfDaTxHCm+HHa/TH4KtavOmUbWqQKzXnqbaDbdQsnMQ8mQnMGX+sNTcxou1zKk 4whn/8TgBISI9hmW2CPs/A8uG5rI= X-Google-Smtp-Source: AGHT+IEEIkfmPvi5wMLrm2mR5DhMq0kU77a8RmtHvcS9ymiDeihDOCJJuyvF6oP4G4mlqA+pa/JmNbF2ox6uwpsOuA8= X-Received: by 2002:a05:6512:1112:b0:520:98ff:5554 with SMTP id 2adb3069b0e04-5296547aa0amr8107946e87.30.1716824713249; Mon, 27 May 2024 08:45:13 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:286050 Archived-At: merge 70958 70835 thanks On Mon, May 27, 2024 at 3:32=E2=80=AFPM Troy Brown = wrote: > > On Mon, May 27, 2024 at 10:09=E2=80=AFAM Jo=C3=A3o T=C3=A1vora wrote: > > > > Bugs are only "legitimate" when they are harming someone somewhere. > > This hook has been there for a number of years, and noone has complaine= d > > that I can remember. If you have a use for the on-shutdown, then it's > > a bug. It'd help to know about this use case. If you don't have a use, > > it's just a doc bug, and patches welcome. Actually I was wrong. I have been recently warned of this exact same issue. I thought you and that person were the same. bug#70835, which this bug is a duplicate of (so I've merged them, hopefully) > The use case is that I was experimenting with updating the > buffer-local indent-region-function (and indirectly > indent-line-function) to be based on eglot-format when the buffer was > connected to the language server. I was attempting to use the > eglot-managed-mode-hook so I could update these variables when the > Eglot buffer management changed. Since the hook wasn't being called > on shutdown it would still attempt to call eglot-format when it was no > longer managing the buffer. The workaround was to use a mode-specific > function for indent-region-function and then having that call > eglot-managed-p to determine if it should call eglot-format or > something else (e.g., indent-relative). Anyway, to your use case. The "off" hook would solve your problem, but not as well as your solution. When setting variables, there's no clean solution to the "undo problem", unless the variable in question is a hook. Think: var is originally X activate minor mode foo, saves var value of X, sets to Y, activate minor mode bar, that also sets var, saves Y, sets to Z deactivate foo, sets var to X deactivate bar, sets var to Y now both modes are inactive, variable is set to Y, in error When the variable being affected is a hook with certain rules, this problem doesn't exist. Anyway, it's not a problem for Eglot to solve. So given there is also bug#70835 requesting the same, I think we can risk just running eglot-managed-mode-hook like so let's try this patch: diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 6896baf30ce..2fab9e7f38b 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -2059,6 +2059,7 @@ eglot--managed-mode (when eglot--current-flymake-report-fn (eglot--report-to-flymake nil) (setq eglot--current-flymake-report-fn nil)) + (run-hooks 'eglot-managed-mode-hook) (let ((server eglot--cached-server)) (setq eglot--cached-server nil) (when server There will possibly be people complaining we broke their configs, so this might not be the end of the story. But it's reasonable to try it since this is how the documentation says it _should_ work and is consistent with the normal minor-mode hooks. Jo=C3=A3o