[gnus git] branch master updated: m0-5-99-g873ba7b =2= gnus-notifications: add actions support ; gnus-notifications: add defcustom for timeout
Julien Danjou <[email protected]>
| Newsgroups | gmane.emacs.gnus.cvs |
|---|---|
| Message-ID | <[email protected]> |
via 873ba7b51ddfb07246cd874b7de72662308236c9 (commit)
via 5ec87d41036dbfce308619f729531b2683917ed4 (commit)
from afdb0e3005c7bc272b37602693eb24169fe9c0de (commit)
- Log -----------------------------------------------------------------
commit 873ba7b51ddfb07246cd874b7de72662308236c9
Author: Julien Danjou <[email protected]>
Date: Thu Aug 30 17:16:48 2012 +0200
gnus-notifications: add actions support
Signed-off-by: Julien Danjou <[email protected]>
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 925f98a..e852269 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -3,6 +3,12 @@
* gnus-notifications.el (gnus-notifications-notify): Use timeout from
`gnus-notifications-timeout'.
(gnus-notifications-timeout): Add.
+ (gnus-notifications-action): New function.
+ (gnus-notifications-notify): Add :action using
+ `gnus-notifications-action'.
+ (gnus-notifications-id-to-msg): New variable.
+ (gnus-notifications): Use `gnus-notifications-id-to-msg' to map
+ notifications id to messages.
2012-08-29 Julien Danjou <[email protected]>
diff --git a/lisp/gnus-notifications.el b/lisp/gnus-notifications.el
index 1c517c2..811a908 100644
--- a/lisp/gnus-notifications.el
+++ b/lisp/gnus-notifications.el
@@ -66,18 +66,34 @@ not get notifications."
(defvar gnus-notifications-sent nil
"Notifications already sent.")
+(defvar gnus-notifications-id-to-msg nil
+ "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 (caddr group-article)))
+ (gnus-fetch-group group (list article)))))))
+
(defun gnus-notifications-notify (from subject photo-file)
- "Send a notification about a new mail."
+ "Send a notification about a new mail.
+Return a notification id if any, or t on success."
(if (fboundp 'notifications-notify)
(notifications-notify
:title from
:body subject
+ :actions '("read" "Read")
+ :on-action 'gnus-notifications-action
:app-icon (image-search-load-path "gnus/gnus.png")
:app-name "Gnus"
:category "email.arrived"
:timeout gnus-notifications-timeout
:image-path photo-file)
- (message "New message from %s: %s" from subject)))
+ (message "New message from %s: %s" from subject)
+ ;; Don't return an id
+ t))
(defun gnus-notifications-get-photo (mail-address)
"Get photo for mail address."
@@ -142,21 +158,23 @@ This is typically a function to add in
(article-decode-encoded-words) ; to decode mail addresses, subjects, etc
(let* ((address-components (mail-extract-address-components
(or (mail-fetch-field "From") "")))
- (address (cadr address-components))
- (photo-file (gnus-notifications-get-photo-file
- address)))
- (when (or
+ (address (cadr address-components)))
;; Ignore mails from ourselves
- (gnus-string-match-p gnus-ignored-from-addresses
+ (unless (gnus-string-match-p gnus-ignored-from-addresses
address)
- (gnus-notifications-notify
+ (let* ((photo-file (gnus-notifications-get-photo-file address))
+ (notification-id (gnus-notifications-notify
(or (car address-components) address)
(mail-fetch-field "Subject")
- photo-file))
+ photo-file)))
+ (when notification-id
;; Register that we did notify this message
- (setcdr group-notifications (cons article (cdr group-notifications))))
+ (setcdr group-notifications (cons article (cdr group-notifications)))
+ (unless (eq notification-id t)
+ ;; Register the notification id for later actions
+ (add-to-list 'gnus-notifications-id-to-msg (list notification-id group article))))
(when photo-file
- (delete-file photo-file)))))))))))
+ (delete-file photo-file)))))))))))))
(provide 'gnus-notifications)
commit 5ec87d41036dbfce308619f729531b2683917ed4
Author: Julien Danjou <[email protected]>
Date: Thu Aug 30 15:57:51 2012 +0200
gnus-notifications: add defcustom for timeout
Signed-off-by: Julien Danjou <[email protected]>
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index aad8bf6..925f98a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2012-08-30 Julien Danjou <[email protected]>
+
+ * gnus-notifications.el (gnus-notifications-notify): Use timeout from
+ `gnus-notifications-timeout'.
+ (gnus-notifications-timeout): Add.
+
2012-08-29 Julien Danjou <[email protected]>
* gnus-notifications.el: New file.
diff --git a/lisp/gnus-notifications.el b/lisp/gnus-notifications.el
index 8811b47..1c517c2 100644
--- a/lisp/gnus-notifications.el
+++ b/lisp/gnus-notifications.el
@@ -58,6 +58,11 @@ not get notifications."
:type 'integer
:group 'gnus-notifications)
+(defcustom gnus-notifications-timeout nil
+ "Timeout used for notifications sent via `notifications-notify'."
+ :type 'integer
+ :group 'gnus-notifications)
+
(defvar gnus-notifications-sent nil
"Notifications already sent.")
@@ -70,6 +75,7 @@ not get notifications."
:app-icon (image-search-load-path "gnus/gnus.png")
:app-name "Gnus"
:category "email.arrived"
+ :timeout gnus-notifications-timeout
:image-path photo-file)
(message "New message from %s: %s" from subject)))
-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.
Summary of changes:
lisp/ChangeLog | 12 +++++++++
lisp/gnus-notifications.el | 58 +++++++++++++++++++++++++++++++-------------
2 files changed, 53 insertions(+), 17 deletions(-)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".
The branch, master has been updated
hooks/post-receive
--
Gnus Project