weechat / weechat

The extensible chat client.

Home Page:https://weechat.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API function to update hotlist for a buffer with direct values

trygveaa opened this issue · comments

Feature description

Currently the only way to change the hotlist as far as I know is to increase one of the priorities by one, or to clear it for a buffer. It would be useful with an API function that lets you set/update the hotlist for a buffer by explicitly setting the number of lines for each priority as well as setting a custom creation time.

The use case for this is when loading history in slack.py. It's may load unread messages in several buffers and currently they will appear in the hotlist in the order they are loaded. By being able to set the creation time, I would be able to sort the hotlist in the correct order by message time, like it would be sorted when new messages arrive.

Additionally, the way it loads messages is to first just set the hotlist without printing any lines, and then at a later time printing the messages in the buffer. This is done for performance reasons and because of rate limiting in certain Slack API functions. Also, the number set in the hotlist when first loading may not be exactly correct, so it has to be updated when printing the lines in the buffer. Currently, I either have to clear the hotlist first and print the lines to get the correct amount which changes the hotlist order, or I have to check the current value of the hotlist, and set notify_none on some of the lines I print to get the correct amount (though, setting notify_none has other implications as well). If I could update the hotlist with the correct amount and creation time after printing the lines, it would be much simpler and I would avoid these problems.