-;; erc-desktop-notifications.el -- Send notification on PRIVMSG or mentions
+;; erc-desktop-notifications.el -- Send notification on PRIVMSG or mentions -*- lexical-binding:t -*-
;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
This will replace the last notification sent with this function."
(dbus-ignore-errors
(setq erc-notifications-last-notification
- (notifications-notify :bus erc-notifications-bus
- :title (xml-escape-string nick)
- :body (xml-escape-string msg)
- :replaces-id erc-notifications-last-notification
- :app-icon erc-notifications-icon))))
-
-(defun erc-notifications-PRIVMSG (proc parsed)
+ (let ((channel (current-buffer)))
+ (notifications-notify :bus erc-notifications-bus
+ :title (format "%s in %s"
+ (xml-escape-string nick)
+ channel)
+ :body (xml-escape-string msg)
+ :replaces-id erc-notifications-last-notification
+ :app-icon erc-notifications-icon
+ :actions '("default" "Switch to buffer")
+ :on-action (lambda (&rest _)
+ (pop-to-buffer channel)))))))
+
+(defun erc-notifications-PRIVMSG (_proc parsed)
(let ((nick (car (erc-parse-user (erc-response.sender parsed))))
(target (car (erc-response.command-args parsed)))
(msg (erc-response.contents parsed)))