unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alex Murray <murray.alex@gmail.com>
To: "Basil L. Contovounesios" <contovob@tcd.ie>
Cc: 35141@debbugs.gnu.org
Subject: bug#35141: Add a default action to erc-desktop-notifications to switch to the originating buffer
Date: Sat, 6 Apr 2019 20:22:38 +1030	[thread overview]
Message-ID: <CAA6Afg6XS71bQyqQwRALpJ9q1Ym9n6Lk__8Lsa2RNnrHzK-4AA@mail.gmail.com> (raw)
In-Reply-To: <87d0m08zni.fsf@tcd.ie>


[-- Attachment #1.1: Type: text/plain, Size: 819 bytes --]

Done - see attached. Thanks again for your help.

On Fri, 5 Apr 2019 at 21:52, Basil L. Contovounesios <contovob@tcd.ie>
wrote:

> Alex Murray <murray.alex@gmail.com> writes:
>
> > Thanks for the review - see attached for an updated version based on
> your feedback.
>
> I just tried byte-compiling the patched file and got the following
> warning:
>
>   ELC      erc/erc-desktop-notifications.elc
>   In toplevel form:
>   erc/erc-desktop-notifications.el:74:1:
>   Warning: Unused lexical argument ‘proc’
>
> Since this arises because of lexical-binding, could you please also add
> an underscore to the name of the PROC argument in
> erc-notifications-PRIVMSG?
>
> Otherwise LGTM, but we'll have to wait a few days to give others a
> chance to comment.
>
> Thanks,
>
> --
> Basil
>

[-- Attachment #1.2: Type: text/html, Size: 1227 bytes --]

[-- Attachment #2: 0001-Switch-to-originating-erc-buffer-when-clicking-deskt.patch --]
[-- Type: text/x-patch, Size: 2672 bytes --]

From 58677b493ba8fbdc32be7e7763463b6c6cc59a0d Mon Sep 17 00:00:00 2001
From: Alex Murray <murray.alex@gmail.com>
Date: Thu, 4 Apr 2019 16:49:48 +1030
Subject: [PATCH] Switch 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 switches to the buffer from which the
  notification originated. As such clicking on the notification now
  automatically switches to that buffer. (Bug#35141)

Copyright-paperwork-exempt: yes
---
 lisp/erc/erc-desktop-notifications.el | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/lisp/erc/erc-desktop-notifications.el b/lisp/erc/erc-desktop-notifications.el
index 56b93925ce..41b7420320 100644
--- a/lisp/erc/erc-desktop-notifications.el
+++ b/lisp/erc/erc-desktop-notifications.el
@@ -1,4 +1,4 @@
-;; 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.
 
@@ -59,13 +59,19 @@
 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)))
-- 
2.17.1


  reply	other threads:[~2019-04-06  9:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-04  6:32 bug#35141: Add a default action to erc-desktop-notifications to switch to the originating buffer Alex Murray
2019-04-05  2:13 ` Basil L. Contovounesios
2019-04-05  3:22   ` Alex Murray
2019-04-05 11:22     ` Basil L. Contovounesios
2019-04-06  9:52       ` Alex Murray [this message]
2019-04-12 12:16         ` Basil L. Contovounesios
2019-04-14 12:17           ` Alex Murray

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAA6Afg6XS71bQyqQwRALpJ9q1Ym9n6Lk__8Lsa2RNnrHzK-4AA@mail.gmail.com \
    --to=murray.alex@gmail.com \
    --cc=35141@debbugs.gnu.org \
    --cc=contovob@tcd.ie \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).