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 90649f1..ad12f82 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 d71de5bc8af58083ee024fd7117d06bf7e6cc0d0 Mon Sep 17 00:00:00 2001 +From 66e54b491f6158a160f2191e9549da7e9a666fa2 Mon Sep 17 00:00:00 2001 From: Martin Sukany Date: Sat, 28 Feb 2026 22:39:35 +0100 Subject: [PATCH 0/8] 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 bc82070..4175197 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 07aa615d046f1af0d02e22f834a2728a75943d18 Mon Sep 17 00:00:00 2001 +From d58eefa46c7673eff2272ebcceea82c031152e10 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 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 64b2dbd..77fc2db 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 885981f0f365c58167cc6ea8e7cff65f14e1f57f Mon Sep 17 00:00:00 2001 +From 07e5007d2ad00a191339286c41ad12aa8439636f 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 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 fa76ea5..c526236 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 af4a3c4333452107c9299950ff947af53ab1b705 Mon Sep 17 00:00:00 2001 +From 6df7e595967100a26599fd9a575f7f947238e2f1 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 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 bab1eb2..9cbfffd 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 589f1536255d1ad28552d8047387fbf3e9288235 Mon Sep 17 00:00:00 2001 +From e270501ae776e953e369fcfdaf5ba2237c3a44c3 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 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 4410318..cf104e2 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 2892f6c1591e8cf269897d738367daf38ae85326 Mon Sep 17 00:00:00 2001 +From 0ac5f50dfe0a4111a6538e1106b6f4ac5259659e 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 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 3e3da18..dfc0227 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 09e78385e7ccaf3a74d333f741f408bd2baa88f3 Mon Sep 17 00:00:00 2001 +From 7e419d0b59c4d4cbec800306a61eecaaa1921500 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 5e59bda..ae02792 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 92aec64d791200f54fcd756b5a07581a6c15d0cb Mon Sep 17 00:00:00 2001 +From c1fa92dbf8caa6faffed7a0813c92bed2f983092 Mon Sep 17 00:00:00 2001 From: Daneel Date: Mon, 2 Mar 2026 18:39:46 +0100 Subject: [PATCH 7/8] ns: announce overlay completion candidates for VoiceOver @@ -18,8 +18,8 @@ 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 | 324 ++++++++++++++++++++++++++++++++++++++++++++------- - 2 files changed, 286 insertions(+), 39 deletions(-) + src/nsterm.m | 318 +++++++++++++++++++++++++++++++++++++++++++++------ + 2 files changed, 283 insertions(+), 36 deletions(-) diff --git a/src/nsterm.h b/src/nsterm.h index 5746e9e9bd..21a93bc799 100644 @@ -34,7 +34,7 @@ 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 8a1bfd9eb1..7fa28222b6 100644 +index 8a1bfd9eb1..523f79d235 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -7263,11 +7263,154 @@ Accessibility virtual elements (macOS / Cocoa only) @@ -228,7 +228,7 @@ index 8a1bfd9eb1..7fa28222b6 100644 write section at the end needs synchronization to protect against concurrent reads from AX server thread. */ eassert ([NSThread isMainThread]); -@@ -8005,25 +8149,16 @@ - (void)ensureTextCache +@@ -8005,24 +8149,15 @@ - (void)ensureTextCache if (!b) return; @@ -247,30 +247,18 @@ index 8a1bfd9eb1..7fa28222b6 100644 - explicit announcements in postAccessibilityNotificationsForFrame). - Including overlay_modiff would silently update cachedOverlayModiff - and prevent the notification dispatch from detecting changes. */ -- ptrdiff_t chars_modiff = BUF_CHARS_MODIFF (b); -+ ptrdiff_t modiff = BUF_MODIFF (b); + ptrdiff_t chars_modiff = BUF_CHARS_MODIFF (b); ptrdiff_t pt = BUF_PT (b); NSUInteger textLen = cachedText ? [cachedText length] : 0; -- if (cachedText && cachedTextModiff == chars_modiff + /* Cache validity: track BUF_MODIFF and buffer narrowing. + Do NOT track BUF_OVERLAY_MODIFF here --- overlay text is not + included in the cached AX text (it is handled separately via + explicit announcements). Including overlay_modiff would + silently update cachedOverlayModiff and prevent the + notification dispatch from detecting overlay changes. */ -+ if (cachedText && cachedTextModiff == modiff + if (cachedText && cachedTextModiff == chars_modiff && cachedTextStart == BUF_BEGV (b) && pt >= cachedTextStart - && (textLen == 0 -@@ -8039,7 +8174,7 @@ included in the cached AX text (it is handled separately via - { - [cachedText release]; - cachedText = [text retain]; -- cachedTextModiff = chars_modiff; -+ cachedTextModiff = modiff; - cachedTextStart = start; - - if (visibleRuns) @@ -8108,7 +8243,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, 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 1bd506d..69c227f 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 a442640322cfb64956e28cc01442c75815718bb9 Mon Sep 17 00:00:00 2001 +From 2de5c652dbcc355549941cc9940bac9f31ab3ea6 Mon Sep 17 00:00:00 2001 From: Daneel Date: Mon, 2 Mar 2026 18:49:13 +0100 Subject: [PATCH 8/8] ns: announce child frame completion candidates for @@ -33,8 +33,8 @@ area announcements. doc/emacs/macos.texi | 14 +- etc/NEWS | 18 +- src/nsterm.h | 20 ++ - src/nsterm.m | 529 +++++++++++++++++++++++++++++++++++++++---- - 4 files changed, 530 insertions(+), 51 deletions(-) + src/nsterm.m | 515 ++++++++++++++++++++++++++++++++++++++++--- + 4 files changed, 519 insertions(+), 48 deletions(-) diff --git a/doc/emacs/macos.texi b/doc/emacs/macos.texi index 8d4a7825d8..03a657f970 100644 @@ -149,7 +149,7 @@ index 21a93bc799..bdd40b8eb7 100644 @end diff --git a/src/nsterm.m b/src/nsterm.m -index 7fa28222b6..6e0575677e 100644 +index 523f79d235..a885249f30 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1126,24 +1126,19 @@ Uses CFAbsoluteTimeGetCurrent() (~5 ns, a VDSO read) for timing. */ @@ -313,14 +313,10 @@ index 7fa28222b6..6e0575677e 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 -@@ -8149,16 +8256,32 @@ - (void)ensureTextCache +@@ -8149,15 +8256,23 @@ - (void)ensureTextCache if (!b) return; -- ptrdiff_t modiff = BUF_MODIFF (b); -- ptrdiff_t pt = BUF_PT (b); -- NSUInteger textLen = cachedText ? [cachedText length] : 0; -- /* Cache validity: track BUF_MODIFF and buffer narrowing. + /* Use BUF_CHARS_MODIFF, not BUF_MODIFF, for cache validity. + BUF_MODIFF is bumped by every text-property change, including + font-lock face applications on every redisplay. AX text contains @@ -331,39 +327,23 @@ index 7fa28222b6..6e0575677e 100644 + BUF_CHARS_MODIFF is bumped only on actual character insertions + and deletions, matching the semantic of "did the text change". + This is the pattern used by WebKit and NSTextView. - Do NOT track BUF_OVERLAY_MODIFF here --- overlay text is not - included in the cached AX text (it is handled separately via -- explicit announcements). Including overlay_modiff would -- silently update cachedOverlayModiff and prevent the -- notification dispatch from detecting overlay changes. */ -- if (cachedText && cachedTextModiff == modiff -+ explicit announcements in postAccessibilityNotificationsForFrame). -+ Including overlay_modiff would silently update cachedOverlayModiff -+ and prevent the notification dispatch from detecting changes. */ -+ ptrdiff_t chars_modiff = BUF_CHARS_MODIFF (b); -+ ptrdiff_t pt = BUF_PT (b); -+ NSUInteger textLen = cachedText ? [cachedText length] : 0; -+ /* Cache is valid when neither characters nor fold-state have changed. -+ BUF_CHARS_MODIFF guards against character edits and is not bumped -+ by font-lock (text-property changes), preserving the O(1) hot path. + Do NOT add BUF_OVERLAY_MODIFF here: modes like hl-line-mode move + overlays on every post-command-hook, bumping BUF_OVERLAY_MODIFF and + causing O(buffer-size) text rebuilds per keystroke. Fold/unfold + changes visible characters and thereby bumps BUF_CHARS_MODIFF. */ -+ if (cachedText && cachedTextModiff == chars_modiff + ptrdiff_t chars_modiff = BUF_CHARS_MODIFF (b); + ptrdiff_t pt = BUF_PT (b); + NSUInteger textLen = cachedText ? [cachedText length] : 0; +- /* Cache validity: track BUF_MODIFF and buffer narrowing. +- Do NOT track BUF_OVERLAY_MODIFF here --- overlay text is not +- included in the cached AX text (it is handled separately via +- explicit announcements). Including overlay_modiff would +- silently update cachedOverlayModiff and prevent the +- notification dispatch from detecting overlay changes. */ + if (cachedText && cachedTextModiff == chars_modiff && cachedTextStart == BUF_BEGV (b) && pt >= cachedTextStart - && (textLen == 0 -@@ -8174,7 +8297,7 @@ included in the cached AX text (it is handled separately via - { - [cachedText release]; - cachedText = [text retain]; -- cachedTextModiff = modiff; -+ cachedTextModiff = chars_modiff; - cachedTextStart = start; - - if (visibleRuns) -@@ -8587,6 +8710,11 @@ - (void)setAccessibilitySelectedTextRange:(NSRange)range +@@ -8587,6 +8702,11 @@ - (void)setAccessibilitySelectedTextRange:(NSRange)range [self ensureTextCache]; @@ -375,7 +355,7 @@ index 7fa28222b6..6e0575677e 100644 specpdl_ref count = SPECPDL_INDEX (); record_unwind_current_buffer (); /* Ensure block_input is always matched by unblock_input even if -@@ -9042,15 +9170,23 @@ - (void)postFocusedCursorNotification:(ptrdiff_t)point +@@ -9042,15 +9162,23 @@ - (void)postFocusedCursorNotification:(ptrdiff_t)point = @(ns_ax_text_state_change_selection_move); moveInfo[@"AXTextSelectionDirection"] = @(direction); moveInfo[@"AXTextChangeElement"] = self; @@ -405,7 +385,7 @@ index 7fa28222b6..6e0575677e 100644 NSAccessibilitySelectedTextChangedNotification, moveInfo); -@@ -9148,12 +9284,17 @@ user expectation ("w" jumps to next word and reads it). */ +@@ -9148,12 +9276,17 @@ user expectation ("w" jumps to next word and reads it). */ } } @@ -428,7 +408,7 @@ index 7fa28222b6..6e0575677e 100644 if (cachedText && granularity == ns_ax_text_selection_granularity_line) { -@@ -9218,6 +9359,11 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b +@@ -9218,6 +9351,11 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b block_input (); specpdl_ref count2 = SPECPDL_INDEX (); @@ -440,7 +420,7 @@ index 7fa28222b6..6e0575677e 100644 record_unwind_protect_void (unblock_input); record_unwind_current_buffer (); if (b != current_buffer) -@@ -9394,12 +9540,29 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f +@@ -9394,12 +9532,29 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f if (!b) return; @@ -470,7 +450,7 @@ index 7fa28222b6..6e0575677e 100644 if (modiff != self.cachedModiff) { self.cachedModiff = modiff; -@@ -9413,6 +9576,7 @@ Text property changes (e.g. face updates from +@@ -9413,6 +9568,7 @@ Text property changes (e.g. face updates from { self.cachedCharsModiff = chars_modiff; [self postTextChangedNotification:point]; @@ -478,7 +458,7 @@ index 7fa28222b6..6e0575677e 100644 } } -@@ -9435,8 +9599,15 @@ frameworks like Vertico bump BOTH BUF_MODIFF (via text property +@@ -9435,8 +9591,15 @@ frameworks like Vertico bump BOTH BUF_MODIFF (via text property displayed in the minibuffer. In normal editing buffers, font-lock and other modes change BUF_OVERLAY_MODIFF on every redisplay, triggering O(overlays) work per keystroke. @@ -496,7 +476,7 @@ index 7fa28222b6..6e0575677e 100644 goto skip_overlay_scan; int selected_line = -1; -@@ -9482,7 +9653,18 @@ frameworks like Vertico bump BOTH BUF_MODIFF (via text property +@@ -9482,7 +9645,18 @@ frameworks like Vertico bump BOTH BUF_MODIFF (via text property self.cachedPoint = point; self.cachedMarkActive = markActive; @@ -516,7 +496,7 @@ index 7fa28222b6..6e0575677e 100644 NSInteger direction = ns_ax_text_selection_direction_discontiguous; if (point > oldPoint) direction = ns_ax_text_selection_direction_next; -@@ -9530,6 +9712,58 @@ frameworks like Vertico bump BOTH BUF_MODIFF (via text property +@@ -9530,6 +9704,58 @@ frameworks like Vertico bump BOTH BUF_MODIFF (via text property granularity = ns_ax_text_selection_granularity_line; } @@ -575,7 +555,7 @@ index 7fa28222b6..6e0575677e 100644 /* Post notifications for focused and non-focused elements. */ if ([self isAccessibilityFocused]) [self postFocusedCursorNotification:point -@@ -9672,6 +9906,13 @@ - (NSRect)accessibilityFrame +@@ -9672,6 +9898,13 @@ - (NSRect)accessibilityFrame if (vis_start >= vis_end) return @[]; @@ -589,7 +569,7 @@ index 7fa28222b6..6e0575677e 100644 block_input (); specpdl_ref blk_count = SPECPDL_INDEX (); record_unwind_protect_void (unblock_input); -@@ -9796,6 +10037,7 @@ than O(chars). Fall back to pos+1 as safety net. */ +@@ -9796,6 +10029,7 @@ than O(chars). Fall back to pos+1 as safety net. */ pos = span_end; } @@ -597,7 +577,7 @@ index 7fa28222b6..6e0575677e 100644 return [[spans copy] autorelease]; } -@@ -9977,6 +10219,10 @@ - (void)dealloc +@@ -9977,6 +10211,10 @@ - (void)dealloc #endif [accessibilityElements release]; @@ -608,7 +588,7 @@ index 7fa28222b6..6e0575677e 100644 [[self menu] release]; [super dealloc]; } -@@ -11426,6 +11672,10 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f +@@ -11426,6 +11664,10 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f windowClosing = NO; processingCompose = NO; @@ -619,7 +599,7 @@ index 7fa28222b6..6e0575677e 100644 scrollbarsNeedingUpdate = 0; fs_state = FULLSCREEN_NONE; fs_before_fs = next_maximized = -1; -@@ -12734,6 +12984,154 @@ - (id)accessibilityFocusedUIElement +@@ -12734,6 +12976,154 @@ - (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. */ @@ -774,7 +754,7 @@ index 7fa28222b6..6e0575677e 100644 - (void)postAccessibilityUpdates { NSTRACE ("[EmacsView postAccessibilityUpdates]"); -@@ -12744,11 +13142,64 @@ - (void)postAccessibilityUpdates +@@ -12744,11 +13134,64 @@ - (void)postAccessibilityUpdates /* Re-entrance guard: VoiceOver callbacks during notification posting can trigger redisplay, which calls ns_update_end, which calls us