yuya373 / emacs-slack

slack client for emacs
1.11k stars 117 forks source link

Tracking behavior for threads and reactions #519

Open chasecaleb opened 4 years ago

chasecaleb commented 4 years ago

Currently, all new messages in threads are added to tracking list if slack-buffer-create-on-notify is non-nil. Would you be open to adding a config option that would make it work like alerts, which only show for followed threads? I'm willing to make a PR if that helps.

Here's the kludgy way that I accomplished it with an advice:

(defun cc/slack-thread-message-update-advice (fn this room team replace)
  "Advice to prevent opening/tracking threads that are not followed."
  (let ((slack-buffer-create-on-notify
         (and slack-buffer-create-on-notify
              (slack-message-subscribed-thread-message-p this room))))
    (funcall fn this room team replace)))
(advice-add 'slack-thread-message-update-buffer :around 'cc/slack-thread-message-update-advice)
chasecaleb commented 4 years ago

After a little more investigation, it looks like my advice only half works. It prevents the thread from becoming tracked, but the room containing the thread is still tracked if the room is not open and slack-buffer-create-on-notify is non-nil.

I'm having a really hard time wrapping my head around what's going on due to the size and complexity of this package. Ideally I would like the following behavior, regardless of what buffers are already open:

Can you point me in the right direction to accomplish this? I know that functions can be added tracking-ignored-buffers from tracking.el, which might be a better way. However the function is only provided the buffer as an argument, and I can't figure out how to get the right information there.