Function: erc-notifications-notify

erc-notifications-notify is a byte-compiled function defined in erc-desktop-notifications.el.gz.

Signature

(erc-notifications-notify NICK MSG &optional PRIVP)

Documentation

Notify that NICK send some MSG, where PRIVP should be non-nil for PRIVMSGs.

This will replace the last notification sent with this function.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-desktop-notifications.el.gz
(defvar dbus-debug) ; used in the macroexpansion of dbus-ignore-errors

(defun erc-notifications-notify (nick msg &optional privp)
  "Notify that NICK send some MSG, where PRIVP should be non-nil for PRIVMSGs.
This will replace the last notification sent with this function."
  ;; TODO: can we do this without PRIVP? (by "fixing" ERC's not
  ;; setting the current buffer to the existing query buffer)
  (dbus-ignore-errors
    (setq erc-notifications-last-notification
          (let* ((channel (if privp (erc-get-buffer nick) (current-buffer)))
                 (title (format "%s in %s" (xml-escape-string nick t) channel))
                 (body (xml-escape-string (erc-controls-strip msg) t)))
            (notifications-notify :bus erc-notifications-bus
                                  :title title
                                  :body body
                                  :replaces-id erc-notifications-last-notification
                                  :app-icon erc-notifications-icon
                                  :actions '("default" "Switch to buffer")
                                  :on-action (lambda (&rest _)
                                               (pop-to-buffer channel)))))))