From 12a9381803205f195ac457d9e569004b32b477e5 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Thu, 23 Jul 2009 17:33:52 +0200 Subject: [PATCH] Add and use a new option: org-show-notification-handler This option lets the user customize the notification mechanism. For example, she might want to use todochiku.el. This option defaults to nil, hence doesn't change the previous behavior: if the program notify-send is installed on the system, use it, and falls back on using (message [notification]) if not. --- lisp/ChangeLog | 5 +++++ lisp/org-clock.el | 24 ++++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9cb0aa5a1..1d2746f19 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2009-07-23 Bastien Guerry + + * org-clock.el (org-show-notification-handler): New option. + (org-show-notification): Use the new option. + 2009-07-21 Bastien Guerry * org.el (org-eval-in-calendar): Fix a bug about calendar diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 594d3cf4b..8d70fd3ca 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -192,6 +192,15 @@ auto Automtically, either `all', or `repeat' for repeating tasks" (const :tag "All task time" all) (const :tag "Automatically, `all' or since `repeat'" auto))) +(defcustom org-show-notification-handler nil + "Function or program to send notification with. +The function or program will be called with the notification +string as argument." + :group 'org-clock + :type '(choice + (string :tag "Program") + (function :tag "Function"))) + (defvar org-clock-in-prepare-hook nil "Hook run when preparing the clock. This hook is run before anything happens to the task that @@ -441,10 +450,17 @@ Notification is shown only once." (defun org-show-notification (notification) "Show notification. Use libnotify, if available." - (if (org-program-exists "notify-send") - (start-process "emacs-timer-notification" nil "notify-send" notification)) - ;; In any case, show in message area - (message notification)) + (cond ((functionp org-show-notification-handler) + (funcall org-show-notification-handler notification)) + ((stringp org-show-notification-handler) + (start-process "emacs-timer-notification" nil + org-show-notification-handler notification)) + ((org-program-exists "notify-send") + (start-process "emacs-timer-notification" nil + "notify-send" notification)) + ;; Maybe the handler will send a message, so only use message as + ;; a fall back option + (t (message notification)))) (defun org-clock-play-sound () "Play sound as configured by `org-clock-sound'.