emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/greader 3090adb51b 03/17: First draft of `greader-piper


From: ELPA Syncer
Subject: [elpa] externals/greader 3090adb51b 03/17: First draft of `greader-piper' back-end.
Date: Wed, 18 Dec 2024 18:59:10 -0500 (EST)

branch: externals/greader
commit 3090adb51bba57bc51f19aa6d6800067e0f35bb6
Author: Michelangelo Rodriguez <michelangelo.rodriguez@gmail.com>
Commit: Michelangelo Rodriguez <michelangelo.rodriguez@gmail.com>

    First draft of `greader-piper' back-end.
---
 greader-piper.el | 44 ++++++++++++++++++++++++++++++++++++++++++--
 greader.el       |  2 +-
 2 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/greader-piper.el b/greader-piper.el
index 4c436a61b1..3f6b0b9db3 100644
--- a/greader-piper.el
+++ b/greader-piper.el
@@ -20,11 +20,51 @@
 ;; It uses a shell script to call piper.
 
 ;;; code:
+(require 'package)
 (defgroup greader-piper
   nil
   "piper back-end."
   :group 'greader)
 
-(defcustom greader-piper-binary-path ""
-  "Path of the piper binary."
+(defcustom greader-piper-script-path
+  (concat (package-desc-dir (package-get-descriptor 'greader)) "/piper.sh")
+  "Piper script path."
   :type 'string)
+
+(defcustom greader-piper-script-url
+  "https://gitlab.com/michelangelo-rodriguez/greader/-/raw/master/piper.sh";
+  "Url of the script `piper.sh'."
+  :type 'string)
+(defun greader-piper-find-script ()
+  "Check if the piper script is really present.
+If the script is not present, propose to download it from gitlab.
+if the script is present or downloaded, then return the path.
+If the script is nor present neither downloaded, then generate an
+Error."
+  (if (file-exists-p greader-piper-script-path)
+      greader-piper-script-path
+    (let* ((default-directory (package-desc-dir
+                              (package-get-descriptor 'greader)))
+          (answer (yes-or-no-p "Do you want to download the script
+  \"piper.sh\" from gitlab?")))
+      (if answer
+         (progn
+           (setq answer (call-process "curl" nil "*piper-script download*"
+                                      nil greader-piper-script-url))
+           (unless (file-exists-p greader-piper-script-path)
+             (Error "Error while downloading %s\nPlease try later or
+open an issue" greader-piper-script-url)))
+       nil))))
+
+;;;###autoload
+(defun greader-piper (command &optional arg)
+  "Entry point for greader-piper."
+  (pcase command
+    ('executable
+     (greader-piper-find-script))
+    (_
+     'not-implemented)
+    ))
+(put 'greader-piper 'greader-backend-name "greader-piper")
+
+(provide 'greader-piper)
diff --git a/greader.el b/greader.el
index f29d7f7f32..e68fec7c56 100644
--- a/greader.el
+++ b/greader.el
@@ -124,7 +124,7 @@ If all the functions in the hook return nil, this function 
return nil."
 
 (defcustom
   greader-backends
-  '(greader-espeak greader-speechd)
+  '(greader-espeak greader-speechd greader-mac greader-piper)
   "A list of functions that are back-ends for greader."
   :tag "greader back-ends"
   :type '(repeat function))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]