Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* [patches] mark as read with gnus notification
@ 2015-03-07 17:21 Rasmus
  2015-03-07 22:01 ` Adam Sjøgren
  2015-03-07 22:30 ` Adam Sjøgren
  0 siblings, 2 replies; 6+ messages in thread
From: Rasmus @ 2015-03-07 17:21 UTC (permalink / raw)
  To: info-gnus-english

[-- Attachment #1: Type: text/plain, Size: 442 bytes --]

Hi,

Two patches to gnus-notification that should apply against master.  I'm
sending them here since apparently gmane.emacs.gnus.general is down or
something.  I hope somebody will apply them nonetheless.

1. Raise frame when clicking read.
2. Allow to mark as read from notification, e.g. for notification ("your
   order has shipped")

My paperwork is sorted out.

—Rasmus

-- 
Slowly unravels in a ball of yarn and the devil collects it

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnus-notifications-Raise-frame-when-clicking-Read.patch --]
[-- Type: text/x-diff, Size: 1411 bytes --]

From b567a21d3039be1f1c82f35057543440ba074760 Mon Sep 17 00:00:00 2001
From: rasmus <x200s@pank.eu>
Date: Sat, 7 Mar 2015 18:10:03 +0100
Subject: [PATCH 1/2] gnus-notifications: Raise frame when clicking Read

* gnus-notifications.el (gnus-notifications-action): Raise window
  frame.
---
 lisp/ChangeLog             | 5 +++++
 lisp/gnus-notifications.el | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2047481..b6526b7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-07  Rasmus Pank Roulund  <rasmus@pank.eu>
+
+	* gnus-notifications.el (gnus-notifications-action): Raise window
+	frame.
+
 2015-02-26  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 	* gnus-art.el (gnus-mime-inline-part, gnus-mm-display-part):
diff --git a/lisp/gnus-notifications.el b/lisp/gnus-notifications.el
index 2941cc4..1ed344e 100644
--- a/lisp/gnus-notifications.el
+++ b/lisp/gnus-notifications.el
@@ -80,7 +80,8 @@ not get notifications."
       (when group-article
         (let ((group (cadr group-article))
               (article (nth 2 group-article)))
-          (gnus-fetch-group group (list article)))))))
+          (gnus-fetch-group group (list article))
+          (when (window-system) (x-focus-frame (selected-frame))))))))
 
 (defun gnus-notifications-notify (from subject photo-file)
   "Send a notification about a new mail.
-- 
2.3.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-gnus-notification.el-Add-mark-as-read.patch --]
[-- Type: text/x-diff, Size: 2610 bytes --]

From f73b285a33d40cd217bc45861d9308f831ffd0c3 Mon Sep 17 00:00:00 2001
From: rasmus <x200s@pank.eu>
Date: Sat, 7 Mar 2015 18:12:41 +0100
Subject: [PATCH 2/2] gnus-notification.el: Add mark as read

* gnus-notifications.el (gnus-notifications-action): Allow mark as read.
  (gnus-notifications-notify): Show uption to mark as read.
---
 lisp/ChangeLog             |  2 ++
 lisp/gnus-notifications.el | 22 ++++++++++++++--------
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b6526b7..072c6fc 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -2,6 +2,8 @@
 
 	* gnus-notifications.el (gnus-notifications-action): Raise window
 	frame.
+	(gnus-notifications-action): Allow mark as read.
+	(gnus-notifications-notify): Show uption to mark as read.
 
 2015-02-26  Katsumi Yamaoka  <yamaoka@jpl.org>
 
diff --git a/lisp/gnus-notifications.el b/lisp/gnus-notifications.el
index 1ed344e..7f8fd9e 100644
--- a/lisp/gnus-notifications.el
+++ b/lisp/gnus-notifications.el
@@ -75,13 +75,19 @@ not get notifications."
   "Map notifications ids to messages.")
 
 (defun gnus-notifications-action (id key)
-  (when (string= key "read")
-    (let ((group-article (assoc id gnus-notifications-id-to-msg)))
-      (when group-article
-        (let ((group (cadr group-article))
-              (article (nth 2 group-article)))
-          (gnus-fetch-group group (list article))
-          (when (window-system) (x-focus-frame (selected-frame))))))))
+  (let ((group-article (assoc id gnus-notifications-id-to-msg)))
+    (when group-article
+      (let ((group (cadr group-article))
+            (article (nth 2 group-article)))
+        (cond ((string= key "read")
+               (gnus-fetch-group group (list article))
+               (when (window-system) (x-focus-frame (selected-frame))))
+              ((string= key "mark-read")
+               (gnus-update-read-articles
+                group
+                (delq article (gnus-list-of-unread-articles group)))
+               ;; gnus-group-refresh-group
+               (gnus-group-update-group group)))))))
 
 (defun gnus-notifications-notify (from subject photo-file)
   "Send a notification about a new mail.
@@ -91,7 +97,7 @@ Return a notification id if any, or t on success."
        'notifications-notify
        :title from
        :body subject
-       :actions '("read" "Read")
+       :actions '("read" "Read" "mark-read" "Mark As Read")
        :on-action 'gnus-notifications-action
        :app-icon (gnus-funcall-no-warning
                   'image-search-load-path "gnus/gnus.png")
-- 
2.3.1




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-03-08 21:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-07 17:21 [patches] mark as read with gnus notification Rasmus
2015-03-07 22:01 ` Adam Sjøgren
2015-03-07 22:30 ` Adam Sjøgren
2015-03-07 22:43   ` Adam Sjøgren
2015-03-08 20:58     ` Adam Sjøgren
2015-03-08 21:29       ` Rasmus

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 NNTP newsgroup(s).