Closed titaniumbones closed 2 years ago
Thank you for the report. There seems to be something broken in add/remove-hook
. I pushed fixes in a few of my projects, where I've observed dangling entries in the alist. Generally it seems to be a good idea to avoid hook priorities. Please let me know if the issue with the alist entries remains if you apply the configuration changes described in the Tempel README.
However the dangling entries should have nothing to do with the zombies:
the big problem here is that sometimes capf's I have explicitly removed from the hook somehow come bak as zombies and provide ocmpletion.
The problem here could be that hooks are for some reason marked as permanently local and then somehow return. I am not sure what causes this, but there have also been an issue on the Emacs tracker if I recall correctly.
Also my Consult package is affected by this :(
https://github.com/minad/consult/commit/d0261c0ecdf95ab543ad73d466c450bfedb8b1e7
However the issue is really that I don't know how the bug can be fixed, since as soon as we add local hooks with priorities, the list cannot be cleaned up anymore since Emacs cannot know if the hook is still in use in some other buffer. The issue becomes particularly problematic when we dynamically generate symbols as in consult. So it seems to me that using local hooks with priorities is a no-go? cc @monnier
ah shoot. Thank you for the update! But that's a bummer -- really hard to fine tune the system without priorities. Does the fix need to happen in upstream emacs?
@titaniumbones In the updated tempel example I manually adjust the list. This is what I recommend. Just configure the capfs explicitly, if you really need this degree of fine-tuning.
(add-hook 'emacs-lisp-mode (lambda ()
(setq-local completion-at-point-functions (list #'tempel-expand ... #'cape-file ...)))
Nevertheless it would be nice to improve the situation upstream since the hook infrastructure should ideally be very solid.
I may have to reduce the baroque elegance of my fine-tuning somewhat if I have to do it mode by mode... :-)
Oh no, you can write your own even more baroque configuration macros which solve that elegantly!
Closing. With the adjusted configurations the issue seems to be fixed mostly. The conclusion from this is that local hooks must not be used together with priorities. Local hooks itself work fine and global hooks with priorities work just fine. Only the combination of local+priority is problematic. But it seems the issue is going to be fixed finally for good on Emacs 29.
I strongly doubt this is a corfu issue, but googling led me only to https://github.com/minad/consult/issues/193 so I thought I would ask you here. I am noticing that I cannot fully delete entries from the
hook--depth-alist
property ofcompletion-at-point-functions
added viaadd-hook
with the local flag set. I have several such mode hooks set, now that' I've switched to corfu and am using it for all my completion. So for instance,I have this from tempel:After I open a bunch of files (via desktop-session) I get this value for the variable
completion-at-point-functions
:which is great; but the hook--depth-alist properthy is enormous:
the big problem here is that sometimes capf's I have explicitly removed from the hook somehow come bak as zombies and provide ocmpletion. I wonder if htis is also related to the slowedowns I am sometimes seeing.
Is this a bug? Is it the emacs bug you point to in that other issue? Or do I just not understand how the symbol property is supposed to work?
Thanks again for all your help, and Ihope this is ano OK place to ask once again.