Fix VO cursor sync, word double-read, and VO->Emacs positioning

patch 0002: Do not activate mark in setAccessibilitySelectedTextRange.
VoiceOver range.length is an internal word-boundary hint, not a text
selection.  Activating the mark made accessibilitySelectedTextRange
return a non-zero length, causing VoiceOver to position its browse
cursor at the END of the selection instead of the START.

patch 0003: Fix word announcement double-read and punctuation.
- Explicit word announcement only for Emacs-initiated (discontiguous)
  moves; VO-initiated (sequential) word navigation relies on VO
  auto-speech from the granularity=word notification, preventing
  double-read.
- Strip trailing/leading punctuation from word announcements using
  punctuationCharacterSet so 'Ahoj,' is announced as 'Ahoj'.

patch 0008: Post FocusedUIElementChangedNotification on the EmacsView
(not just on line-granularity moves) for all Emacs-initiated cursor
movements.  Posting on the view causes VoiceOver to re-query
accessibilityFocusedUIElement and re-anchor its browse cursor at the
current accessibilitySelectedTextRange.  Also fixes a pre-existing
off-by-one in the macos.texi hunk header.
This commit is contained in:
2026-03-02 11:12:48 +01:00
parent 760992224c
commit 91981bf77e
3 changed files with 24 additions and 33 deletions

View File

@@ -70,7 +70,7 @@ diff --git a/etc/NEWS b/etc/NEWS
index 2b1f9e6..5766428 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -4400,16 +4400,20 @@ allowing Emacs users access to speech recognition utilities.
@@ -4400,16 +4400,19 @@ allowing Emacs users access to speech recognition utilities.
Note: Accepting this permission allows the use of system APIs, which may
send user data to Apple's speech recognition servers.
@@ -518,7 +518,7 @@ index 8d44b5f..29b646d 100644
NSInteger direction = ns_ax_text_selection_direction_discontiguous;
if (point > oldPoint)
direction = ns_ax_text_selection_direction_next;
@@ -9488,6 +9670,41 @@ frameworks like Vertico bump BOTH BUF_MODIFF (via text property
@@ -9488,6 +9670,36 @@ frameworks like Vertico bump BOTH BUF_MODIFF (via text property
granularity = ns_ax_text_selection_granularity_line;
}
@@ -542,19 +542,14 @@ index 8d44b5f..29b646d 100644
+ if (emacsMovedCursor && !isCtrlNP)
+ direction = ns_ax_text_selection_direction_discontiguous;
+
+ /* Post FocusedUIElementChanged when Emacs moved the cursor
+ across a line boundary so VoiceOver re-anchors its browse
+ cursor at the new accessibilitySelectedTextRange.
+ SelectedTextChanged with discontiguous direction alone is
+ not sufficient; VoiceOver requires this notification to
+ re-query the focused element and update its internal
+ browse position. */
+ if (emacsMovedCursor
+ && granularity
+ == ns_ax_text_selection_granularity_line
+ && [self isAccessibilityFocused])
+ /* Post FocusedUIElementChanged on the containing NSView whenever
+ Emacs moves the cursor independently of VoiceOver. Posting on
+ the view causes VoiceOver to re-query accessibilityFocusedUIElement
+ and re-anchor its browse cursor at the new selection range, without
+ re-announcing the element name. Required for all granularities. */
+ if (emacsMovedCursor && [self isAccessibilityFocused])
+ ns_ax_post_notification (
+ self,
+ self.emacsView,
+ NSAccessibilityFocusedUIElementChangedNotification);
+
/* Post notifications for focused and non-focused elements. */