patches: fix all safe pre-submission issues

- Blocker #1: add BOOL emacsMovedCursor = YES in patch 0005 so series
  compiles standalone; patch 0008 replaces it with !voiceoverSetPoint
- Blocker #3: change all Daneel authorship to Martin Sukany
- Zoom gate: remove ns_accessibility_enabled guards from Zoom code
  paths (0005 no longer adds them; 0008 retains the clarifying comment)
- eassert: remove redundant BUFFER_LIVE_P eassert with contradictory
  comment in patch 0008
- macos.texi: integrate orphan 'Block-style cursors' paragraph as
  @item in the Known Limitations list
- cindex: restore @cindex Zoom, cursor tracking (macOS) removed in 0008
- ChangeLog 0002: list only functions actually added in that patch
- ChangeLog 0008: accurate description (remove wrong BUF_CHARS_MODIFF
  claim for ensureTextCache; ns_ax_buffer_text block_input was in 0001)
- git apply --check: all 9 patches apply cleanly on fresh base

Remaining open issue: BUF_MODIFF regression in patch 0007 (ensureTextCache
O(N) rebuild per font-lock pass) requires design decision before
submission.
This commit is contained in:
2026-03-03 17:50:18 +01:00
parent 3a3fbbac19
commit 70f0cb9a86
9 changed files with 270 additions and 247 deletions

View File

@@ -1,11 +1,11 @@
From affdaf60d28ad4d9836c6505216e19599b31c437 Mon Sep 17 00:00:00 2001
From: Daneel <daneel@sukany.cz>
From 7474a4e1ddbf37286842e3beda1810c40f2a3ef7 Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz>
Date: Mon, 2 Mar 2026 18:39:46 +0100
Subject: [PATCH 7/8] ns: announce overlay completion candidates for VoiceOver
Subject: [PATCH 8/9] ns: announce overlay completion candidates for VoiceOver
Overlay-based completion UIs (Vertico, Ivy, Icomplete) render candidates
via overlay before-string/after-string properties. Without this change
VoiceOver cannot read overlay-based completion UIs.
Completion frameworks such as Vertico, Ivy, and Icomplete render
candidates via overlay before-string/after-string properties. Without
this change VoiceOver cannot read overlay-based completion UIs.
* src/nsterm.m (ns_ax_face_is_selected): New static function; matches
'current', 'selected', 'selection' in face symbol names.
@@ -18,11 +18,11 @@ ValueChanged; keep overlay_modiff out of ensureTextCache to prevent a
race where an AX query consumes the change before notification.
---
src/nsterm.h | 1 +
src/nsterm.m | 348 ++++++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 307 insertions(+), 42 deletions(-)
src/nsterm.m | 345 ++++++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 304 insertions(+), 42 deletions(-)
diff --git a/src/nsterm.h b/src/nsterm.h
index 5746e9e9bd..21a93bc799 100644
index f245675513..a210ceba14 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -510,6 +510,7 @@ typedef struct ns_ax_visible_run
@@ -34,10 +34,10 @@ index 5746e9e9bd..21a93bc799 100644
@property (nonatomic, assign) BOOL cachedMarkActive;
@property (nonatomic, copy) NSString *cachedCompletionAnnouncement;
diff --git a/src/nsterm.m b/src/nsterm.m
index 8e5cc7e1d7..8ef344d9fe 100644
index a0419bb5df..54cee74401 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7263,11 +7263,157 @@ Accessibility virtual elements (macOS / Cocoa only)
@@ -7263,11 +7263,154 @@ Accessibility virtual elements (macOS / Cocoa only)
/* ---- Helper: extract buffer text for accessibility ---- */
@@ -46,9 +46,6 @@ index 8e5cc7e1d7..8ef344d9fe 100644
+ completion candidate. Works for vertico-current,
+ icomplete-selected-match, ivy-current-match, etc. */
+static bool
+/* Note: ns_zoom_face_is_selected in the Zoom series has identical
+ logic. The duplication is intentional: both series are
+ independent and must compile standalone. */
+ns_ax_face_is_selected (Lisp_Object face)
+{
+ if (SYMBOLP (face) && !NILP (face))
@@ -200,7 +197,7 @@ index 8e5cc7e1d7..8ef344d9fe 100644
/* Extract this visible run's text. Use
Fbuffer_substring_no_properties which correctly handles the
- buffer gap --- raw BUF_BYTE_ADDRESS reads across the gap would
- buffer gap raw BUF_BYTE_ADDRESS reads across the gap would
+ buffer gap --- raw BUF_BYTE_ADDRESS reads across the gap would
include garbage bytes when the run spans the gap position. */
Lisp_Object lstr = Fbuffer_substring_no_properties (
@@ -209,7 +206,7 @@ index 8e5cc7e1d7..8ef344d9fe 100644
return NSZeroRect;
/* charpos_start and charpos_len are already in buffer charpos
- space --- the caller maps AX string indices through
- space the caller maps AX string indices through
+ space --- the caller maps AX string indices through
charposForAccessibilityIndex which handles invisible text. */
ptrdiff_t cp_start = charpos_start;
@@ -226,7 +223,7 @@ index 8e5cc7e1d7..8ef344d9fe 100644
NSTRACE ("EmacsAccessibilityBuffer ensureTextCache");
/* This method is only called from the main thread (AX getters
dispatch_sync to main first). Reads of cachedText/cachedTextModiff
- below are therefore safe without @synchronized --- only the
- below are therefore safe without @synchronized only the
+ below are therefore safe without @synchronized --- only the
write section at the end needs synchronization to protect
against concurrent reads from AX server thread. */
@@ -309,7 +306,7 @@ index 8e5cc7e1d7..8ef344d9fe 100644
/* Binary search: runs are sorted by charpos (ascending). Find the
run whose [charpos, charpos+length) range contains the target,
or the nearest run after an invisible gap. O(log n) instead of
- O(n) --- matters for org-mode with many folded sections. */
- O(n) matters for org-mode with many folded sections. */
+ O(n) --- matters for org-mode with many folded sections. */
NSUInteger lo = 0, hi = visibleRunCount;
while (lo < hi)
@@ -318,11 +315,11 @@ index 8e5cc7e1d7..8ef344d9fe 100644
/* Convert accessibility string index to buffer charpos.
Safe to call from any thread: uses only cachedText (NSString) and
- visibleRuns --- no Lisp calls. */
- visibleRuns no Lisp calls. */
+ visibleRuns --- no Lisp calls. */
- (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx
{
- /* May be called from AX server thread --- synchronize. */
- /* May be called from AX server thread synchronize. */
+ /* May be called from AX server thread --- synchronize. */
@synchronized (self)
{
@@ -331,7 +328,7 @@ index 8e5cc7e1d7..8ef344d9fe 100644
return cp;
}
}
- /* Past end --- return last charpos. */
- /* Past end return last charpos. */
+ /* Past end --- return last charpos. */
if (lo > 0)
{
@@ -340,7 +337,7 @@ index 8e5cc7e1d7..8ef344d9fe 100644
deadlocking the AX server thread. This is prevented by:
1. validWindow checks WINDOW_LIVE_P and BUFFERP before every
- Lisp access --- the window and buffer are verified live.
- Lisp access the window and buffer are verified live.
+ Lisp access --- the window and buffer are verified live.
2. All dispatch_sync blocks run on the main thread where no
concurrent Lisp code can modify state between checks.
@@ -400,7 +397,7 @@ index 8e5cc7e1d7..8ef344d9fe 100644
/* ===================================================================
- EmacsAccessibilityBuffer (Notifications) --- AX event dispatch
- EmacsAccessibilityBuffer (Notifications) AX event dispatch
+ EmacsAccessibilityBuffer (Notifications) --- AX event dispatch
These methods notify VoiceOver of text and selection changes.
@@ -409,7 +406,7 @@ index 8e5cc7e1d7..8ef344d9fe 100644
if (point > self.cachedPoint
&& point - self.cachedPoint == 1)
{
- /* Single char inserted --- refresh cache and grab it. */
- /* Single char inserted refresh cache and grab it. */
+ /* Single char inserted --- refresh cache and grab it. */
[self invalidateTextCache];
[self ensureTextCache];
@@ -418,12 +415,12 @@ index 8e5cc7e1d7..8ef344d9fe 100644
/* Update cachedPoint here so the selection-move branch does NOT
fire for point changes caused by edits. WebKit and Chromium
never send both ValueChanged and SelectedTextChanged for the
- same user action --- they are mutually exclusive. */
- same user action they are mutually exclusive. */
+ same user action --- they are mutually exclusive. */
self.cachedPoint = point;
NSDictionary *change = @{
@@ -9220,16 +9417,83 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f
@@ -9220,16 +9417,80 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f
BOOL markActive = !NILP (BVAR (b, mark_active));
/* --- Text changed (edit) --- */
@@ -465,90 +462,87 @@ index 8e5cc7e1d7..8ef344d9fe 100644
+ font-lock and other modes change BUF_OVERLAY_MODIFF on
+ every redisplay, triggering O(overlays) work per keystroke.
+ Restrict the scan to minibuffer windows. */
+ if (!MINI_WINDOW_P (w))
+ goto skip_overlay_scan;
+
+ int selected_line = -1;
+ NSString *candidate
+ = ns_ax_selected_overlay_text (b, BUF_BEGV (b), BUF_ZV (b),
+ &selected_line);
+ if (candidate)
+ if (MINI_WINDOW_P (w))
+ {
+ /* Deduplicate: only announce when the candidate changed. */
+ if (![candidate isEqualToString:
+ self.cachedCompletionAnnouncement])
+ int selected_line = -1;
+ NSString *candidate
+ = ns_ax_selected_overlay_text (b, BUF_BEGV (b), BUF_ZV (b),
+ &selected_line);
+ if (candidate)
+ {
+ self.cachedCompletionAnnouncement = candidate;
+
+ /* Announce the candidate text directly via NSApp.
+ Do NOT post SelectedTextChanged --- that would cause
+ VoiceOver to read the AX text at the cursor position
+ (the minibuffer input line), not the overlay candidate.
+ AnnouncementRequested with High priority interrupts
+ any current speech and announces our text. */
+ NSDictionary *annInfo = @{
+ NSAccessibilityAnnouncementKey: candidate,
+ NSAccessibilityPriorityKey:
+ @(NSAccessibilityPriorityHigh)
+ };
+ ns_ax_post_notification_with_info (
+ NSApp,
+ NSAccessibilityAnnouncementRequestedNotification,
+ annInfo);
+ /* Deduplicate: only announce when the candidate changed. */
+ if (![candidate isEqualToString:
+ self.cachedCompletionAnnouncement])
+ {
+ self.cachedCompletionAnnouncement = candidate;
+
+ /* Announce the candidate text directly via NSApp.
+ Do NOT post SelectedTextChanged --- that would cause
+ VoiceOver to read the AX text at the cursor position
+ (the minibuffer input line), not the overlay candidate.
+ AnnouncementRequested with High priority interrupts
+ any current speech and announces our text. */
+ NSDictionary *annInfo = @{
+ NSAccessibilityAnnouncementKey: candidate,
+ NSAccessibilityPriorityKey:
+ @(NSAccessibilityPriorityHigh)
+ };
+ ns_ax_post_notification_with_info (
+ NSApp,
+ NSAccessibilityAnnouncementRequestedNotification,
+ annInfo);
+ }
+ }
+ }
}
+ skip_overlay_scan:;
/* --- Cursor moved or selection changed ---
- Use 'else if' --- edits and selection moves are mutually exclusive
- Use 'else if' edits and selection moves are mutually exclusive
- per the WebKit/Chromium pattern. */
- else if (point != self.cachedPoint || markActive != self.cachedMarkActive)
+ Independent check: the goto above may jump here from the overlay
+ branch, so this must be a standalone if, not else-if. */
+ Independent check from the overlay branch above. */
+ if (point != self.cachedPoint || markActive != self.cachedMarkActive)
{
ptrdiff_t oldPoint = self.cachedPoint;
BOOL oldMarkActive = self.cachedMarkActive;
@@ -12403,7 +12667,7 @@ - (int) fullscreenState
@@ -12408,7 +12669,7 @@ - (int) fullscreenState
if (WINDOW_LEAF_P (w))
{
- /* Buffer element --- reuse existing if available. */
- /* Buffer element reuse existing if available. */
+ /* Buffer element --- reuse existing if available. */
EmacsAccessibilityBuffer *elem
= [existing objectForKey:[NSValue valueWithPointer:w]];
if (!elem)
@@ -12437,7 +12701,7 @@ - (int) fullscreenState
@@ -12442,7 +12703,7 @@ - (int) fullscreenState
}
else
{
- /* Internal (combination) window --- recurse into children. */
- /* Internal (combination) window recurse into children. */
+ /* Internal (combination) window --- recurse into children. */
Lisp_Object child = w->contents;
while (!NILP (child))
{
@@ -12549,7 +12813,7 @@ - (void)postAccessibilityUpdates
@@ -12554,7 +12815,7 @@ - (void)postAccessibilityUpdates
accessibilityUpdating = YES;
/* Detect window tree change (split, delete, new buffer). Compare
- FRAME_ROOT_WINDOW --- if it changed, the tree structure changed. */
- FRAME_ROOT_WINDOW if it changed, the tree structure changed. */
+ FRAME_ROOT_WINDOW --- if it changed, the tree structure changed. */
Lisp_Object curRoot = FRAME_ROOT_WINDOW (emacsframe);
if (!EQ (curRoot, lastRootWindow))
{
@@ -12558,12 +12822,12 @@ - (void)postAccessibilityUpdates
@@ -12563,12 +12824,12 @@ - (void)postAccessibilityUpdates
}
/* If tree is stale, rebuild FIRST so we don't iterate freed
- window pointers. Skip notifications for this cycle --- the
- window pointers. Skip notifications for this cycle the
+ window pointers. Skip notifications for this cycle --- the
freshly-built elements have no previous state to diff against. */
if (!accessibilityTreeValid)
{
[self rebuildAccessibilityTree];
- /* Invalidate span cache --- window layout changed. */
- /* Invalidate span cache window layout changed. */
+ /* Invalidate span cache --- window layout changed. */
for (EmacsAccessibilityElement *elem in accessibilityElements)
if ([elem isKindOfClass: [EmacsAccessibilityBuffer class]])