* bug#35141: Add a default action to erc-desktop-notifications to switch to the originating buffer
@ 2019-04-04 6:32 Alex Murray
2019-04-05 2:13 ` Basil L. Contovounesios
0 siblings, 1 reply; 7+ messages in thread
From: Alex Murray @ 2019-04-04 6:32 UTC (permalink / raw)
To: 35141
[-- Attachment #1.1: Type: text/plain, Size: 221 bytes --]
Attached is a patch which converts erc-desktop-notifications.el to
lexical-binding and adds a default action to the generated notifications so
that when they are clicked we automatically switch to the originating
buffer.
[-- Attachment #1.2: Type: text/html, Size: 242 bytes --]
[-- Attachment #2: 0001-Switch-to-originating-erc-buffer-when-clicking-deskt.patch --]
[-- Type: text/x-patch, Size: 2986 bytes --]
From 52b63272eed8aaafcd931e833ad006dd425d6512 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 and
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.
---
ChangeLog.3 | 7 +++++++
lisp/erc/erc-desktop-notifications.el | 18 ++++++++++++------
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/ChangeLog.3 b/ChangeLog.3
index 235c8bb180..3819d6b4fe 100644
--- a/ChangeLog.3
+++ b/ChangeLog.3
@@ -1,3 +1,10 @@
+2019-04-04 Alex Murray <murray.alex@gmail.com>
+
+ * lisp/erc/erc-desktop-notifications.el: Use lexical-binding.
+ (erc-notifications-notify): Add a default action to
+ notifications which switches to the buffer from which the
+ notification originated.
+
2019-03-20 Eli Zaretskii <eliz@gnu.org>
Improve indexing of the user manual
diff --git a/lisp/erc/erc-desktop-notifications.el b/lisp/erc/erc-desktop-notifications.el
index 56b93925ce..c1b812c119 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,11 +59,17 @@
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))))
+ (let ((channel (current-buffer)))
+ (notifications-notify :bus erc-notifications-bus
+ :title (format "%s in %s"
+ (xml-escape-string nick)
+ (buffer-name 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 (id action)
+ (switch-to-buffer channel)))))))
(defun erc-notifications-PRIVMSG (proc parsed)
(let ((nick (car (erc-parse-user (erc-response.sender parsed))))
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#35141: Add a default action to erc-desktop-notifications to switch to the originating buffer
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
0 siblings, 1 reply; 7+ messages in thread
From: Basil L. Contovounesios @ 2019-04-05 2:13 UTC (permalink / raw)
To: Alex Murray; +Cc: 35141
Alex Murray <murray.alex@gmail.com> writes:
> Attached is a patch which converts erc-desktop-notifications.el to
> lexical-binding and adds a default action to the generated
> notifications so that when they are clicked we automatically switch to
> the originating buffer.
SGTM.
> From 52b63272eed8aaafcd931e833ad006dd425d6512 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 and
> 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.
Please mention the name of the function changed:
* lisp/erc/erc-desktop-notifications.el: Switch to lexical-binding.
(erc-notifications-notify): Add ...
Unless you have completed your copyright assignment for contributions to
Emacs, the commit message should also include:
Copyright-paperwork-exempt: yes
For more details, see the file CONTRIBUTE.
> diff --git a/ChangeLog.3 b/ChangeLog.3
> index 235c8bb180..3819d6b4fe 100644
> --- a/ChangeLog.3
> +++ b/ChangeLog.3
> @@ -1,3 +1,10 @@
> +2019-04-04 Alex Murray <murray.alex@gmail.com>
> +
> + * lisp/erc/erc-desktop-notifications.el: Use lexical-binding.
> + (erc-notifications-notify): Add a default action to
> + notifications which switches to the buffer from which the
> + notification originated.
> +
> 2019-03-20 Eli Zaretskii <eliz@gnu.org>
>
> Improve indexing of the user manual
ChangeLog files are no longer maintained by hand, but rather generated
from Git commit messages.
> diff --git a/lisp/erc/erc-desktop-notifications.el b/lisp/erc/erc-desktop-notifications.el
> index 56b93925ce..c1b812c119 100644
> --- a/lisp/erc/erc-desktop-notifications.el
> +++ b/lisp/erc/erc-desktop-notifications.el
> @@ -59,11 +59,17 @@
> 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))))
> + (let ((channel (current-buffer)))
> + (notifications-notify :bus erc-notifications-bus
> + :title (format "%s in %s"
> + (xml-escape-string nick)
> + (buffer-name channel))
No need for buffer-name; you can pass buffers directly to "%s".
> + :body (xml-escape-string msg)
> + :replaces-id erc-notifications-last-notification
> + :app-icon erc-notifications-icon
> + :actions '("default" "Switch to buffer")
> + :on-action #'(lambda (id action)
> + (switch-to-buffer channel)))))))
This should instead be something like the following:
(lambda (&rest _)
(pop-to-buffer channel))
In particular, lambdas don't need to be quoted with #', pop-to-buffer is
far better behaved than switch-to-buffer, and unused argument names
should either start with an underscore or be omitted.
Thanks,
--
Basil
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#35141: Add a default action to erc-desktop-notifications to switch to the originating buffer
2019-04-05 2:13 ` Basil L. Contovounesios
@ 2019-04-05 3:22 ` Alex Murray
2019-04-05 11:22 ` Basil L. Contovounesios
0 siblings, 1 reply; 7+ messages in thread
From: Alex Murray @ 2019-04-05 3:22 UTC (permalink / raw)
To: Basil L. Contovounesios; +Cc: 35141
[-- Attachment #1.1: Type: text/plain, Size: 4056 bytes --]
Hi Basil,
Thanks for the review - see attached for an updated version based on your
feedback.
Cheers,
Alex
On Fri, 5 Apr 2019 at 12:43, Basil L. Contovounesios <contovob@tcd.ie>
wrote:
> Alex Murray <murray.alex@gmail.com> writes:
>
> > Attached is a patch which converts erc-desktop-notifications.el to
> > lexical-binding and adds a default action to the generated
> > notifications so that when they are clicked we automatically switch to
> > the originating buffer.
>
> SGTM.
>
> > From 52b63272eed8aaafcd931e833ad006dd425d6512 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 and
> > 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.
>
> Please mention the name of the function changed:
>
> * lisp/erc/erc-desktop-notifications.el: Switch to lexical-binding.
> (erc-notifications-notify): Add ...
>
> Unless you have completed your copyright assignment for contributions to
> Emacs, the commit message should also include:
>
> Copyright-paperwork-exempt: yes
>
> For more details, see the file CONTRIBUTE.
>
> > diff --git a/ChangeLog.3 b/ChangeLog.3
> > index 235c8bb180..3819d6b4fe 100644
> > --- a/ChangeLog.3
> > +++ b/ChangeLog.3
> > @@ -1,3 +1,10 @@
> > +2019-04-04 Alex Murray <murray.alex@gmail.com>
> > +
> > + * lisp/erc/erc-desktop-notifications.el: Use lexical-binding.
> > + (erc-notifications-notify): Add a default action to
> > + notifications which switches to the buffer from which the
> > + notification originated.
> > +
> > 2019-03-20 Eli Zaretskii <eliz@gnu.org>
> >
> > Improve indexing of the user manual
>
> ChangeLog files are no longer maintained by hand, but rather generated
> from Git commit messages.
>
> > diff --git a/lisp/erc/erc-desktop-notifications.el
> b/lisp/erc/erc-desktop-notifications.el
> > index 56b93925ce..c1b812c119 100644
> > --- a/lisp/erc/erc-desktop-notifications.el
> > +++ b/lisp/erc/erc-desktop-notifications.el
> > @@ -59,11 +59,17 @@
> > 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))))
> > + (let ((channel (current-buffer)))
> > + (notifications-notify :bus erc-notifications-bus
> > + :title (format "%s in %s"
> > + (xml-escape-string
> nick)
> > + (buffer-name channel))
>
> No need for buffer-name; you can pass buffers directly to "%s".
>
> > + :body (xml-escape-string msg)
> > + :replaces-id
> erc-notifications-last-notification
> > + :app-icon erc-notifications-icon
> > + :actions '("default" "Switch to
> buffer")
> > + :on-action #'(lambda (id action)
> > + (switch-to-buffer
> channel)))))))
>
> This should instead be something like the following:
>
> (lambda (&rest _)
> (pop-to-buffer channel))
>
> In particular, lambdas don't need to be quoted with #', pop-to-buffer is
> far better behaved than switch-to-buffer, and unused argument names
> should either start with an underscore or be omitted.
>
> Thanks,
>
> --
> Basil
>
[-- Attachment #1.2: Type: text/html, Size: 5455 bytes --]
[-- Attachment #2: 0001-Switch-to-originating-erc-buffer-when-clicking-deskt.patch --]
[-- Type: text/x-patch, Size: 2511 bytes --]
From f22ead6a584557deaa04a246b22574aed38aac3a 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 | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/lisp/erc/erc-desktop-notifications.el b/lisp/erc/erc-desktop-notifications.el
index 56b93925ce..4046399969 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,11 +59,17 @@
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))))
+ (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))))
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#35141: Add a default action to erc-desktop-notifications to switch to the originating buffer
2019-04-05 3:22 ` Alex Murray
@ 2019-04-05 11:22 ` Basil L. Contovounesios
2019-04-06 9:52 ` Alex Murray
0 siblings, 1 reply; 7+ messages in thread
From: Basil L. Contovounesios @ 2019-04-05 11:22 UTC (permalink / raw)
To: Alex Murray; +Cc: 35141
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#35141: Add a default action to erc-desktop-notifications to switch to the originating buffer
2019-04-05 11:22 ` Basil L. Contovounesios
@ 2019-04-06 9:52 ` Alex Murray
2019-04-12 12:16 ` Basil L. Contovounesios
0 siblings, 1 reply; 7+ messages in thread
From: Alex Murray @ 2019-04-06 9:52 UTC (permalink / raw)
To: Basil L. Contovounesios; +Cc: 35141
[-- 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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#35141: Add a default action to erc-desktop-notifications to switch to the originating buffer
2019-04-06 9:52 ` Alex Murray
@ 2019-04-12 12:16 ` Basil L. Contovounesios
2019-04-14 12:17 ` Alex Murray
0 siblings, 1 reply; 7+ messages in thread
From: Basil L. Contovounesios @ 2019-04-12 12:16 UTC (permalink / raw)
To: Alex Murray; +Cc: 35141-done
Alex Murray <murray.alex@gmail.com> writes:
> Done - see attached. Thanks again for your help.
>
> On Fri, 5 Apr 2019 at 21:52, Basil L. Contovounesios <contovob@tcd.ie> wrote:
>
> Otherwise LGTM, but we'll have to wait a few days to give others a
> chance to comment.
Thanks, pushed to master[1]. I made minor edits to the commit message
to follow CONTRIBUTE guidelines and to make it slightly more accurate
and less redundant.
[1: 6dc4c722af]: Pop to originating erc buffer when clicking desktop notification
2019-04-12 13:08:28 +0100
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=6dc4c722af4e5f9f189631638700cd1fb3cc2edb
If you're interested in making further contributions, I would recommend
starting the copyright assignment process. See CONTRIBUTE and (info
"(emacs) Copyright Assignment") for details.
Thanks,
--
Basil
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#35141: Add a default action to erc-desktop-notifications to switch to the originating buffer
2019-04-12 12:16 ` Basil L. Contovounesios
@ 2019-04-14 12:17 ` Alex Murray
0 siblings, 0 replies; 7+ messages in thread
From: Alex Murray @ 2019-04-14 12:17 UTC (permalink / raw)
To: Basil L. Contovounesios; +Cc: 35141-done
[-- Attachment #1: Type: text/plain, Size: 988 bytes --]
Thanks!
On Fri, 12 Apr 2019 at 21:46, Basil L. Contovounesios <contovob@tcd.ie>
wrote:
> Alex Murray <murray.alex@gmail.com> writes:
>
> > Done - see attached. Thanks again for your help.
> >
> > On Fri, 5 Apr 2019 at 21:52, Basil L. Contovounesios <contovob@tcd.ie>
> wrote:
> >
> > Otherwise LGTM, but we'll have to wait a few days to give others a
> > chance to comment.
>
> Thanks, pushed to master[1]. I made minor edits to the commit message
> to follow CONTRIBUTE guidelines and to make it slightly more accurate
> and less redundant.
>
> [1: 6dc4c722af]: Pop to originating erc buffer when clicking desktop
> notification
> 2019-04-12 13:08:28 +0100
>
> https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=6dc4c722af4e5f9f189631638700cd1fb3cc2edb
>
> If you're interested in making further contributions, I would recommend
> starting the copyright assignment process. See CONTRIBUTE and (info
> "(emacs) Copyright Assignment") for details.
>
> Thanks,
>
> --
> Basil
>
[-- Attachment #2: Type: text/html, Size: 1648 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-04-14 12:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2019-04-12 12:16 ` Basil L. Contovounesios
2019-04-14 12:17 ` Alex Murray
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.