From ad028a1f197377b7a9a5a8f7a55598cff8413297 Mon Sep 17 00:00:00 2001 From: Krzysztof Drewniak <krzysdrewniak@xxxxxxxxxxx> Date: Tue, 8 Jun 2021 18:31:08 -0500 Subject: [PATCH] Fix bugs in and clean up the vertico support. 1. Some of vertico's variables, like vertico--insert, were incorrectly given an emacspeak- prefix. This has been fixed. 2. Removed redundant versions of advice 3. Tried to silence some warnings about undeclared functions 4. Removed interactivity checks for vertico-insert and vertico--exhibit, as these functions are not always called from contexts that satisfy ems-interactive-p while stile being used interactively. Having interactivity checks breaks the speaking of autocompletions. 5. Same the point before `ad-do-it` in vertico--insert. Otherwise, the speech becomes a noop. --- lisp/emacspeak-vertico.el | 65 +++++++++++---------------------------- 1 file changed, 18 insertions(+), 47 deletions(-) diff --git a/lisp/emacspeak-vertico.el b/lisp/emacspeak-vertico.el index c31a2444c..36d0fd1c3 100644 --- a/lisp/emacspeak-vertico.el +++ b/lisp/emacspeak-vertico.el @@ -57,38 +57,31 @@ (defvar-local emacspeak-vertico--prev-index nil "Index of previously spoken candidate") +;;}}} +;;{{{ +(declare-function 'vertico--candidate "vertico.el" (&optional hl)) +(declare-function 'vertico--allow-prompt-selection-p "vertico.el" ()) ;;}}} ;;{{{ Advice interactive commands -(defun emacspeak-vertico--insert-advice (orig-func &rest args) - "Read inserted text after tab completion." - (let* ((orig-point (point)) - (ret (apply orig-func args))) - (emacspeak-auditory-icon 'complete) - (emacspeak-speak-region orig-point (point)) - ret)) - (defadvice vertico-insert (around emacspeak pre act comp) "Provide auditory feedback." - (cond - ((ems-interactive-p) + (let* ((orig-point (point))) ad-do-it - (let* ((orig-point (point))) - (emacspeak-auditory-icon 'complete) - (emacspeak-speak-region orig-point (point)))) - (t ad-do-it)) + (emacspeak-auditory-icon 'complete) + (emacspeak-speak-region orig-point (point))) ad-return-value) - -(defun emacspeak-vertico--exhibit () - "Provide audio display of current completion." - (cl-declare (special emacspeak-vertico--index vertico--base)) - (let ((new-cand (substring (vertico--candidate) - (if (>= vertico--index 0) vertico--base 0))) +(defadvice vertico--exhibit (after emacspeak pre act comp) + "Provide auditory feedback." + (cl-declare (special vertico--index vertico--base)) + (let ((new-cand + (substring (vertico--candidate) + (if (>= vertico--index 0) vertico--base 0))) (to-speak nil)) (unless (equal emacspeak-vertico--prev-candidate new-cand) (push new-cand to-speak) - (when (or (equal emacspeak-vertico--index emacspeak-vertico--prev-index) + (when (or (equal vertico--index emacspeak-vertico--prev-index) (and (not (equal vertico--index -1)) (equal emacspeak-vertico--prev-index -1))) (push "candidate" to-speak))) @@ -97,31 +90,9 @@ (push "first candidate" to-speak)) (when to-speak (dtk-speak (mapconcat 'identity to-speak " "))) - (setq-local emacspeak-vertico--prev-candidate new-cand - emacspeak-vertico--prev-index vertico--index))) - -(defadvice vertico--exhibit (after emacspeak pre act comp) - "Provide auditory feedback." - (cl-declare (special vertico--index vertico--base)) - (when (ems-interactive-p) - (let ((new-cand - (substring (vertico--candidate) - (if (>= vertico--index 0) vertico--base 0))) - (to-speak nil)) - (unless (equal emacspeak-vertico--prev-candidate new-cand) - (push new-cand to-speak) - (when (or (equal emacspeak-vertico--index emacspeak-vertico--prev-index) - (and (not (equal vertico--index -1)) - (equal emacspeak-vertico--prev-index -1))) - (push "candidate" to-speak))) - (when (and (not (vertico--allow-prompt-selection-p)) - (equal emacspeak-vertico--prev-candidate nil)) - (push "first candidate" to-speak)) - (when to-speak - (dtk-speak (mapconcat 'identity to-speak " "))) - (setq-local - vertico--prev-candidate new-cand - vertico--prev-index vertico--index)))) + (setq-local + emacspeak-vertico--prev-candidate new-cand + emacspeak-vertico--prev-index vertico--index))) (cl-loop for (f icon) in @@ -138,7 +109,7 @@ `(defadvice ,f (after emacspeak pre act comp) "Provide auditory feedback." (when (ems-interactive-p) - (emacspeak-auditory-icon ,icon))))) + (emacspeak-auditory-icon ',icon))))) ;;}}} (provide 'emacspeak-vertico) -- 2.25.1
|May 1995 - Last Year|Current Year|
If you have questions about this archive or had problems using it, please contact us.