From 636545c2a5dd7041eec270d2410ce2d1ba82b3ed Mon Sep 17 00:00:00 2001 From: Daneel Date: Sun, 1 Mar 2026 06:39:37 +0100 Subject: [PATCH] patches: auto-detect Zoom/VoiceOver; single variable gates both Changes: - EmacsApp gets ns_update_accessibility_state and ns_accessibility_did_change: methods (patch 0005) - At startup: UAZoomEnabled() + AXIsProcessTrustedWithOptions() determine initial ns_accessibility_enabled state - com.apple.accessibility.api distributed notification updates it whenever any AT connects or disconnects - All Zoom call sites (UAZoomChangeFocus) now gated by ns_accessibility_enabled in addition to ns_zoom_enabled_p() - ns-accessibility-enabled docstring updated to describe auto-detect Result: zero config needed; zero overhead when no AT is active; single variable overrides auto-detection when needed. --- ...-with-macOS-Zoom-for-cursor-tracking.patch | 2 +- ...lity-base-classes-and-text-extractio.patch | 2 +- ...fer-accessibility-element-core-proto.patch | 2 +- ...tification-dispatch-and-mode-line-el.patch | 2 +- ...ive-span-elements-for-Tab-navigation.patch | 2 +- ...essibility-with-EmacsView-and-redisp.patch | 131 ++++++++++++++++-- ...r-accessibility-section-to-macOS-app.patch | 2 +- ...lay-completion-candidates-for-VoiceO.patch | 52 +++---- ...d-frame-completion-candidates-for-Vo.patch | 22 +-- 9 files changed, 163 insertions(+), 54 deletions(-) diff --git a/patches/0000-ns-integrate-with-macOS-Zoom-for-cursor-tracking.patch b/patches/0000-ns-integrate-with-macOS-Zoom-for-cursor-tracking.patch index e3896e0..71cade0 100644 --- a/patches/0000-ns-integrate-with-macOS-Zoom-for-cursor-tracking.patch +++ b/patches/0000-ns-integrate-with-macOS-Zoom-for-cursor-tracking.patch @@ -1,4 +1,4 @@ -From 38bbd275736251862f4b2fb433ee0a84799f0cec Mon Sep 17 00:00:00 2001 +From d494967af08ec3e5bb94ff50126c2994505a6d85 Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 22:39:35 +0100 Subject: [PATCH 1/9] ns: integrate with macOS Zoom for cursor tracking diff --git a/patches/0001-ns-add-accessibility-base-classes-and-text-extractio.patch b/patches/0001-ns-add-accessibility-base-classes-and-text-extractio.patch index e901996..13b4fb6 100644 --- a/patches/0001-ns-add-accessibility-base-classes-and-text-extractio.patch +++ b/patches/0001-ns-add-accessibility-base-classes-and-text-extractio.patch @@ -1,4 +1,4 @@ -From 92f8d65bd248ac3bcc5d40b0707ffa184d3c7fa5 Mon Sep 17 00:00:00 2001 +From 971bf8f19bec3a89144ddf2375cd17a4d95bb707 Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 2/9] ns: add accessibility base classes and text extraction diff --git a/patches/0002-ns-implement-buffer-accessibility-element-core-proto.patch b/patches/0002-ns-implement-buffer-accessibility-element-core-proto.patch index 0c2e506..0262b83 100644 --- a/patches/0002-ns-implement-buffer-accessibility-element-core-proto.patch +++ b/patches/0002-ns-implement-buffer-accessibility-element-core-proto.patch @@ -1,4 +1,4 @@ -From a9af26dc0f2762b5e53785554f110a08aad72d01 Mon Sep 17 00:00:00 2001 +From d49a7ef5e31a5988d6c54a04561326cff8444a2f Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 3/9] ns: implement buffer accessibility element (core diff --git a/patches/0003-ns-add-buffer-notification-dispatch-and-mode-line-el.patch b/patches/0003-ns-add-buffer-notification-dispatch-and-mode-line-el.patch index 4a33ef3..bb67a61 100644 --- a/patches/0003-ns-add-buffer-notification-dispatch-and-mode-line-el.patch +++ b/patches/0003-ns-add-buffer-notification-dispatch-and-mode-line-el.patch @@ -1,4 +1,4 @@ -From 593b5219ee63b32125efc0e58e9c376c949b463b Mon Sep 17 00:00:00 2001 +From 5a58044053001af12f388af2960f903427676c8f Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 4/9] ns: add buffer notification dispatch and mode-line diff --git a/patches/0004-ns-add-interactive-span-elements-for-Tab-navigation.patch b/patches/0004-ns-add-interactive-span-elements-for-Tab-navigation.patch index 4b2259d..7d5f28b 100644 --- a/patches/0004-ns-add-interactive-span-elements-for-Tab-navigation.patch +++ b/patches/0004-ns-add-interactive-span-elements-for-Tab-navigation.patch @@ -1,4 +1,4 @@ -From 19053ea6ef478603115e2f4288f54d44ce204bcd Mon Sep 17 00:00:00 2001 +From 388628944f6ecc74806932e0ee2ad89c3df669ed Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 5/9] ns: add interactive span elements for Tab navigation diff --git a/patches/0005-ns-integrate-accessibility-with-EmacsView-and-redisp.patch b/patches/0005-ns-integrate-accessibility-with-EmacsView-and-redisp.patch index d0f2488..799a309 100644 --- a/patches/0005-ns-integrate-accessibility-with-EmacsView-and-redisp.patch +++ b/patches/0005-ns-integrate-accessibility-with-EmacsView-and-redisp.patch @@ -1,4 +1,4 @@ -From 7b4c8fc93674296aac802377ad223db50f79f33d Mon Sep 17 00:00:00 2001 +From 61a0ae5344e6f52cb21ae299133b39b2ede010d0 Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 6/9] ns: integrate accessibility with EmacsView and redisplay @@ -23,8 +23,8 @@ block cursor, org-mode folded headings, indirect buffers. Known limitations documented in patch 6 Texinfo node. --- etc/NEWS | 13 ++ - src/nsterm.m | 359 ++++++++++++++++++++++++++++++++++++++++++++++++++- - 2 files changed, 369 insertions(+), 3 deletions(-) + src/nsterm.m | 430 +++++++++++++++++++++++++++++++++++++++++++++++++-- + 2 files changed, 431 insertions(+), 12 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 80661a9..2b1f9e6 100644 @@ -51,10 +51,29 @@ index 80661a9..2b1f9e6 100644 ** Re-introduced dictation, lost in Emacs v30 (macOS). We lost macOS dictation in v30 when migrating to NSTextInputClient. diff --git a/src/nsterm.m b/src/nsterm.m -index 5eaf480..1577338 100644 +index 5eaf480..4ad451f 100644 --- a/src/nsterm.m +++ b/src/nsterm.m -@@ -1405,6 +1405,9 @@ so the visual offset is (ov_line + 1) * line_h from +@@ -1258,7 +1258,7 @@ If a completion candidate is selected (overlay or child frame), + static void + ns_zoom_track_completion (struct frame *f, EmacsView *view) + { +- if (!ns_zoom_enabled_p ()) ++ if (!ns_accessibility_enabled || !ns_zoom_enabled_p ()) + return; + if (!WINDOWP (f->selected_window)) + return; +@@ -1378,7 +1378,8 @@ so the visual offset is (ov_line + 1) * line_h from + (zoomCursorUpdated is NO). */ + #if defined (MAC_OS_X_VERSION_MIN_REQUIRED) \ + && MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 +- if (view && !view->zoomCursorUpdated && ns_zoom_enabled_p () ++ if (ns_accessibility_enabled && view && !view->zoomCursorUpdated ++ && ns_zoom_enabled_p () + && !NSIsEmptyRect (view->lastCursorRect)) + { + NSRect r = view->lastCursorRect; +@@ -1405,6 +1406,9 @@ so the visual offset is (ov_line + 1) * line_h from if (view) ns_zoom_track_completion (f, view); #endif /* NS_IMPL_COCOA */ @@ -64,7 +83,73 @@ index 5eaf480..1577338 100644 } static void -@@ -7620,7 +7623,6 @@ - (id)accessibilityTopLevelUIElement +@@ -3552,7 +3556,7 @@ EmacsView pixels (AppKit, flipped, top-left origin) + + #if defined (MAC_OS_X_VERSION_MIN_REQUIRED) \ + && MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 +- if (ns_zoom_enabled_p ()) ++ if (ns_accessibility_enabled && ns_zoom_enabled_p ()) + { + NSRect windowRect = [view convertRect:r toView:nil]; + NSRect screenRect +@@ -6717,9 +6721,56 @@ - (void)applicationDidFinishLaunching: (NSNotification *)notification + } + #endif + ++#ifdef NS_IMPL_COCOA ++ /* Auto-detect Zoom and VoiceOver at startup and whenever their state ++ changes. The "com.apple.accessibility.api" distributed notification ++ fires when any assistive technology connects or disconnects. ++ Both code paths set ns_accessibility_enabled so that one variable ++ gates all our accessibility overhead. */ ++ [self ns_update_accessibility_state]; ++ [[NSDistributedNotificationCenter defaultCenter] ++ addObserver: self ++ selector: @selector(ns_accessibility_did_change:) ++ name: @"com.apple.accessibility.api" ++ object: nil ++suspensionBehavior: NSNotificationSuspensionBehaviorDeliverImmediately]; ++#endif ++ + ns_send_appdefined (-2); + } + ++#ifdef NS_IMPL_COCOA ++/* Set ns_accessibility_enabled based on current AT state. ++ Called at startup and from the "com.apple.accessibility.api" ++ distributed notification handler. Checks both UAZoomEnabled() ++ (Zoom) and AXIsProcessTrustedWithOptions() (VoiceOver and other ++ ATs that have connected to this process). */ ++- (void) ns_update_accessibility_state ++{ ++ NSTRACE ("[EmacsApp ns_update_accessibility_state]"); ++ BOOL zoom_on = UAZoomEnabled (); ++ NSDictionary *opts = @{(__bridge id) kAXTrustedCheckOptionPrompt: @NO}; ++ BOOL at_on = AXIsProcessTrustedWithOptions ((__bridge CFDictionaryRef) opts); ++ BOOL new_state = zoom_on || at_on; ++ if ((BOOL) ns_accessibility_enabled != new_state) ++ { ++ ns_accessibility_enabled = new_state; ++ /* Reset the UAZoomEnabled cache so ns_zoom_enabled_p() reflects ++ the new Zoom state on its next call. */ ++ ns_zoom_cache_time = 0; ++ } ++} ++ ++/* Handler for the "com.apple.accessibility.api" distributed notification, ++ posted by macOS when any AT (VoiceOver, Switch Control, etc.) starts ++ or stops. */ ++- (void) ns_accessibility_did_change: (NSNotification *) notification ++{ ++ NSTRACE ("[EmacsApp ns_accessibility_did_change:]"); ++ [self ns_update_accessibility_state]; ++} ++#endif ++ + - (void)antialiasThresholdDidChange:(NSNotification *)notification + { + #ifdef NS_IMPL_COCOA +@@ -7620,7 +7671,6 @@ - (id)accessibilityTopLevelUIElement @@ -72,7 +157,7 @@ index 5eaf480..1577338 100644 static BOOL ns_ax_find_completion_overlay_range (struct buffer *b, ptrdiff_t point, ptrdiff_t *out_start, -@@ -8722,7 +8724,6 @@ - (NSRect)accessibilityFrame +@@ -8722,7 +8772,6 @@ - (NSRect)accessibilityFrame @end @@ -80,7 +165,7 @@ index 5eaf480..1577338 100644 /* =================================================================== EmacsAccessibilityBuffer (Notifications) — AX event dispatch -@@ -9267,7 +9268,6 @@ - (NSRect)accessibilityFrame +@@ -9267,7 +9316,6 @@ - (NSRect)accessibilityFrame @end @@ -88,7 +173,7 @@ index 5eaf480..1577338 100644 /* =================================================================== EmacsAccessibilityInteractiveSpan — helpers and implementation =================================================================== */ -@@ -9597,6 +9597,7 @@ - (void)dealloc +@@ -9597,6 +9645,7 @@ - (void)dealloc [layer release]; #endif @@ -96,7 +181,7 @@ index 5eaf480..1577338 100644 [[self menu] release]; [super dealloc]; } -@@ -10945,6 +10946,32 @@ - (void)windowDidBecomeKey /* for direct calls */ +@@ -10945,6 +10994,32 @@ - (void)windowDidBecomeKey /* for direct calls */ XSETFRAME (event.frame_or_window, emacsframe); kbd_buffer_store_event (&event); ns_send_appdefined (-1); // Kick main loop @@ -129,7 +214,7 @@ index 5eaf480..1577338 100644 } -@@ -12182,6 +12209,332 @@ - (int) fullscreenState +@@ -12182,6 +12257,332 @@ - (int) fullscreenState return fs_state; } @@ -462,6 +547,30 @@ index 5eaf480..1577338 100644 @end /* EmacsView */ +@@ -14182,12 +14583,17 @@ Nil means use fullscreen the old (< 10.7) way. The old way works better with + ns_use_srgb_colorspace = YES; + + DEFVAR_BOOL ("ns-accessibility-enabled", ns_accessibility_enabled, +- doc: /* Non-nil means expose buffer content to the macOS accessibility +-subsystem (VoiceOver, Zoom, and other assistive technology). +-When nil, the accessibility virtual element tree is not built and no +-notifications are posted, eliminating the associated overhead. +-Requires the Cocoa (NS) build on macOS; ignored on GNUstep. +-Default is nil. Set to t to enable VoiceOver support. */); ++ doc: /* Non-nil enables Zoom cursor tracking and VoiceOver support. ++Emacs sets this automatically at startup when macOS Zoom is active or ++any assistive technology (VoiceOver, Switch Control, etc.) is connected, ++and updates it whenever that state changes. You can override manually: ++ ++ (setq ns-accessibility-enabled t) ; always on ++ (setq ns-accessibility-enabled nil) ; always off ++ ++When nil, no AX tree is built and no notifications are posted, ++giving zero per-redisplay overhead. ++Requires the Cocoa (NS) build on macOS; ignored on GNUstep. */); + ns_accessibility_enabled = NO; + + DEFVAR_BOOL ("ns-use-mwheel-acceleration", -- 2.43.0 diff --git a/patches/0006-doc-add-VoiceOver-accessibility-section-to-macOS-app.patch b/patches/0006-doc-add-VoiceOver-accessibility-section-to-macOS-app.patch index 81cd38d..3644096 100644 --- a/patches/0006-doc-add-VoiceOver-accessibility-section-to-macOS-app.patch +++ b/patches/0006-doc-add-VoiceOver-accessibility-section-to-macOS-app.patch @@ -1,4 +1,4 @@ -From 44cb6c8657feb1e17afabfb1a97d341727245bdd Mon Sep 17 00:00:00 2001 +From e2213409bca76154764263879b4bd43459230d6c Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 7/9] doc: add VoiceOver accessibility section to macOS diff --git a/patches/0007-ns-announce-overlay-completion-candidates-for-VoiceO.patch b/patches/0007-ns-announce-overlay-completion-candidates-for-VoiceO.patch index 42e4947..a6404db 100644 --- a/patches/0007-ns-announce-overlay-completion-candidates-for-VoiceO.patch +++ b/patches/0007-ns-announce-overlay-completion-candidates-for-VoiceO.patch @@ -1,4 +1,4 @@ -From 03bc19846230e9df6545948e6a431fdb7bdce031 Mon Sep 17 00:00:00 2001 +From a5041ede13b2bbcea1ebcb501f8c7317c0fe998f Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 14:46:25 +0100 Subject: [PATCH 8/9] ns: announce overlay completion candidates for VoiceOver @@ -61,10 +61,10 @@ index 6e830de..2102fb9 100644 @property (nonatomic, assign) BOOL cachedMarkActive; @property (nonatomic, copy) NSString *cachedCompletionAnnouncement; diff --git a/src/nsterm.m b/src/nsterm.m -index 1577338..71b6d2e 100644 +index 4ad451f..5654283 100644 --- a/src/nsterm.m +++ b/src/nsterm.m -@@ -7209,11 +7209,154 @@ Accessibility virtual elements (macOS / Cocoa only) +@@ -7257,11 +7257,154 @@ Accessibility virtual elements (macOS / Cocoa only) /* ---- Helper: extract buffer text for accessibility ---- */ @@ -220,7 +220,7 @@ index 1577338..71b6d2e 100644 static NSString * ns_ax_buffer_text (struct window *w, ptrdiff_t *out_start, ns_ax_visible_run **out_runs, NSUInteger *out_nruns) -@@ -7284,7 +7427,7 @@ Accessibility virtual elements (macOS / Cocoa only) +@@ -7332,7 +7475,7 @@ Accessibility virtual elements (macOS / Cocoa only) /* Extract this visible run's text. Use Fbuffer_substring_no_properties which correctly handles the @@ -229,7 +229,7 @@ index 1577338..71b6d2e 100644 include garbage bytes when the run spans the gap position. */ Lisp_Object lstr = Fbuffer_substring_no_properties ( make_fixnum (pos), make_fixnum (run_end)); -@@ -7365,7 +7508,7 @@ Mode lines using icon fonts (e.g. doom-modeline with nerd-font) +@@ -7413,7 +7556,7 @@ Mode lines using icon fonts (e.g. doom-modeline with nerd-font) return NSZeroRect; /* charpos_start and charpos_len are already in buffer charpos @@ -238,7 +238,7 @@ index 1577338..71b6d2e 100644 charposForAccessibilityIndex which handles invisible text. */ ptrdiff_t cp_start = charpos_start; ptrdiff_t cp_end = cp_start + charpos_len; -@@ -7844,6 +7987,7 @@ @implementation EmacsAccessibilityBuffer +@@ -7892,6 +8035,7 @@ @implementation EmacsAccessibilityBuffer @synthesize cachedOverlayModiff; @synthesize cachedTextStart; @synthesize cachedModiff; @@ -246,7 +246,7 @@ index 1577338..71b6d2e 100644 @synthesize cachedPoint; @synthesize cachedMarkActive; @synthesize cachedCompletionAnnouncement; -@@ -7941,7 +8085,7 @@ - (void)ensureTextCache +@@ -7989,7 +8133,7 @@ - (void)ensureTextCache NSTRACE ("EmacsAccessibilityBuffer ensureTextCache"); /* This method is only called from the main thread (AX getters dispatch_sync to main first). Reads of cachedText/cachedTextModiff @@ -255,7 +255,7 @@ index 1577338..71b6d2e 100644 write section at the end needs synchronization to protect against concurrent reads from AX server thread. */ eassert ([NSThread isMainThread]); -@@ -7953,25 +8097,16 @@ - (void)ensureTextCache +@@ -8001,25 +8145,16 @@ - (void)ensureTextCache if (!b) return; @@ -289,7 +289,7 @@ index 1577338..71b6d2e 100644 && cachedTextStart == BUF_BEGV (b) && pt >= cachedTextStart && (textLen == 0 -@@ -7987,7 +8122,7 @@ included in the cached AX text (it is handled separately via +@@ -8035,7 +8170,7 @@ included in the cached AX text (it is handled separately via { [cachedText release]; cachedText = [text retain]; @@ -298,7 +298,7 @@ index 1577338..71b6d2e 100644 cachedTextStart = start; if (visibleRuns) -@@ -8052,7 +8187,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos +@@ -8100,7 +8235,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos /* 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 @@ -307,7 +307,7 @@ index 1577338..71b6d2e 100644 NSUInteger lo = 0, hi = visibleRunCount; while (lo < hi) { -@@ -8065,7 +8200,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos +@@ -8113,7 +8248,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos else { /* Found: charpos is inside this run. Compute UTF-16 delta @@ -316,7 +316,7 @@ index 1577338..71b6d2e 100644 NSUInteger chars_in = (NSUInteger)(charpos - r->charpos); if (chars_in == 0 || !cachedText) return r->ax_start; -@@ -8090,10 +8225,10 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos +@@ -8138,10 +8273,10 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos /* Convert accessibility string index to buffer charpos. Safe to call from any thread: uses only cachedText (NSString) and @@ -329,7 +329,7 @@ index 1577338..71b6d2e 100644 @synchronized (self) { if (visibleRunCount == 0) -@@ -8127,7 +8262,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx +@@ -8175,7 +8310,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx return cp; } } @@ -338,7 +338,7 @@ index 1577338..71b6d2e 100644 if (lo > 0) { ns_ax_visible_run *last = &visibleRuns[visibleRunCount - 1]; -@@ -8149,7 +8284,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx +@@ -8197,7 +8332,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx deadlocking the AX server thread. This is prevented by: 1. validWindow checks WINDOW_LIVE_P and BUFFERP before every @@ -347,7 +347,7 @@ index 1577338..71b6d2e 100644 2. All dispatch_sync blocks run on the main thread where no concurrent Lisp code can modify state between checks. 3. block_input prevents timer events and process output from -@@ -8503,6 +8638,50 @@ - (NSInteger)accessibilityInsertionPointLineNumber +@@ -8551,6 +8686,50 @@ - (NSInteger)accessibilityInsertionPointLineNumber return [self lineForAXIndex:point_idx]; } @@ -398,7 +398,7 @@ index 1577338..71b6d2e 100644 - (NSRange)accessibilityRangeForLine:(NSInteger)line { if (![NSThread isMainThread]) -@@ -8725,7 +8904,7 @@ - (NSRect)accessibilityFrame +@@ -8773,7 +8952,7 @@ - (NSRect)accessibilityFrame /* =================================================================== @@ -407,7 +407,7 @@ index 1577338..71b6d2e 100644 These methods notify VoiceOver of text and selection changes. Called from the redisplay cycle (postAccessibilityUpdates). -@@ -8740,7 +8919,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point +@@ -8788,7 +8967,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point if (point > self.cachedPoint && point - self.cachedPoint == 1) { @@ -416,7 +416,7 @@ index 1577338..71b6d2e 100644 [self invalidateTextCache]; [self ensureTextCache]; if (cachedText) -@@ -8759,7 +8938,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point +@@ -8807,7 +8986,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point /* 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 @@ -425,7 +425,7 @@ index 1577338..71b6d2e 100644 self.cachedPoint = point; NSDictionary *change = @{ -@@ -9092,16 +9271,83 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f +@@ -9140,16 +9319,83 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f BOOL markActive = !NILP (BVAR (b, mark_active)); /* --- Text changed (edit) --- */ @@ -513,7 +513,7 @@ index 1577338..71b6d2e 100644 { ptrdiff_t oldPoint = self.cachedPoint; BOOL oldMarkActive = self.cachedMarkActive; -@@ -9269,7 +9515,7 @@ - (NSRect)accessibilityFrame +@@ -9317,7 +9563,7 @@ - (NSRect)accessibilityFrame /* =================================================================== @@ -522,7 +522,7 @@ index 1577338..71b6d2e 100644 =================================================================== */ /* Scan visible range of window W for interactive spans. -@@ -9477,7 +9723,7 @@ - (void) setAccessibilityFocused: (BOOL) focused +@@ -9525,7 +9771,7 @@ - (void) setAccessibilityFocused: (BOOL) focused dispatch_async (dispatch_get_main_queue (), ^{ /* lwin is a Lisp_Object captured by value. This is GC-safe because Lisp_Objects are tagged integers/pointers that @@ -531,7 +531,7 @@ index 1577338..71b6d2e 100644 Emacs. The WINDOW_LIVE_P check below guards against the window being deleted between capture and execution. */ if (!WINDOWP (lwin) || NILP (Fwindow_live_p (lwin))) -@@ -9503,7 +9749,7 @@ - (void) setAccessibilityFocused: (BOOL) focused +@@ -9551,7 +9797,7 @@ - (void) setAccessibilityFocused: (BOOL) focused @end @@ -540,7 +540,7 @@ index 1577338..71b6d2e 100644 Methods are kept here (same .m file) so they access the ivars declared in the @interface ivar block. */ @implementation EmacsAccessibilityBuffer (InteractiveSpans) -@@ -12225,7 +12471,7 @@ - (int) fullscreenState +@@ -12273,7 +12519,7 @@ - (int) fullscreenState if (WINDOW_LEAF_P (w)) { @@ -549,7 +549,7 @@ index 1577338..71b6d2e 100644 EmacsAccessibilityBuffer *elem = [existing objectForKey:[NSValue valueWithPointer:w]]; if (!elem) -@@ -12259,7 +12505,7 @@ - (int) fullscreenState +@@ -12307,7 +12553,7 @@ - (int) fullscreenState } else { @@ -558,7 +558,7 @@ index 1577338..71b6d2e 100644 Lisp_Object child = w->contents; while (!NILP (child)) { -@@ -12371,7 +12617,7 @@ - (void)postAccessibilityUpdates +@@ -12419,7 +12665,7 @@ - (void)postAccessibilityUpdates accessibilityUpdating = YES; /* Detect window tree change (split, delete, new buffer). Compare @@ -567,7 +567,7 @@ index 1577338..71b6d2e 100644 Lisp_Object curRoot = FRAME_ROOT_WINDOW (emacsframe); if (!EQ (curRoot, lastRootWindow)) { -@@ -12380,12 +12626,12 @@ - (void)postAccessibilityUpdates +@@ -12428,12 +12674,12 @@ - (void)postAccessibilityUpdates } /* If tree is stale, rebuild FIRST so we don't iterate freed diff --git a/patches/0008-ns-announce-child-frame-completion-candidates-for-Vo.patch b/patches/0008-ns-announce-child-frame-completion-candidates-for-Vo.patch index 23f5ca5..09cf04a 100644 --- a/patches/0008-ns-announce-child-frame-completion-candidates-for-Vo.patch +++ b/patches/0008-ns-announce-child-frame-completion-candidates-for-Vo.patch @@ -1,4 +1,4 @@ -From 2466072f55f562d96d189814815bf8c4084338b5 Mon Sep 17 00:00:00 2001 +From 2dabc7e44d316fa29e64958383fbac230f0f6870 Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 16:01:29 +0100 Subject: [PATCH 9/9] ns: announce child frame completion candidates for @@ -109,10 +109,10 @@ index 2102fb9..dd98d56 100644 @end diff --git a/src/nsterm.m b/src/nsterm.m -index 71b6d2e..fd7c520 100644 +index 5654283..69644d5 100644 --- a/src/nsterm.m +++ b/src/nsterm.m -@@ -7353,6 +7353,112 @@ visual line index for Zoom (skip whitespace-only lines +@@ -7401,6 +7401,112 @@ visual line index for Zoom (skip whitespace-only lines return nil; } @@ -225,7 +225,7 @@ index 71b6d2e..fd7c520 100644 /* Build accessibility text for window W, skipping invisible text. Populates *OUT_START with the buffer start charpos. Populates *OUT_RUNS with an array of visible runs and *OUT_NRUNS -@@ -8097,16 +8203,25 @@ - (void)ensureTextCache +@@ -8145,16 +8251,25 @@ - (void)ensureTextCache if (!b) return; @@ -259,7 +259,7 @@ index 71b6d2e..fd7c520 100644 && cachedTextStart == BUF_BEGV (b) && pt >= cachedTextStart && (textLen == 0 -@@ -8122,7 +8237,7 @@ included in the cached AX text (it is handled separately via +@@ -8170,7 +8285,7 @@ included in the cached AX text (it is handled separately via { [cachedText release]; cachedText = [text retain]; @@ -268,7 +268,7 @@ index 71b6d2e..fd7c520 100644 cachedTextStart = start; if (visibleRuns) -@@ -9090,6 +9205,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b +@@ -9138,6 +9253,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b ptrdiff_t currentOverlayStart = 0; ptrdiff_t currentOverlayEnd = 0; @@ -276,7 +276,7 @@ index 71b6d2e..fd7c520 100644 specpdl_ref count2 = SPECPDL_INDEX (); record_unwind_current_buffer (); if (b != current_buffer) -@@ -9248,6 +9364,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b +@@ -9296,6 +9412,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b self.cachedCompletionOverlayEnd = 0; self.cachedCompletionPoint = 0; } @@ -284,7 +284,7 @@ index 71b6d2e..fd7c520 100644 } /* ---- Notification dispatch (main entry point) ---- */ -@@ -9844,6 +9961,10 @@ - (void)dealloc +@@ -9892,6 +10009,10 @@ - (void)dealloc #endif [accessibilityElements release]; @@ -295,7 +295,7 @@ index 71b6d2e..fd7c520 100644 [[self menu] release]; [super dealloc]; } -@@ -11293,6 +11414,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f +@@ -11341,6 +11462,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f windowClosing = NO; processingCompose = NO; @@ -305,7 +305,7 @@ index 71b6d2e..fd7c520 100644 scrollbarsNeedingUpdate = 0; fs_state = FULLSCREEN_NONE; fs_before_fs = next_maximized = -1; -@@ -12601,6 +12725,80 @@ - (id)accessibilityFocusedUIElement +@@ -12649,6 +12773,80 @@ - (id)accessibilityFocusedUIElement The existing elements carry cached state (modiff, point) from the previous redisplay cycle. Rebuilding first would create fresh elements with current values, making change detection impossible. */ @@ -386,7 +386,7 @@ index 71b6d2e..fd7c520 100644 - (void)postAccessibilityUpdates { NSTRACE ("[EmacsView postAccessibilityUpdates]"); -@@ -12611,11 +12809,59 @@ - (void)postAccessibilityUpdates +@@ -12659,11 +12857,59 @@ - (void)postAccessibilityUpdates /* Re-entrance guard: VoiceOver callbacks during notification posting can trigger redisplay, which calls ns_update_end, which calls us