alphapapa / ement.el

A Matrix client for GNU Emacs
GNU General Public License v3.0
493 stars 44 forks source link

tracking.el support #27

Open alphapapa opened 3 years ago

alphapapa commented 3 years ago

Wibjarm posted this in #ement.el:matrix.org:

So it turns out to be conveniently simple to plug ement into the modeline channel tracking from circe and get my preferred setup of "tag in the modeline on new messages, desktop notification on mentions"

(defun my/ement-notify-track-if-buffer (event room session)
    (when (ement-notify--room-buffer-live-p event room session)
      (tracking-add-buffer (map-elt (ement-room-local room) 'buffer))))

It's literally just adding this to ement-notify-functions

I'm not sure what the best thing to do now is: add this to the readme as a simple example of code users can copy into their config, put it in an ement-tracking.el file that users can load, or put it into ement-notify.el in a way that avoids compile-time, load-time, and run-time warnings.

viiru- commented 1 year ago

Any clues on how one might implement this in the current codebase as ement-notify-functions no longer exists since commit 70da19e4c921?

viiru- commented 1 year ago

Here is how I ended up doing this on version 0.5.2:

(cl-defun viiru/ement-notify-track-if-buffer (event room session &key (buffer-name "*Ement Notifications*"))
  (with-demoted-errors "viiru/ement-notify-track-if-buffer: %S"
    (when (ement-notify--room-buffer-live-p event room session)
      (tracking-add-buffer (map-elt (ement-room-local room) 'buffer)))))

(advice-add 'ement-notify--log-to-buffer :after #'viiru/ement-notify-track-if-buffer)
mokrates commented 1 year ago

Where do I get the "tracking-add-buffer" function from? Circe?

Ok, I didn't get it running. I also think, if you should use some foreign tracking library, perhaps use one that is included in vanilla emacs? the one from ERC?

viiru- commented 1 year ago

No, this is based on tracking.el from circe. The current version of my setup is here: https://gist.github.com/viiru-/685134a1781816e83df68520a4862599

I also do a bunch of other stuff to adjust how the room names are shortened and so on (to get closer to what I had under ERC), but those are easy enough to adjust to taste.