summaryrefslogtreecommitdiffstatsabout
authorJulien Danjou <julien@danjou.info>2012-08-29 14:35:32 (GMT)
committer Julien Danjou <julien@danjou.info>2012-08-29 14:44:20 (GMT)
commita3e8da79ece592d0db266903049b80c966c00cf8 (patch) (side-by-side diff)
tree71b4a1ea5dbec85ba24a70d412ce137eed39b6ec
parent7b7db76666fae115c7ec0cc78ca96ea4e177ba4e (diff)
downloadgnus-a3e8da79ece592d0db266903049b80c966c00cf8.zip
gnus-notifications: add indirections
So we don't fail on emacsen without notifications library. Signed-off-by: Julien Danjou <julien@danjou.info>
-rw-r--r--lisp/ChangeLog2
-rw-r--r--lisp/gnus-notifications.el27
2 files changed, 20 insertions, 9 deletions
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 <julien@danjou.info>
* gnus-notifications.el: New file.
+ (gnus-notifications-notify): New function.
+ (gnus-notifications): Use `gnus-notifications-notify'.
2012-08-28 Katsumi Yamaoka <yamaoka@jpl.org>
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
@@ -87,7 +99,7 @@ Returns nil if no image found."
(let ((photo-file (make-temp-file "gnus-notifications-photo-"))
(coding-system-for-write 'binary))
(with-temp-file photo-file
- (insert photo))
+ (insert photo))
photo-file))))
;;;###autoload
@@ -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