speechd-discuss
[Top][All Lists]
Advanced

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

No speech with `speechd-speak-function-feedback' when FEEDBACK is an exp


From: Alain Kalker
Subject: No speech with `speechd-speak-function-feedback' when FEEDBACK is an expression
Date: Mon, 29 Aug 2016 21:19:59 +0200

Hi all,

Using Emacs 24.5, speechd-el from MELPA, I'm trying to make speechd-el 
speak in Helm[1] buffers, by using `speechd-speak-function-feedback'. 
 From its docstring I gather that I should be able to specify an 
expression to be evaluated for the feedback, but I only get speech when 
I supply a literal string.

The snippet of code I have in my init.el is:

       (defun my-get-helm-selection-string ()
         (with-helm-buffer
           (buffer-substring-no-properties (line-beginning-position)
                                           (line-end-position))))
       (speechd-speak-function-feedback helm-move-selection-common
                                        after
                                        (my-get-helm-selection-string))

The function `my-get-helm-selection-string' produces the right output, 
I've verified it by wrapping the function body with `message', which 
causes selection items to be logged to `*Messages*' whenever I move the 
selection.

So I did some debugging and went looking in speechd-el's source, where 
eventually I found the macro `speechd-speak--report', which appears to 
refuse to speak anything which is not a literal string, i.e. an 
expression which returns a string isn't accepted.

     (speechd-speak--report "bla" :priority 'message) ;=> "bla" (and 
says "bla")
     (speechd-speak--report (string 98 108 97) :priority 'message) ;=> 
"bla" (but remains silent)

I think this is because of a problem with how `speechd-speak--report' 
evaluates its arguments; here is my (hopefully improved) version:

(defmacro speechd-speak--report (feedback &rest args)
   (let (($feedback (gensym)))
     `(let ((,$feedback ,feedback))
        (if (stringp ,$feedback)
            (speechd-speak-report ,$feedback , at args)
          ,$feedback))))

I'm wondering why this should be a macro at all. Why not simply turn it 
into a function, and use `(apply 'speechd-speak-report feedback args)'?

Also, why have the `stringp' check at all? It limits 
`speechd-speak-function-feedback' to only text as feedback, while the 
underlying `speechd-speak-report' function can also handle events (sound 
icons), which are quite useful.

Kind regards,

Alain

[1]: https://github.com/emacs-helm/helm



reply via email to

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