Subject: bug#79070: [PATCH] Fix macOS dictation post NSTextInputClient migration in v30

From: Alvaro Ramirez <[email-masked]>
Date: Mon, 21 Jul 2025 14:20:24 +0100

Eli Zaretskii <[email-masked]> writes:

>> Cc: [email-masked], [email-masked], 
>> [email-masked],
>>  [email-masked]
>> From: Alvaro Ramirez <[email-masked]>
>> Date: Mon, 21 Jul 2025 13:26:13 +0100
>>
>> We lost macOS dictation in Emacs v30 (see
>> https://lists.gnu.org/archive/html/bug-gnu-emacs/2025-03/msg00585.html)
>> with the NSTextInputClient migration.
>
> Thanks, but I'm not sure I understand why a new bug was in 
> order.
> Shouldn't this be discussed as part of bug#76765?

Apologies. Still getting the hang of things here. I used `M-x 
submit-emacs-patch`, which created new bug.

>> Looks like we can get it back using the new subsystem by
>> implementing the missing bits for 'selectedRange' in 
>> 'nsterm.m'.
>>
>> Not a NSTextInputClient expert here. Would love for other macOS
>> users to give the patch a try and confirm they get dictation
>> back. Similarly, edit as normal so we can rule out there are no
>> additional side effects.
>
> From the discussion of bug#76765, my impression was that the 
> problem
> was not caused by any change in the Emacs code.  You seem to 
> imply
> differently?

I looked at changes for v30 and narrowed the regression down to 
this change:

https://lists.gnu.org/archive/html/bug-gnu-emacs/2024-07/msg01310.html

To fix macOS dictation, we have two options:

1. Roll back the patch from msg01310 (migrating to 
NSTextInputClient) and re-introduce the warning.
2. Roll forward with a fix on top of the NSTextInputClient 
migration.

My patch is for 2.

> And what is 'macOS dictation", anyway? what does it do for Emacs
> users?

Pressing a keyboard shortcut on macOS temporarily enables 
dictation for any app, so you can speak and transcribe text into 
an Emacs buffer. Attaching demo (speech is muted).