[gnus git] branch master updated: m0-5-91-ga3e8da7 =1= gnus-notifications: add indirections

Julien Danjou <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  a3e8da79ece592d0db266903049b80c966c00cf8 (commit)
      from  7b7db76666fae115c7ec0cc78ca96ea4e177ba4e (commit)


- Log -----------------------------------------------------------------
commit a3e8da79ece592d0db266903049b80c966c00cf8
Author: Julien Danjou <[email protected]>
Date:   Wed Aug 29 16:35:32 2012 +0200

    gnus-notifications: add indirections
    
    So we don't fail on emacsen without notifications library.
    
    Signed-off-by: Julien Danjou <[email protected]>

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 91b5d68..aad8bf6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,6 +1,8 @@
 2012-08-29  Julien Danjou  <[email protected]>
 
 	* gnus-notifications.el: New file.
+	(gnus-notifications-notify): New function.
+	(gnus-notifications): Use `gnus-notifications-notify'.
 
 2012-08-28  Katsumi Yamaoka  <[email protected]>
 
diff --git a/lisp/gnus-notifications.el b/lisp/gnus-notifications.el
index 348bbbe..8811b47 100644
--- a/lisp/gnus-notifications.el
+++ b/lisp/gnus-notifications.el
@@ -29,7 +29,7 @@
 
 ;;; Code:
 
-(require 'notifications)
+(require 'notifications nil t)
 (require 'gnus-sum)
 (require 'gnus-group)
 (require 'gnus-int)
@@ -61,6 +61,18 @@ not get notifications."
 (defvar gnus-notifications-sent nil
   "Notifications already sent.")
 
+(defun gnus-notifications-notify (from subject photo-file)
+  "Send a notification about a new mail."
+  (if (fboundp 'notifications-notify)
+      (notifications-notify
+       :title from
+       :body subject
+       :app-icon (image-search-load-path "gnus/gnus.png")
+       :app-name "Gnus"
+       :category "email.arrived"
+       :image-path photo-file)
+    (message "New message from %s: %s" from subject)))
+
 (defun gnus-notifications-get-photo (mail-address)
   "Get photo for mail address."
   (let ((google-photo (when (and gnus-notifications-use-google-contacts
@@ -131,13 +143,10 @@ This is typically a function to add in
                          ;; Ignore mails from ourselves
                          (gnus-string-match-p gnus-ignored-from-addresses
                                               address)
-                         (notifications-notify :title (concat "New message from "
-                                                              (or (car address-components) address))
-                                               :body (mail-fetch-field "Subject")
-                                               :app-icon (image-search-load-path "gnus/gnus.png")
-                                               :app-name "Gnus"
-                                               :category "email.arrived"
-                                               :image-path photo-file))
+                         (gnus-notifications-notify
+                          (or (car address-components) address)
+                          (mail-fetch-field "Subject")
+                          photo-file))
                     ;; Register that we did notify this message
                     (setcdr group-notifications (cons article (cdr group-notifications))))
                   (when photo-file

-----------------------------------------------------------------------
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             |    2 ++
 lisp/gnus-notifications.el |   27 ++++++++++++++++++---------
 2 files changed, 20 insertions(+), 9 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.