all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Troy Brown <brownts@troybrown.dev>
Cc: 70958@debbugs.gnu.org, Eli Zaretskii <eliz@gnu.org>,
	Felician Nemeth <felician.nemeth@gmail.com>,
	Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#70958: 30.0.50; eglot-managed-mode hooks not called on shutdown
Date: Mon, 27 May 2024 16:51:17 +0100	[thread overview]
Message-ID: <CALDnm53w-5_VOLgJ7Q4uqmo3ok-tcPBaseCPyV=uWqFt15qVTA@mail.gmail.com> (raw)
In-Reply-To: <CALDnm53f1nxwBum+EcTxJQC+Qd27OYV1iZCVwnchSuvjj6jQEg@mail.gmail.com>

By the way Troy, can you show your indent-region-function based
on eglot-format? I once tried this and it didn't work very well.  With the
clangd server.  Would like to see your attempt.

João

On Mon, May 27, 2024 at 4:45 PM João Távora <joaotavora@gmail.com> wrote:
>
> merge 70958 70835
> thanks
>
> On Mon, May 27, 2024 at 3:32 PM Troy Brown <brownts@troybrown.dev> wrote:
> >
> > On Mon, May 27, 2024 at 10:09 AM João Távora <joaotavora@gmail.com> wrote:
> > >
> > > Bugs are only "legitimate" when they are harming someone somewhere.
> > > This hook has been there for a number of years, and noone has complained
> > > 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ão



-- 
João Távora





  reply	other threads:[~2024-05-27 15:51 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-15 12:38 bug#70958: 30.0.50; eglot-managed-mode hooks not called on shutdown Troy Brown
2024-05-25  7:53 ` Eli Zaretskii
2024-05-26 22:46   ` João Távora
2024-05-27 12:29     ` Troy Brown
2024-05-27 12:35       ` João Távora
2024-05-27 12:45         ` Troy Brown
2024-05-27 14:09           ` João Távora
2024-05-27 14:32             ` Troy Brown
2024-05-27 15:45               ` João Távora
2024-05-27 15:51                 ` João Távora [this message]
2024-05-27 16:21     ` Felician Nemeth
2024-05-27 17:22       ` João Távora
2024-05-27 17:35         ` Felician Nemeth
2024-05-27 21:05           ` João Távora
2024-05-27 22:21             ` João Távora
2024-05-28 13:00               ` Troy Brown
2024-06-01 14:18                 ` Eli Zaretskii
     [not found]                   ` <CALDnm507yRL6y6VcM-OwHUhSmFbpcFhsUb00wabirPkfq7ZAow@mail.gmail.com>
2024-06-01 16:01                     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALDnm53w-5_VOLgJ7Q4uqmo3ok-tcPBaseCPyV=uWqFt15qVTA@mail.gmail.com' \
    --to=joaotavora@gmail.com \
    --cc=70958@debbugs.gnu.org \
    --cc=brownts@troybrown.dev \
    --cc=eliz@gnu.org \
    --cc=felician.nemeth@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.