[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/detached fa0549e52b 2/2: Move alert notification functi
From: |
ELPA Syncer |
Subject: |
[elpa] externals/detached fa0549e52b 2/2: Move alert notification function to detached-extra |
Date: |
Sun, 22 May 2022 05:57:32 -0400 (EDT) |
branch: externals/detached
commit fa0549e52b305bfa680fe3791046f6e12d1a92df
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Move alert notification function to detached-extra
Its a small function and we can have it defined in the detached-extra.
---
README.md | 14 +-------------
detached-extra.el | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
index 08b1302e6a..9f67715964 100644
--- a/README.md
+++ b/README.md
@@ -302,19 +302,7 @@ The `detached.el` package integrates with core Emacs
packages as well as 3rd par
By default `detached.el` uses the built in `notifications` library to issue a
notification. This solution uses `dbus` but if that doesn't work for the user
there is the possibility to set the `detached-notification-function` to
`detached-state-transition-echo-message` to use the echo area instead. If that
doesn't suffice there is the possibility to use the
[alert](https://github.com/jwiegley/alert) package to get a system notification
instead.
``` emacs-lisp
-(defun my/state-detached-transition-alert-notification (session)
- "Send an `alert' notification when SESSION becomes inactive."
- (let ((status (car (detached--session-status session)))
- (host (car (detached--session-host session))))
- (alert (detached--session-command session)
- :title (pcase status
- ('success (format "Detached finished [%s]" host))
- ('failure (format "Detached failed [%s]" host)))
- :severity (pcase status
- ('success 'moderate)
- ('failure 'high)))))
-
-(setq detached-notification-function
#'my/detached-state-transition-alert-notification)
+(setq detached-notification-function #'detached-extra-alert-notification)
```
# Versions
diff --git a/detached-extra.el b/detached-extra.el
index a9f8867592..b678ead9da 100644
--- a/detached-extra.el
+++ b/detached-extra.el
@@ -27,6 +27,11 @@
(declare-function detached-compile "detached")
(declare-function detached-start-session "detached")
+(declare-function detached--session-status "detached")
+(declare-function detached--session-host "detached")
+(declare-function detached--session-command "detached")
+
+(declare-function alert "alert")
(defvar detached-session-origin)
(defvar detached-local-session)
@@ -50,6 +55,19 @@ Optionally USE-COMINT-MODE"
(detached-session-origin 'rsync))
(detached-start-session command t)))
+;;;###autoload
+(defun detached-extra-alert-notification (session)
+ "Send an `alert' notification when SESSION becomes inactive."
+ (let ((status (car (detached--session-status session)))
+ (host (car (detached--session-host session))))
+ (alert (detached--session-command session)
+ :title (pcase status
+ ('success (format "Detached finished [%s]" host))
+ ('failure (format "Detached failed [%s]" host)))
+ :severity (pcase status
+ ('success 'moderate)
+ ('failure 'high)))))
+
(provide 'detached-extra)
;;; detached-extra.el ends here