Subject: Re: bug#45686: 28.0.50; Could minibuf-eldef-setup-minibuffer inhibit modifications hooks, please?

From: Lars Ingebrigtsen <[email-masked]>
Date: Sun, 10 Jan 2021 15:43:25 +0100

Omar Antolín Camarena <[email-masked]> writes:

> I'd like it if minibuf-eldef-setup-minibuffer was wrapped in
>
> (let ((inhibit-modification-hooks t))
>   ...)

[...]

> This works fabulously except if I use
>
> (setq minibuffer-eldef-shorten-default t)
> (minibuffer-electric-default-mode)
>
> Because if the minibuffer prompt does have a default, and it gets
> shortened, the shortening triggers after-change-functions even though
> the user hasn't typed anything at the minibuffer. So that's why I want
> minibuf-eldef-setup-minibuffer to inhibit modification hooks, but if
> there's a reason it shouldn't or a better way to solve my problem, I
> would love to hear it.

Well, I could see others wanting to trigger something on these
modifications, too, so I'm not sure inhibiting these specific
modifications from running the hooks would be a good general solution.
And as you say:

> For now, I just add this to my configuration, so my problem is actually
> solved already:
>
> (defun stealthily (fn &rest args)
>   (let ((inhibit-modification-hooks t))
>     (apply fn args)))
>
> (advice-add 'minibuf-eldef-setup-minibuffer :around #'stealthily)

That looks like the correct solution for your use case?

Anybody else got an opinion here?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no