diff options
| author | Stefan Monnier <monnier@iro.umontreal.ca> | 2023-09-15 12:56:23 -0400 |
|---|---|---|
| committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2023-09-15 12:57:50 -0400 |
| commit | 6fe3129a11f32078f5622e1321e9e5021eb0f5cc (patch) | |
| tree | be4ef5660a9a78110b656301f289b744e48f5b37 /greader-speechd.el | |
| parent | dff6b60acb7456422f5e32e2c9a36fda8f077267 (diff) | |
Miscellanous simplifications and "tightening"scratch/greader
Many of the simplifications result from hoisting `setq`
out of ifs or avoiding `setq` altogether.
Among the tightening, don't treat hooks as mere "variables holding
a list of functions", since they're a bit more complex than that
(e.g. can contain a function rather than a list, can have both
global and buffer-local functions at the same time, ...).
* greader.el (greader--call-functions-after-get-of-sentence):
Use `run-hook-wrapped` and simplify.
(greader--call-before-finish-functions):
Use `run-hook-with-args-until-success`.
(greader-change-backend): Consolidate the `seq-local`s outside of
the ifs. Use (cadr (memq ...)) to find the "next" item instead of
going through index numbers.
(greader-read-asynchronous): Simplify the computation of `txt` and
`backend` by avoiding `setq`.
(greader-action): Assume `greader-backend-action` is non-nil.
Use `ignore` rather than `nil` if you want a backend that does
nothing :-)
(greader-set-language): Simplify by avoiding `setq`.
(greader-timer-flag-p, greader-sentence-needs-dehyphenation): η-reduce.
(greader-compile-mode): Don't trust the `member` test
since hooks aren't just "normal var holding a list".
* greader-speechd.el (greader-speechd-set-punctuation): Simplify.
Signal an error when `punct` is nil instead of returning
`greader-speechd-punctuation` without a preceding "-m".
* greader-mac.el: Add missing `Code:` header.
(greader-mac-set-voice): Simplify.
(greader-mac-forward-sentence): Use `move` arg of `re-search-forward`.
(greader-mac-get-sentence): Use `greader-mac-forward-sentence`
and eliminate dummy initialization of `sentence-start` that's
immediately overwritten by something else.
(greader--mac-get-voices): `beginning-of-buffer` is "interactive-only".
Diffstat (limited to 'greader-speechd.el')
| -rw-r--r-- | greader-speechd.el | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/greader-speechd.el b/greader-speechd.el index c928de5..2913cab 100644 --- a/greader-speechd.el +++ b/greader-speechd.el @@ -82,27 +82,14 @@ for further documentation, see the `greader-speechd-rate' variable." "Return a suitable parameter to pass to spd-say for setting punctuation level. PUNCT must be a numeric value, 0 for no punctuation, 1 for some and 2 or >2 for all punctuation." - (catch 'return - (cond - ((booleanp punct) - (if punct - (progn - (setq-local greader-speechd-punctuation "all") - (throw 'return (concat "-mall"))) - (throw 'return greader-speechd-punctuation))) - ((numberp punct) - (if (= punct 0) - (progn - (setq-local greader-speechd-punctuation "none") - (throw 'return (concat "-mnone")))) - (if (= punct 1) - (progn - (setq-local greader-speechd-punctuation "some") - (throw 'return (concat "-msome")))) - (if (>= punct 2) - (progn - (setq-local greader-speechd-punctuation "all") - (throw 'return (concat "-mall")))))))) + (setq-local greader-speechd-punctuation + (pcase punct + ('t "all") + ('0 "none") + ('1 "some") + ((and (pred numberp) (pred (<= 2))) "all") + (_ (error "Unknown punctuation: %S" punct)))) + (concat "-m" greader-speechd-punctuation)) (defun greader-speechd-stop () "Stops speech-dispatcher client." |
