branch: externals/tmr
commit cb37214ebbaffa5ea115d4358b5732e38a3fa581
Author: Daniel Mendler <m...@daniel-mendler.de>
Commit: Protesilaos Stavrou <i...@protesilaos.com>

    Move tmr-notification-notify to tmr.el
    
    Using a separate tmr-notification file is not beneficial for the minimal 
amount
    of provided functionality.
---
 tmr-notification.el | 71 -----------------------------------------------------
 tmr.el              | 31 +++++++++++++++++++++--
 2 files changed, 29 insertions(+), 73 deletions(-)

diff --git a/tmr-notification.el b/tmr-notification.el
deleted file mode 100644
index e8aace435b..0000000000
--- a/tmr-notification.el
+++ /dev/null
@@ -1,71 +0,0 @@
-;;; tmr-notification.el --- Display TMR desktop notifications -*- 
lexical-binding: t -*-
-
-;; Copyright (C) 2020-2023  Free Software Foundation, Inc.
-
-;; Author: Protesilaos Stavrou <i...@protesilaos.com>,
-;;         Damien Cassou <dam...@cassou.me>,
-;;         Daniel Mendler <m...@daniel-mendler.de>
-;; Maintainer: TMR Development <~protesilaos/t...@lists.sr.ht>
-;; URL: https://git.sr.ht/~protesilaos/tmr
-;; Mailing-List: https://lists.sr.ht/~protesilaos/tmr
-
-;; This file is NOT part of GNU Emacs.
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;
-;; Provides a function to display a desktop notification.  This is
-;; useful to get a passive popup when a timer completes.
-;;
-;; Please read the manual for all the technicalities.  Either evaluate
-;; (info "(tmr) Top") or visit <https://protesilaos.com/emacs/tmr>.
-;;
-;; Developers can also read (info "(elisp) Desktop Notifications") for
-;; details.
-
-;;; Code:
-(require 'tmr)
-(require 'notifications)
-
-(defcustom tmr-notification-urgency 'normal
-  "The urgency level of the desktop notification.
-Values can be `low', `normal' (default), or `critical'.
-
-The desktop environment or notification daemon is responsible for
-such notifications."
-  :type '(choice
-          (const :tag "Low" low)
-          (const :tag "Normal" normal)
-          (const :tag "Critical" critical))
-  :group 'tmr)
-
-;;;###autoload
-(defun tmr-notification-notify (timer)
-  "Dispatch a notification for TIMER.
-
-Read: (info \"(elisp) Desktop Notifications\") for details."
-  (if (featurep 'dbusbind)
-      (let ((title "TMR May Ring (Emacs tmr package)")
-            (body (tmr--long-description-for-finished-timer timer)))
-        (notifications-notify
-         :title title
-         :body body
-         :app-name "GNU Emacs"
-         :urgency tmr-notification-urgency
-         :sound-file tmr-sound-file))
-    (warn "Emacs has no DBUS support, TMR notifications unavailable")))
-
-(provide 'tmr-notification)
-;;; tmr-notification.el ends here
diff --git a/tmr.el b/tmr.el
index 3936a55c24..1fea3567e9 100644
--- a/tmr.el
+++ b/tmr.el
@@ -63,6 +63,17 @@ variable that contains input provided by the user at the 
relevant
 prompt of the `tmr' and `tmr-with-details' commands."
   :type '(choice symbol (repeat string)))
 
+(defcustom tmr-notification-urgency 'normal
+  "The urgency level of the desktop notification.
+Values can be `low', `normal' (default), or `critical'.
+
+The desktop environment or notification daemon is responsible for
+such notifications."
+  :type '(choice
+          (const :tag "Low" low)
+          (const :tag "Normal" normal)
+          (const :tag "Critical" critical)))
+
 (defcustom tmr-sound-file
   "/usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga"
   "Path to sound file used by `tmr-sound-play'.
@@ -90,8 +101,6 @@ Each function must accept a timer as argument."
   :type 'hook
   :options '(tmr-print-message-for-created-timer))
 
-(declare-function tmr-notification-notify "ext:tmr-notification.el" (title 
message))
-
 (define-obsolete-variable-alias
   'tmr-timer-completed-functions
   'tmr-timer-finished-functions
@@ -353,6 +362,24 @@ If there are no timers, throw an error."
         (or (and selected (get-text-property 0 'tmr-timer selected))
             (user-error "No timer selected")))))))
 
+(declare-function notifications-notify "notifications")
+(defun tmr-notification-notify (timer)
+  "Dispatch a notification for TIMER.
+
+Read: (info \"(elisp) Desktop Notifications\") for details."
+  (if (featurep 'dbusbind)
+      (let ((title "TMR May Ring (Emacs tmr package)")
+            (body (tmr--long-description-for-finished-timer timer)))
+        (unless (fboundp 'notifications-notify)
+          (require 'notifications))
+        (notifications-notify
+         :title title
+         :body body
+         :app-name "GNU Emacs"
+         :urgency tmr-notification-urgency
+         :sound-file tmr-sound-file))
+    (warn "Emacs has no DBUS support, TMR notifications unavailable")))
+
 ;; NOTE 2022-04-21: Emacs has a `play-sound' function but it only
 ;; supports .wav and .au formats.  Also, it does not work on all
 ;; platforms and Emacs needs to be compiled --with-sound capabilities.

Reply via email to