Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: Rasmus <rasmus@gmx.us>
To: info-gnus-english@gnu.org
Subject: [patches] mark as read with gnus notification
Date: Sat, 07 Mar 2015 18:21:00 +0100	[thread overview]
Message-ID: <871tl0k9kz.fsf@gmx.us> (raw)

[-- 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




             reply	other threads:[~2015-03-07 17:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-07 17:21 Rasmus [this message]
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

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

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

  git send-email \
    --in-reply-to=871tl0k9kz.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --cc=info-gnus-english@gnu.org \
    /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.
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).