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

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

[elpa] externals/greader ed45417 45/76: functions to handle punctuation


From: Stefan Monnier
Subject: [elpa] externals/greader ed45417 45/76: functions to handle punctuation rewritten to reflect new back-end architecture.
Date: Fri, 8 Feb 2019 15:26:54 -0500 (EST)

branch: externals/greader
commit ed4541769996cfb4baaf787618e2bb579742c9d3
Author: Michelangelo Rodriguez <address@hidden>
Commit: Michelangelo Rodriguez <address@hidden>

    functions to handle punctuation rewritten to reflect new back-end 
architecture.
---
 greader-espeak.el  | 26 +++++++++++++++++++-------
 greader-speechd.el | 30 ++++++++++++++++++++++--------
 greader.el         | 14 +++++++-------
 3 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/greader-espeak.el b/greader-espeak.el
index 1503c27..2c8234b 100644
--- a/greader-espeak.el
+++ b/greader-espeak.el
@@ -59,15 +59,15 @@ this variable determines authomatically if espeak is 
present in your PATH enviro
     ()
   "tries to find espeak executable in PATH.
 If it's present, returns absolute path of espeak, else returns nil."
-(locate-file "espeak" exec-path))
+  (locate-file "espeak" exec-path))
+
 (defun greader-espeak-set-punctuation
     (&optional switch)
   "sets espeak punctuation on or off.
 this function accepts only nil or t."
   (if switch
-      "--punct"
-    greader-espeak-punctuation))
-
+      (setq-local greader-espeak-punctuation switch)
+    greader-espeak-punctuation))    
 (defun greader-espeak (command &optional arg &rest args)
   "back-end main function of greader-espeak."
   (pcase command
@@ -84,9 +84,21 @@ this function accepts only nil or t."
         (greader-espeak-set-rate)
        (greader-espeak-set-rate arg)))
     ('punctuation
-     (if (not arg)
-        (greader-espeak-set-punctuation)
-       (greader-espeak-set-punctuation arg)))
+     (cond
+
+      (
+       (or (equal arg 'yes) arg)
+       (setq-local greader-espeak-punctuation t)
+       "--punct")
+      (
+       (equal arg 'no)
+       (setq-local greader-espeak-punctuation nil)
+       nil)
+      ((not arg)
+       (if greader-espeak-punctuation
+          "--punct"
+        greader-espeak-punctuation))))
+     
     (command-not-implemented
      'not-implemented)))
 (put 'greader-espeak 'greader-backend-name "greader-espeak")
diff --git a/greader-speechd.el b/greader-speechd.el
index aacb2c6..575e6fe 100644
--- a/greader-speechd.el
+++ b/greader-speechd.el
@@ -70,15 +70,25 @@ punct must be a numeric value, 0 for no punctuation, 1 for 
some and 2 or >2 for
   (cond
    ((booleanp punct)
     (if punct
-       (throw 'return (concat "-mall"))
-      (throw 'return (concat "-mnone"))))
+       (progn
+         (setq-local greader-speechd-punctuation "all")
+         (throw 'return (concat "-mall")))
+      (progn
+       (setq-local greader-speechd-punctuation "none")
+       (throw 'return (concat "-mnone")))))
    ((numberp punct)
      (if (= punct 0)
-        (throw 'return (concat "-mnone")))
+        (progn
+          (setq-local greader-speechd-punctuation "none")
+          (throw 'return (concat "-mnone"))))
      (if (= punct 1)
-        (throw 'return (concat "-msome")))
+        (progn
+          (setq-local greader-speechd-punctuation "some")
+          (throw 'return (concat "-msome"))))
      (if (>= punct 2)
-        (throw 'return (concat "-mall")))))))
+        (progn
+          (setq-local greader-speechd-punctuation "all")
+          (throw 'return (concat "-mall"))))))))
 (defun greader-speechd-stop ()
   "stops speech-dispatcher client."
   (start-process "speechd-client" nil greader-speechd-executable-path "-S"))
@@ -96,9 +106,13 @@ punct must be a numeric value, 0 for no punctuation, 1 for 
some and 2 or >2 for
         (greader-speechd-set-rate)
        (greader-speechd-set-rate arg)))
     ('punctuation
-     (if (not arg)
-        (greader-speechd-set-punctuation)
-       (greader-speechd-set-punctuation arg)))
+     (cond
+      ((equal arg 'no)
+       (greader-speechd-set-punctuation 0))
+      ((equal arg 'yes)
+       (greader-speechd-set-punctuation 2))
+      ((not arg)
+       (greader-speechd-set-punctuation))))
     ('stop
      (greader-speechd-stop))
     ('extra
diff --git a/greader.el b/greader.el
index 64c846b..2541a8d 100644
--- a/greader.el
+++ b/greader.el
@@ -458,21 +458,21 @@ This function sets the language of tts local for current 
buffer, so if you want
   (interactive "sset language to:")
   (greader-call-backend 'lang lang))
 (defun greader-set-punctuation (flag)
-  (setq-local greader-punctuation flag)
+  (greader-call-backend 'punctuation flag)
   greader-punctuation)
 (defun greader-toggle-punctuation ()
   "Toggles punctuation locally for current buffer."
   (interactive)
-  (if greader-punctuation
+  (if (equal (greader-call-backend 'punctuation) "")
       (progn
        (greader-stop)
-       (greader-set-punctuation nil)
-       (message "punctuation disabled in current buffer")
+       (greader-set-punctuation t)
+       (message "punctuation enabled in current buffer")
        (greader-read))
     (progn
       (greader-stop)
-      (greader-set-punctuation t)
-      (message "punctuation enabled in current buffer")
+      (greader-set-punctuation nil)
+      (message "punctuation disabled in current buffer")
       (greader-read))))
 
 (defun greader-toggle-timer-flag ()
@@ -696,8 +696,8 @@ The default is 22:00 for entering and 08:00 for exiting."
 (defun greader-set-rate (n)
   "sets rate in current buffer to tthe specified value in n. rate is expressed 
in words per minute.
 For maximum value, see 'man espeak'."
+  (greader-call-backend 'rate n))
 
-  (setq-local greader-rate n))
 
 (defun greader-inc-rate (&optional n)
   "increments rate of speech by 10 units.



reply via email to

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