diff options
| author | Alex Murray | 2019-04-04 16:49:48 +1030 |
|---|---|---|
| committer | Basil L. Contovounesios | 2019-04-12 13:08:28 +0100 |
| commit | 6dc4c722af4e5f9f189631638700cd1fb3cc2edb (patch) | |
| tree | 1fc30f8cbacf699fc300f334948726bf502a1274 | |
| parent | 2b82c829706808668ea2e8a63b6bc4351d93afc2 (diff) | |
| download | emacs-6dc4c722af4e5f9f189631638700cd1fb3cc2edb.tar.gz emacs-6dc4c722af4e5f9f189631638700cd1fb3cc2edb.zip | |
Pop to originating erc buffer when clicking desktop notification
* lisp/erc/erc-desktop-notifications.el: Switch to lexical-binding.
(erc-notifications-notify): Add a default action to the desktop
notification which pops to the buffer from which the notification
originated. (Bug#35141)
Copyright-paperwork-exempt: yes
| -rw-r--r-- | lisp/erc/erc-desktop-notifications.el | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lisp/erc/erc-desktop-notifications.el b/lisp/erc/erc-desktop-notifications.el index 56b93925ced..41b7420320c 100644 --- a/lisp/erc/erc-desktop-notifications.el +++ b/lisp/erc/erc-desktop-notifications.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;; erc-desktop-notifications.el -- Send notification on PRIVMSG or mentions | 1 | ;; erc-desktop-notifications.el -- Send notification on PRIVMSG or mentions -*- lexical-binding:t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2012-2019 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2012-2019 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -59,13 +59,19 @@ | |||
| 59 | This will replace the last notification sent with this function." | 59 | This will replace the last notification sent with this function." |
| 60 | (dbus-ignore-errors | 60 | (dbus-ignore-errors |
| 61 | (setq erc-notifications-last-notification | 61 | (setq erc-notifications-last-notification |
| 62 | (notifications-notify :bus erc-notifications-bus | 62 | (let ((channel (current-buffer))) |
| 63 | :title (xml-escape-string nick) | 63 | (notifications-notify :bus erc-notifications-bus |
| 64 | :body (xml-escape-string msg) | 64 | :title (format "%s in %s" |
| 65 | :replaces-id erc-notifications-last-notification | 65 | (xml-escape-string nick) |
| 66 | :app-icon erc-notifications-icon)))) | 66 | channel) |
| 67 | 67 | :body (xml-escape-string msg) | |
| 68 | (defun erc-notifications-PRIVMSG (proc parsed) | 68 | :replaces-id erc-notifications-last-notification |
| 69 | :app-icon erc-notifications-icon | ||
| 70 | :actions '("default" "Switch to buffer") | ||
| 71 | :on-action (lambda (&rest _) | ||
| 72 | (pop-to-buffer channel))))))) | ||
| 73 | |||
| 74 | (defun erc-notifications-PRIVMSG (_proc parsed) | ||
| 69 | (let ((nick (car (erc-parse-user (erc-response.sender parsed)))) | 75 | (let ((nick (car (erc-parse-user (erc-response.sender parsed)))) |
| 70 | (target (car (erc-response.command-args parsed))) | 76 | (target (car (erc-response.command-args parsed))) |
| 71 | (msg (erc-response.contents parsed))) | 77 | (msg (erc-response.contents parsed))) |