dunn / company-emoji

MOVED to codeberg
https://codeberg.org/egirl/company-emoji
82 stars 7 forks source link

Cache the list of emojis between company complete calls #8

Closed torgeir closed 6 years ago

torgeir commented 7 years ago

Cache the list of emojis between company complete calls to speed up completion.

dunn commented 7 years ago

Oh, thanks! Caching them is a great idea. My one concern is that if a user modifies the company-emoji-aliases custom variable, those won't take effect until Emacs is restarted. Any idea how we might get around that?

torgeir commented 7 years ago

Oh, I didn't realize that. Detecting a defcustom change isn't possible afaik.. We could expose a function to add aliases and regenerate the list when its done? And change the cached list to a defvar

dunn commented 7 years ago

Sorry for the delay in replying! That sounds promising, if you want to try making that change.

torgeir commented 7 years ago

I won't have time to have a go at this in the near future, feel free to close it

wyuenho commented 6 years ago

@dunn You can use a :set keyword to recreate the list of emojis when the aliases have changed. https://www.gnu.org/software/emacs/manual/html_node/elisp/Variable-Definitions.html

torgeir commented 6 years ago

So this took a while :grin:

The last commit prefixes the cached list of emojis and uses :set as per @wyuenho's suggestion to recreate the cached list on company-emoji-aliases change.

torgeir commented 6 years ago

And on second thoughts I really don't see how this is nescessary as the aliases are looked up at runtime when invoking company-emoji, before the list of emojis is consulted.

https://github.com/dunn/company-emoji/blob/master/company-emoji.el#L192-L193

torgeir commented 6 years ago

Yeah, it has no effect. Reverted it to keep only the namespaced var. Seems to work fine on my end, with added user aliases appearing instantly.

dunn commented 6 years ago

Thanks so much!