From 9130268ff04e5df3b41777c21c08f0c276c75d3c Mon Sep 17 00:00:00 2001 From: Daneel Date: Sat, 28 Feb 2026 12:58:18 +0100 Subject: [PATCH] patches: fix ObjC category declaration warnings Move postAccessibilityNotificationsForFrame: declaration from primary @interface to (Notifications) category. Add invalidateInteractiveSpans to (InteractiveSpans) category. Fixes 3 compiler warnings (-Wobjc-method-access, -Wincomplete-implementation, -Wobjc-protocol-method-implementation). --- ...lity-base-classes-and-text-extractio.patch | 41 +++++++++++-------- ...fer-accessibility-element-core-proto.patch | 4 +- ...tification-dispatch-and-mode-line-el.patch | 13 +++--- ...ive-span-elements-for-Tab-navigation.patch | 9 ++-- ...essibility-with-EmacsView-and-redisp.patch | 23 ++++------- ...r-accessibility-section-to-macOS-app.patch | 4 +- 6 files changed, 44 insertions(+), 50 deletions(-) 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 bbe2097..24f777f 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,6 +1,6 @@ -From 69b3f939764d4a7e5e9dc7bcb882b654364d7ca9 Mon Sep 17 00:00:00 2001 +From 3bb5a0bed12de424e79a24228e6ae2b4a6e0ecf1 Mon Sep 17 00:00:00 2001 From: Martin Sukany -Date: Sat, 28 Feb 2026 10:35:35 +0100 +Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 1/6] ns: add accessibility base classes and text extraction Add the foundation for macOS VoiceOver accessibility in the NS @@ -10,19 +10,18 @@ Add the foundation for macOS VoiceOver accessibility in the NS (EmacsAccessibilityElement): New base class. (EmacsAccessibilityBuffer, EmacsAccessibilityModeLine) (EmacsAccessibilityInteractiveSpan): Forward declarations. +(EmacsAccessibilityBuffer(Notifications)): New category interface. +(EmacsAccessibilityBuffer(InteractiveSpans)): New category interface. (EmacsAXSpanType): New enum. (EmacsView): New ivars for accessibility state. * src/nsterm.m: Include intervals.h for TEXT_PROP_MEANS_INVISIBLE. (NS_AX_TEXT_CAP): New macro, 100000. -(ns_ax_buffer_text): New function. -(ns_ax_mode_line_text): New function. -(ns_ax_frame_for_range): New function. -(ns_ax_completion_string_from_prop): New function. -(ns_ax_window_buffer_object, ns_ax_window_end_charpos) -(ns_ax_text_prop_at, ns_ax_next_prop_change) -(ns_ax_get_span_label): New utility functions. +(ns_ax_buffer_text, ns_ax_mode_line_text, ns_ax_frame_for_range) +(ns_ax_completion_string_from_prop, ns_ax_window_buffer_object) +(ns_ax_window_end_charpos, ns_ax_text_prop_at) +(ns_ax_next_prop_change, ns_ax_get_span_label) (ns_ax_post_notification, ns_ax_post_notification_with_info): New -functions. dispatch_async wrappers preventing VoiceOver deadlock. +functions. (EmacsAccessibilityElement): Implement base class. (syms_of_nsterm): Register accessibility DEFSYM and DEFVAR ns-accessibility-enabled. @@ -30,15 +29,15 @@ ns-accessibility-enabled. Tested on macOS 14 Sonoma with VoiceOver 10. Builds cleanly; no functional change (dead code until patch 5/6 wires it in). --- - src/nsterm.h | 119 +++++++++++++ + src/nsterm.h | 127 ++++++++++++++ src/nsterm.m | 468 +++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 587 insertions(+) + 2 files changed, 595 insertions(+) diff --git a/src/nsterm.h b/src/nsterm.h -index 7c1ee4c..393fc4c 100644 +index 7c1ee4c..51c30ca 100644 --- a/src/nsterm.h +++ b/src/nsterm.h -@@ -453,6 +453,110 @@ enum ns_return_frame_mode +@@ -453,6 +453,118 @@ enum ns_return_frame_mode @end @@ -103,11 +102,19 @@ index 7c1ee4c..393fc4c 100644 +@property (nonatomic, assign) ptrdiff_t cachedCompletionOverlayEnd; +@property (nonatomic, assign) ptrdiff_t cachedCompletionPoint; +- (void)invalidateTextCache; -+- (void)postAccessibilityNotificationsForFrame:(struct frame *)f; +- (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx; +- (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos; +@end + ++@interface EmacsAccessibilityBuffer (Notifications) ++- (void)postTextChangedNotification:(ptrdiff_t)point; ++- (void)postAccessibilityNotificationsForFrame:(struct frame *)f; ++@end ++ ++@interface EmacsAccessibilityBuffer (InteractiveSpans) ++- (void)invalidateInteractiveSpans; ++@end ++ +/* Virtual AXStaticText element — one per mode line. */ +@interface EmacsAccessibilityModeLine : EmacsAccessibilityElement +@end @@ -149,7 +156,7 @@ index 7c1ee4c..393fc4c 100644 /* ========================================================================== The main Emacs view -@@ -471,6 +575,14 @@ enum ns_return_frame_mode +@@ -471,6 +583,14 @@ enum ns_return_frame_mode #ifdef NS_IMPL_COCOA char *old_title; BOOL maximizing_resize; @@ -164,7 +171,7 @@ index 7c1ee4c..393fc4c 100644 #endif BOOL font_panel_active; NSFont *font_panel_result; -@@ -528,6 +640,13 @@ enum ns_return_frame_mode +@@ -528,6 +648,13 @@ enum ns_return_frame_mode - (void)windowWillExitFullScreen; - (void)windowDidExitFullScreen; - (void)windowDidBecomeKey; 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 561e537..99fa840 100644 --- a/patches/0002-ns-implement-buffer-accessibility-element-core-proto.patch +++ b/patches/0002-ns-implement-buffer-accessibility-element-core-proto.patch @@ -1,6 +1,6 @@ -From 51b6682ecdd088835b36462caf0a94b6a4ca1aea Mon Sep 17 00:00:00 2001 +From b448ae7e4c129a12a4a5485f26f706614c0da1cd Mon Sep 17 00:00:00 2001 From: Martin Sukany -Date: Sat, 28 Feb 2026 10:35:35 +0100 +Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 2/6] ns: implement buffer accessibility element (core protocol) 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 6f27847..2a31572 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,6 +1,6 @@ -From dc701c1028f8fa4f043127564de0b3c276021327 Mon Sep 17 00:00:00 2001 +From 8163e04dbc948ff24633bed534a8c66b9bc1b187 Mon Sep 17 00:00:00 2001 From: Martin Sukany -Date: Sat, 28 Feb 2026 10:35:35 +0100 +Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 3/6] ns: add buffer notification dispatch and mode-line element @@ -11,14 +11,11 @@ category. (postTextChangedNotification:): ValueChanged with edit details. (postFocusedCursorNotification:direction:granularity:markActive: oldMarkActive:): Hybrid SelectedTextChanged / AnnouncementRequested -per WebKit pattern. Deduplicates notification storms from -redisplay. +per WebKit pattern. (postCompletionAnnouncementForBuffer:point:): Announce completion candidates in non-focused buffers. -(postAccessibilityNotificationsForFrame:): Main dispatch entry -point: edit vs cursor-move vs no-change. -(EmacsAccessibilityModeLine): Implement AXStaticText element for -mode-line readout. +(postAccessibilityNotificationsForFrame:): Main dispatch entry point. +(EmacsAccessibilityModeLine): Implement AXStaticText element. Tested on macOS 14. Verified: cursor movement announcements, region selection feedback, completion popups, mode-line reading. 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 f0eb24a..9faae47 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,12 +1,9 @@ -From 74f5b0e286fd771457a2d9bcb1fa455c6bb4a5e0 Mon Sep 17 00:00:00 2001 +From 6626fa801e94c693d0027c3d7b02e750def95df9 Mon Sep 17 00:00:00 2001 From: Martin Sukany -Date: Sat, 28 Feb 2026 10:35:35 +0100 +Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 4/6] ns: add interactive span elements for Tab navigation -* src/nsterm.m (ns_ax_scan_interactive_spans): New function. Scan -visible range with O(n/skip) property-skip optimization. Priority: -widget > button > follow-link > org-link > completion-candidate > -keymap-overlay. +* src/nsterm.m (ns_ax_scan_interactive_spans): New function. (EmacsAccessibilityInteractiveSpan): Implement AXButton/AXLink elements with AXPress action. (EmacsAccessibilityBuffer(InteractiveSpans)): New category. 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 f2150d1..0e0a232 100644 --- a/patches/0005-ns-integrate-accessibility-with-EmacsView-and-redisp.patch +++ b/patches/0005-ns-integrate-accessibility-with-EmacsView-and-redisp.patch @@ -1,6 +1,6 @@ -From 2de08fd21b94d2eec8271b162a6bbfa94576356c Mon Sep 17 00:00:00 2001 +From 72a0b8bad2d200cf093d9e0c60d937032784bd74 Mon Sep 17 00:00:00 2001 From: Martin Sukany -Date: Sat, 28 Feb 2026 10:35:35 +0100 +Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 5/6] ns: integrate accessibility with EmacsView and redisplay Wire the accessibility infrastructure into EmacsView and the @@ -11,25 +11,18 @@ redisplay cycle. After this patch, VoiceOver and Zoom are active. (EmacsView dealloc): Release accessibilityElements. (EmacsView windowDidBecomeKey): Post accessibility focus notification. (ns_ax_collect_windows): New function. -(EmacsView rebuildAccessibilityTree): New method. -(EmacsView invalidateAccessibilityTree): New method. -(EmacsView accessibilityChildren): New method. -(EmacsView accessibilityFocusedUIElement): New method. -(EmacsView postAccessibilityUpdates): New method. -(EmacsView accessibilityBoundsForRange:): New method. -(EmacsView accessibilityParameterizedAttributeNames): New method. -(EmacsView accessibilityAttributeValue:forParameter:): New method. +(EmacsView rebuildAccessibilityTree, invalidateAccessibilityTree) +(accessibilityChildren, accessibilityFocusedUIElement) +(postAccessibilityUpdates, accessibilityBoundsForRange:) +(accessibilityParameterizedAttributeNames) +(accessibilityAttributeValue:forParameter:): New methods. * etc/NEWS: Document VoiceOver accessibility support. Tested on macOS 14 with VoiceOver and Zoom. End-to-end: buffer navigation, cursor tracking, window switching, completions, evil-mode block cursor, org-mode folded headings, indirect buffers. -Known limitations: -- Bidi: accessibilityRangeForPosition assumes LTR glyph layout. -- Mode-line icons: image/stretch glyphs not extracted (TODO). -- Text cap: buffers exceeding NS_AX_TEXT_CAP (100K) truncated. -- Non-ASCII: tested with CJK (UTF-16 surrogates) and combining chars. +Known limitations documented in patch 6 Texinfo node. --- etc/NEWS | 13 ++ src/nsterm.m | 398 ++++++++++++++++++++++++++++++++++++++++++++++++++- 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 75f400c..16b28ca 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,6 +1,6 @@ -From e78b534524fec76d257db2c590a87ef61ea4f291 Mon Sep 17 00:00:00 2001 +From 2865a2fccc26e339a4f649b65ab07cf323acf0d1 Mon Sep 17 00:00:00 2001 From: Martin Sukany -Date: Sat, 28 Feb 2026 10:35:36 +0100 +Date: Sat, 28 Feb 2026 12:58:11 +0100 Subject: [PATCH 6/6] doc: add VoiceOver accessibility section to macOS appendix