diff --git a/patches/0001-ns-implement-AXBoundsForRange-for-macOS-Zoom-cursor-.patch b/patches/0001-ns-implement-AXBoundsForRange-for-macOS-Zoom-cursor-.patch index 8cb7216..63fbadf 100644 --- a/patches/0001-ns-implement-AXBoundsForRange-for-macOS-Zoom-cursor-.patch +++ b/patches/0001-ns-implement-AXBoundsForRange-for-macOS-Zoom-cursor-.patch @@ -159,7 +159,7 @@ index 932d209..da40369 100644 ns_focus (f, NULL, 0); NSGraphicsContext *ctx = [NSGraphicsContext currentContext]; -@@ -6849,214 +6885,1777 @@ ns_create_font_panel_buttons (id target, SEL select, SEL cancel_action) +@@ -6849,214 +6885,1801 @@ ns_create_font_panel_buttons (id target, SEL select, SEL cancel_action) /* ========================================================================== @@ -196,6 +196,11 @@ index 932d209..da40369 100644 + return @""; + } + ++ if (!BUFFERP (w->contents)) ++ { ++ *out_start = 0; ++ return @""; ++ } + struct buffer *b = XBUFFER (w->contents); + if (!b) + { @@ -629,7 +634,7 @@ index 932d209..da40369 100644 - NSView *buttons; - BOOL canceled; -#endif -+ if (!SYMBOLP (real_this_command)) ++ if (!SYMBOLP (Vreal_this_command)) + return false; -#ifdef NS_IMPL_GNUSTEP @@ -639,7 +644,7 @@ index 932d209..da40369 100644 -#endif + Lisp_Object next = intern ("next-line"); + Lisp_Object prev = intern ("previous-line"); -+ return EQ (real_this_command, next) || EQ (real_this_command, prev); ++ return EQ (Vreal_this_command, next) || EQ (Vreal_this_command, prev); +} -#ifdef NS_IMPL_COCOA @@ -833,6 +838,8 @@ index 932d209..da40369 100644 + if (!w || !WINDOW_LEAF_P (w)) + return; + ++ if (!BUFFERP (w->contents)) ++ return; + struct buffer *b = XBUFFER (w->contents); + if (!b) + return; @@ -1004,6 +1011,8 @@ index 932d209..da40369 100644 + if (!w || !WINDOW_LEAF_P (w)) + return @""; + ++ if (!BUFFERP (w->contents)) ++ return @""; + struct buffer *b = XBUFFER (w->contents); + if (!b || NILP (BVAR (b, mark_active))) + return @""; @@ -1022,6 +1031,8 @@ index 932d209..da40369 100644 + if (!w || !WINDOW_LEAF_P (w)) + return NSMakeRange (0, 0); + ++ if (!BUFFERP (w->contents)) ++ return 0; + struct buffer *b = XBUFFER (w->contents); + if (!b) + return NSMakeRange (0, 0); @@ -1046,54 +1057,63 @@ index 932d209..da40369 100644 + if (!w || !WINDOW_LEAF_P (w)) + return; + -+ struct buffer *b = XBUFFER (w->contents); -+ if (!b) ++ if (!BUFFERP (w->contents)) + return; + -+ [self ensureTextCache]; ++ dispatch_async (dispatch_get_main_queue (), ^{ ++ struct window *w2 = self.emacsWindow; ++ if (!w2 || !WINDOW_LEAF_P (w2)) ++ return; + -+ /* Convert accessibility index to buffer charpos via mapping. */ -+ ptrdiff_t charpos = [self charposForAccessibilityIndex:range.location]; ++ if (!BUFFERP (w2->contents)) ++ return; ++ struct buffer *b = XBUFFER (w2->contents); + -+ /* Clamp to buffer bounds. */ -+ if (charpos < BUF_BEGV (b)) -+ charpos = BUF_BEGV (b); -+ if (charpos > BUF_ZV (b)) -+ charpos = BUF_ZV (b); ++ [self ensureTextCache]; + -+ block_input (); ++ /* Convert accessibility index to buffer charpos via mapping. */ ++ ptrdiff_t charpos = [self charposForAccessibilityIndex:range.location]; + -+ /* Move point directly in the buffer. Use set_point_both which -+ operates on the current buffer — temporarily switch if needed. */ -+ struct buffer *oldb = current_buffer; -+ if (b != current_buffer) -+ set_buffer_internal_1 (b); ++ /* Clamp to buffer bounds. */ ++ if (charpos < BUF_BEGV (b)) ++ charpos = BUF_BEGV (b); ++ if (charpos > BUF_ZV (b)) ++ charpos = BUF_ZV (b); + -+ SET_PT_BOTH (charpos, CHAR_TO_BYTE (charpos)); ++ block_input (); + -+ /* Keep mark state aligned with requested selection range. */ -+ if (range.length > 0) -+ { -+ ptrdiff_t mark_charpos = [self charposForAccessibilityIndex: -+ range.location + range.length]; -+ if (mark_charpos > BUF_ZV (b)) -+ mark_charpos = BUF_ZV (b); -+ Fset_marker (BVAR (b, mark), make_fixnum (mark_charpos), -+ Fcurrent_buffer ()); -+ bset_mark_active (b, Qt); -+ } -+ else -+ bset_mark_active (b, Qnil); ++ /* Move point directly in the buffer. Use set_point_both which ++ operates on the current buffer — temporarily switch if needed. */ ++ struct buffer *oldb = current_buffer; ++ if (b != current_buffer) ++ set_buffer_internal_1 (b); + -+ if (b != oldb) -+ set_buffer_internal_1 (oldb); ++ SET_PT_BOTH (charpos, CHAR_TO_BYTE (charpos)); + -+ unblock_input (); ++ /* Keep mark state aligned with requested selection range. */ ++ if (range.length > 0) ++ { ++ ptrdiff_t mark_charpos = [self charposForAccessibilityIndex: ++ range.location + range.length]; ++ if (mark_charpos > BUF_ZV (b)) ++ mark_charpos = BUF_ZV (b); ++ Fset_marker (BVAR (b, mark), make_fixnum (mark_charpos), ++ Fcurrent_buffer ()); ++ bset_mark_active (b, Qt); ++ } ++ else ++ bset_mark_active (b, Qnil); + -+ /* Update cached state so the next notification cycle doesn't -+ re-announce this movement. */ -+ self.cachedPoint = charpos; -+ self.cachedMarkActive = (range.length > 0); ++ if (b != oldb) ++ set_buffer_internal_1 (oldb); ++ ++ unblock_input (); ++ ++ /* Update cached state so the next notification cycle doesn't ++ re-announce this movement. */ ++ self.cachedPoint = charpos; ++ self.cachedMarkActive = (range.length > 0); ++ }); +} + +- (void)setAccessibilityFocused:(BOOL)flag @@ -1133,6 +1153,8 @@ index 932d209..da40369 100644 + if (!w || !WINDOW_LEAF_P (w)) + return 0; + ++ if (!BUFFERP (w->contents)) ++ return 0; + struct buffer *b = XBUFFER (w->contents); + if (!b) + return 0; @@ -1367,6 +1389,8 @@ index 932d209..da40369 100644 + if (!w || !WINDOW_LEAF_P (w)) + return; + ++ if (!BUFFERP (w->contents)) ++ return; + struct buffer *b = XBUFFER (w->contents); + if (!b) + return; @@ -2076,7 +2100,7 @@ index 932d209..da40369 100644 - (void)keyDown: (NSEvent *)theEvent { -@@ -8237,6 +9836,28 @@ ns_in_echo_area (void) +@@ -8237,6 +9860,28 @@ ns_in_echo_area (void) XSETFRAME (event.frame_or_window, emacsframe); kbd_buffer_store_event (&event); ns_send_appdefined (-1); // Kick main loop @@ -2105,7 +2129,7 @@ index 932d209..da40369 100644 } -@@ -9474,6 +11095,298 @@ ns_in_echo_area (void) +@@ -9474,6 +11119,298 @@ ns_in_echo_area (void) return fs_state; } @@ -2404,7 +2428,7 @@ index 932d209..da40369 100644 @end /* EmacsView */ -@@ -9941,6 +11854,14 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c) +@@ -9941,6 +11878,14 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c) return [super accessibilityAttributeValue:attribute]; }