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

[Emacspeak] Re: finer control of auditory icons



Hello, Peter,

[Cue the No Way Home meme]

Brace yourself, this is a long reply!

> I like auditory icons but I perhaps don't like them as much as TVR :-)

I suspect I don't like them as much as him either, but this is Emacs we are speaking of - near-infinite configuration possibilities!

> For example in the attached mail under vm I get an icon with every cursor movement. That's probably because the body is an html attachment.

I try to shun HTML emails as much as possible - I haven't gotten a good workflow under "regular" Emacs, much less Emacspeak, yet, that is. I have an idea that might work with most HTML emails I still have to interact with, however - that of converting them to Markdown and viewing that instead..

> forward-paragraph also produces an icon which I probably wouldn't do by preference. Is there any way I can fine-tune which icons get played or where when? I can imagine a hack where I remove various sound files and replace them with silence but I suspect there might be nicer ways of doing this.

A good portion of Emacspeak's power comes from Emacs' advice capabilities. See TVR's article on advice[1] for an overview of that, and then `(info "(elisp)Advising Functions")` for the portion of the Elisp manual on advicing.

For this particular scenario, I will assume you are using the latest Emacspeak stable release. The relevant code you should look at is [2]. Throughout the codebase, you'll see TVR's pattern of using `cl-loop`, `eval`, `defadvice`, and `(when (ems-interactive-p))`. Note, however, that this is, as the aforementioned article states, using the (quite old) advice API. I would strongly advise (pun not intended!) to use the new `nadvice` API. See `(info "(elisp)Porting Old Advice")` for specific advice (pun also not intended!) on that very subject.

Should you wish to remove the auditory icons for `forward-paragraph` and, I presume, `backward-paragraph`, run `(describe-function 'forward-paragraph)` and scroll to the bottom, where it should state that it has an :around advice and gives a compiled function, `ad-Advice-forward-paragraph`. To remove it, execute `(advice-remove 'forward-paragraph #'ad-Advice-forward-paragraph)`. `(describe-function 'forward-paragraph)` should no longer list that, or any, advice functions. Do the same thing with `backward-paragraph` and its advice. You will now notice that when navigating paragraphs, they aren't getting spoken anymore. That is because the advices you removed also called `emacspeak-speak-paragraph`, which Emacs obviously doesn't do by default.

To remedy this, you should create your own advices, preferably using the new API[3]. Here's something you should be able to use in your config:

```elisp
(advice-remove #'forward-paragraph #'ad-Advice-forward-paragraph)
(advice-remove #'backward-paragraph #'ad-Advice-backward-paragraph)

(defun speak-paragraph-afterwards (&rest _)
  "Speak paragraph."
  (when (called-interactively-p 'any)
    (emacspeak-speak-paragraph)))

(advice-add #'forward-paragraph :after #'speak-paragraph-afterwards)
(advice-add #'backward-paragraph :after #'speak-paragraph-afterwards)
```

Note the `(called-interactively-p 'any)` - I really do not know, beyond probably old and esoteric reasons, why TVR has to `eval` his `defadvice`s. Perhaps he can chime in and enlighten us all!

> Is there also a function where I can train myself on the meanings of the various sound icons in a theme?

If I understand you correctly, there already is, see `emacspeak-wizards-show-voices`.

Hope this helps!

Hendursaga

[1] https://emacspeak.blogspot.com/2022/04/advice-on-emacs-advice.html
[2] https://github.com/tvraman/emacspeak/blob/56.0/lisp/emacspeak-advice.el#L378-L387
[3] https://emacs.stackexchange.com/questions/12997/how-do-i-use-nadvice


|May 1995 - Last Year|Current Year|


If you have questions about this archive or had problems using it, please contact us.

Contact Info Page