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 8d2227e..def28fa 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 1834e38e60c9e9f898a7e67894c1c9b717db339b Mon Sep 17 00:00:00 2001 +From 4f148cc62b903aac6f9b98832d9f543729964d65 Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 1/8] ns: add accessibility base classes and text extraction @@ -34,7 +34,7 @@ no functional change (dead code until patch 5/6 wires it in). 2 files changed, 585 insertions(+) diff --git a/src/nsterm.h b/src/nsterm.h -index 7c1ee4c..ca67bd9 100644 +index 7c1ee4c..8ea15b1 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -453,6 +453,122 @@ enum ns_return_frame_mode @@ -87,8 +87,8 @@ index 7c1ee4c..ca67bd9 100644 +{ + ns_ax_visible_run *visibleRuns; + NSUInteger visibleRunCount; -+ NSUInteger *lineStartOffsets; /* AX string index of each line start. */ -+ NSUInteger lineCount; /* Number of entries in lineStartOffsets. */ ++ NSUInteger *lineStartOffsets; /* AX index for each line. */ ++ NSUInteger lineCount; /* Entries in lineStartOffsets. */ + NSMutableArray *cachedInteractiveSpans; + BOOL interactiveSpansDirty; +} 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 cc6fef1..71b3774 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 9233586621907a44b6a6a1257d6965bf1c2fcee8 Mon Sep 17 00:00:00 2001 +From 8a27823b4cbe34959582d7557eb0a418103c8a80 Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 2/8] ns: implement buffer accessibility element (core @@ -18,14 +18,14 @@ setAccessibilityFocused. Tested on macOS 14 with VoiceOver. Verified: buffer reading, line-by-line navigation, word/character announcements. --- - src/nsterm.m | 1096 ++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 1096 insertions(+) + src/nsterm.m | 1097 ++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 1097 insertions(+) diff --git a/src/nsterm.m b/src/nsterm.m -index 2ac1d9d..1bcc84d 100644 +index 2ac1d9d..1cc824f 100644 --- a/src/nsterm.m +++ b/src/nsterm.m -@@ -7278,6 +7278,1102 @@ - (id)accessibilityTopLevelUIElement +@@ -7278,6 +7278,1103 @@ - (id)accessibilityTopLevelUIElement @end @@ -942,7 +942,8 @@ index 2ac1d9d..1bcc84d 100644 + if (!cachedText || index < 0 + || (NSUInteger) index >= [cachedText length]) + return NSMakeRange (NSNotFound, 0); -+ return [cachedText rangeOfComposedCharacterSequenceAtIndex:(NSUInteger)index]; ++ return [cachedText ++ rangeOfComposedCharacterSequenceAtIndex:(NSUInteger)index]; +} + +- (NSRange)accessibilityStyleRangeForIndex:(NSInteger)index 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 70a83c2..faa06e4 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 d3bcf0db4dd16b70dc816fe3e6463b9f5ca7a9c2 Mon Sep 17 00:00:00 2001 +From 171e5fb9f27a4a1c62ddd2fc9246f29d8e2c224b Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 3/8] ns: add buffer notification dispatch and mode-line @@ -24,10 +24,10 @@ region selection feedback, completion popups, mode-line reading. 1 file changed, 545 insertions(+) diff --git a/src/nsterm.m b/src/nsterm.m -index 1bcc84d..dfb84ca 100644 +index 1cc824f..30a89f0 100644 --- a/src/nsterm.m +++ b/src/nsterm.m -@@ -8374,6 +8374,551 @@ - (NSRect)accessibilityFrame +@@ -8375,6 +8375,551 @@ - (NSRect)accessibilityFrame @end 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 67d029b..5ac267f 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 30fc5f90489e8802ed950317076ce39cdab66d25 Mon Sep 17 00:00:00 2001 +From 96763efb71773ed424230cb1773f8ce2ed7a5ac8 Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 4/8] ns: add interactive span elements for Tab navigation @@ -17,10 +17,10 @@ Tested on macOS 14. Verified: Tab-cycling through org-mode links, 1 file changed, 286 insertions(+) diff --git a/src/nsterm.m b/src/nsterm.m -index dfb84ca..c852929 100644 +index 30a89f0..3a76a0f 100644 --- a/src/nsterm.m +++ b/src/nsterm.m -@@ -8919,6 +8919,292 @@ - (NSRect)accessibilityFrame +@@ -8920,6 +8920,292 @@ - (NSRect)accessibilityFrame @end 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 de089d4..e69d310 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 f1e29f1ec0695a7c97bfc5587274995a4b1052f1 Mon Sep 17 00:00:00 2001 +From af7342d4f5f67531b01f636e00885d40a4edeea5 Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 5/8] ns: integrate accessibility with EmacsView and redisplay @@ -52,7 +52,7 @@ index ef36df5..e76ee93 100644 ** Re-introduced dictation, lost in Emacs v30 (macOS). We lost macOS dictation in v30 when migrating to NSTextInputClient. diff --git a/src/nsterm.h b/src/nsterm.h -index ca67bd9..ec7b587 100644 +index 8ea15b1..d308a71 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -593,6 +593,8 @@ typedef NS_ENUM (NSInteger, EmacsAXSpanType) @@ -65,7 +65,7 @@ index ca67bd9..ec7b587 100644 BOOL font_panel_active; NSFont *font_panel_result; diff --git a/src/nsterm.m b/src/nsterm.m -index c852929..f0e8751 100644 +index 3a76a0f..156dba9 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1105,6 +1105,11 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen) @@ -107,7 +107,7 @@ index c852929..f0e8751 100644 static BOOL ns_ax_find_completion_overlay_range (struct buffer *b, ptrdiff_t point, ptrdiff_t *out_start, -@@ -8375,7 +8391,6 @@ - (NSRect)accessibilityFrame +@@ -8376,7 +8392,6 @@ - (NSRect)accessibilityFrame @end @@ -115,7 +115,7 @@ index c852929..f0e8751 100644 /* =================================================================== EmacsAccessibilityBuffer (Notifications) — AX event dispatch -@@ -8920,7 +8935,6 @@ - (NSRect)accessibilityFrame +@@ -8921,7 +8936,6 @@ - (NSRect)accessibilityFrame @end @@ -123,7 +123,7 @@ index c852929..f0e8751 100644 /* =================================================================== EmacsAccessibilityInteractiveSpan — helpers and implementation =================================================================== */ -@@ -9250,6 +9264,7 @@ - (void)dealloc +@@ -9251,6 +9265,7 @@ - (void)dealloc [layer release]; #endif @@ -131,7 +131,7 @@ index c852929..f0e8751 100644 [[self menu] release]; [super dealloc]; } -@@ -10598,6 +10613,32 @@ - (void)windowDidBecomeKey /* for direct calls */ +@@ -10599,6 +10614,32 @@ - (void)windowDidBecomeKey /* for direct calls */ XSETFRAME (event.frame_or_window, emacsframe); kbd_buffer_store_event (&event); ns_send_appdefined (-1); // Kick main loop @@ -164,7 +164,7 @@ index c852929..f0e8751 100644 } -@@ -11835,6 +11876,332 @@ - (int) fullscreenState +@@ -11836,6 +11877,332 @@ - (int) fullscreenState return fs_state; } 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 a101064..68d1be1 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 4957ac5c94e8266688ed8479b21f2322e2aa4c86 Mon Sep 17 00:00:00 2001 +From 970373177e737b5050ce4160c6609a21b2501e85 Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 6/8] 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 982e7e0..a27e68c 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 479cfe85e8efc97c184ca68bbe4373d762e5841f Mon Sep 17 00:00:00 2001 +From d8a9886e85772c934b9f619251f301ee9baddc84 Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 14:46:25 +0100 Subject: [PATCH 7/8] ns: announce overlay completion candidates for VoiceOver @@ -45,11 +45,11 @@ Key implementation details: Independent overlay branch, BUF_CHARS_MODIFF gating, candidate --- src/nsterm.h | 1 + - src/nsterm.m | 308 +++++++++++++++++++++++++++++++++++++++++++++------ - 2 files changed, 277 insertions(+), 32 deletions(-) + src/nsterm.m | 306 +++++++++++++++++++++++++++++++++++++++++++++------ + 2 files changed, 276 insertions(+), 31 deletions(-) diff --git a/src/nsterm.h b/src/nsterm.h -index ec7b587..19a7e7a 100644 +index d308a71..7a8c5a0 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -509,6 +509,7 @@ typedef struct ns_ax_visible_run @@ -61,7 +61,7 @@ index ec7b587..19a7e7a 100644 @property (nonatomic, assign) BOOL cachedMarkActive; @property (nonatomic, copy) NSString *cachedCompletionAnnouncement; diff --git a/src/nsterm.m b/src/nsterm.m -index f0e8751..72478e0 100644 +index 156dba9..a6fce74 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -6884,11 +6884,154 @@ Accessibility virtual elements (macOS / Cocoa only) @@ -386,7 +386,7 @@ index f0e8751..72478e0 100644 - (NSRange)accessibilityRangeForLine:(NSInteger)line { if (![NSThread isMainThread]) -@@ -8392,7 +8578,7 @@ - (NSRect)accessibilityFrame +@@ -8393,7 +8579,7 @@ - (NSRect)accessibilityFrame /* =================================================================== @@ -395,7 +395,7 @@ index f0e8751..72478e0 100644 These methods notify VoiceOver of text and selection changes. Called from the redisplay cycle (postAccessibilityUpdates). -@@ -8407,7 +8593,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point +@@ -8408,7 +8594,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point if (point > self.cachedPoint && point - self.cachedPoint == 1) { @@ -404,7 +404,7 @@ index f0e8751..72478e0 100644 [self invalidateTextCache]; [self ensureTextCache]; if (cachedText) -@@ -8426,7 +8612,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point +@@ -8427,7 +8613,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 @@ -413,7 +413,7 @@ index f0e8751..72478e0 100644 self.cachedPoint = point; NSDictionary *change = @{ -@@ -8759,14 +8945,72 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f +@@ -8760,14 +8946,72 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f BOOL markActive = !NILP (BVAR (b, mark_active)); /* --- Text changed (edit) --- */ @@ -488,7 +488,7 @@ index f0e8751..72478e0 100644 per the WebKit/Chromium pattern. */ else if (point != self.cachedPoint || markActive != self.cachedMarkActive) { -@@ -8936,7 +9180,7 @@ - (NSRect)accessibilityFrame +@@ -8937,7 +9181,7 @@ - (NSRect)accessibilityFrame /* =================================================================== @@ -497,16 +497,7 @@ index f0e8751..72478e0 100644 =================================================================== */ /* Scan visible range of window W for interactive spans. -@@ -9127,7 +9371,7 @@ - (NSRect) accessibilityFrame - - (BOOL) isAccessibilityFocused - { - /* Read the cached point stored by EmacsAccessibilityBuffer on the main -- thread — safe to read from any thread (plain ptrdiff_t, no Lisp calls). */ -+ thread --- safe to read from any thread (plain ptrdiff_t, no Lisp calls). */ - EmacsAccessibilityBuffer *pb = self.parentBuffer; - if (!pb) - return NO; -@@ -9144,7 +9388,7 @@ - (void) setAccessibilityFocused: (BOOL) focused +@@ -9145,7 +9389,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 @@ -515,7 +506,7 @@ index f0e8751..72478e0 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))) -@@ -9170,7 +9414,7 @@ - (void) setAccessibilityFocused: (BOOL) focused +@@ -9171,7 +9415,7 @@ - (void) setAccessibilityFocused: (BOOL) focused @end @@ -524,7 +515,7 @@ index f0e8751..72478e0 100644 Methods are kept here (same .m file) so they access the ivars declared in the @interface ivar block. */ @implementation EmacsAccessibilityBuffer (InteractiveSpans) -@@ -11892,7 +12136,7 @@ - (int) fullscreenState +@@ -11893,7 +12137,7 @@ - (int) fullscreenState if (WINDOW_LEAF_P (w)) { @@ -533,7 +524,7 @@ index f0e8751..72478e0 100644 EmacsAccessibilityBuffer *elem = [existing objectForKey:[NSValue valueWithPointer:w]]; if (!elem) -@@ -11926,7 +12170,7 @@ - (int) fullscreenState +@@ -11927,7 +12171,7 @@ - (int) fullscreenState } else { @@ -542,7 +533,7 @@ index f0e8751..72478e0 100644 Lisp_Object child = w->contents; while (!NILP (child)) { -@@ -12038,7 +12282,7 @@ - (void)postAccessibilityUpdates +@@ -12039,7 +12283,7 @@ - (void)postAccessibilityUpdates accessibilityUpdating = YES; /* Detect window tree change (split, delete, new buffer). Compare @@ -551,7 +542,7 @@ index f0e8751..72478e0 100644 Lisp_Object curRoot = FRAME_ROOT_WINDOW (emacsframe); if (!EQ (curRoot, lastRootWindow)) { -@@ -12047,12 +12291,12 @@ - (void)postAccessibilityUpdates +@@ -12048,12 +12292,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 2ebd346..6daf7cc 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 c76af5456ed23045749a221bd42896e8f8e8601a Mon Sep 17 00:00:00 2001 +From 14ee30459ef494e4c6f0c766cf8d24007e75659a Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 16:01:29 +0100 Subject: [PATCH 8/8] ns: announce child frame completion candidates for @@ -86,7 +86,7 @@ index e76ee93..c3e0b40 100644 for the *Completions* buffer. The implementation uses a virtual accessibility tree with per-window elements, hybrid SelectedTextChanged diff --git a/src/nsterm.h b/src/nsterm.h -index 19a7e7a..49e8f00 100644 +index 7a8c5a0..9ac65ac 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -596,6 +596,10 @@ typedef NS_ENUM (NSInteger, EmacsAXSpanType) @@ -109,7 +109,7 @@ index 19a7e7a..49e8f00 100644 @end diff --git a/src/nsterm.m b/src/nsterm.m -index 72478e0..daa8f61 100644 +index a6fce74..75ef0e0 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -7028,6 +7028,112 @@ visual line index for Zoom (skip whitespace-only lines @@ -225,7 +225,7 @@ index 72478e0..daa8f61 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 -@@ -12266,6 +12372,77 @@ - (id)accessibilityFocusedUIElement +@@ -12267,6 +12373,77 @@ - (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. */ @@ -303,7 +303,7 @@ index 72478e0..daa8f61 100644 - (void)postAccessibilityUpdates { NSTRACE ("[EmacsView postAccessibilityUpdates]"); -@@ -12276,11 +12453,59 @@ - (void)postAccessibilityUpdates +@@ -12277,11 +12454,59 @@ - (void)postAccessibilityUpdates /* Re-entrance guard: VoiceOver callbacks during notification posting can trigger redisplay, which calls ns_update_end, which calls us