patches: fix all compile errors and review issues

- ZV_S -> BUF_ZV (undefined macro)
- cf->current_buffer -> XWINDOW(cf->selected_window)->contents
  (current_buffer is a thread macro, can't use as field name)
- find_newline: add record_unwind_current_buffer + set_buffer_internal_1
- ns_zoom_track_completion: add specpdl unwind protection
- ns_zoom_face_is_selected: replace with forward decl of ns_ax_face_is_selected
  (eliminates duplicate)
- childFrameLastBuffer: struct buffer * -> Lisp_Object (safe vs kill-buffer)
- EmacsView dealloc: xfree childFrameLastCandidate (memory leak)
- postCompletionAnnouncementForBuffer: add block_input/unblock_input
This commit is contained in:
2026-03-01 03:58:04 +01:00
parent b283068f82
commit 84eb777065
9 changed files with 134 additions and 132 deletions

View File

@@ -1,4 +1,4 @@
From 62e619d508d4ce3b3bf0f8dd959041bcd9a75350 Mon Sep 17 00:00:00 2001
From ca488b10323f136b3ce2593b56e72e222bdae7d6 Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 16:01:29 +0100
Subject: [PATCH 9/9] ns: announce child frame completion candidates for
@@ -43,8 +43,8 @@ refocus parent buffer element when child frame closes.
doc/emacs/macos.texi | 6 --
etc/NEWS | 4 +-
src/nsterm.h | 5 +
src/nsterm.m | 227 ++++++++++++++++++++++++++++++++++++++++++-
4 files changed, 233 insertions(+), 9 deletions(-)
src/nsterm.m | 236 ++++++++++++++++++++++++++++++++++++++++++-
4 files changed, 242 insertions(+), 9 deletions(-)
diff --git a/doc/emacs/macos.texi b/doc/emacs/macos.texi
index 4825cf9..97777e2 100644
@@ -86,7 +86,7 @@ index 2b1f9e6..8a40850 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 2102fb9..2fc4de4 100644
index 2102fb9..dd98d56 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -594,6 +594,10 @@ typedef NS_ENUM (NSInteger, EmacsAXSpanType)
@@ -95,7 +95,7 @@ index 2102fb9..2fc4de4 100644
BOOL accessibilityUpdating;
+ BOOL childFrameCompletionActive;
+ char *childFrameLastCandidate;
+ struct buffer *childFrameLastBuffer;
+ Lisp_Object childFrameLastBuffer;
+ EMACS_INT childFrameLastModiff;
#endif
BOOL font_panel_active;
@@ -109,10 +109,10 @@ index 2102fb9..2fc4de4 100644
@end
diff --git a/src/nsterm.m b/src/nsterm.m
index b9b2a80..dc49417 100644
index b3bdd42..9f37c4e 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7296,6 +7296,112 @@ visual line index for Zoom (skip whitespace-only lines
@@ -7291,6 +7291,112 @@ visual line index for Zoom (skip whitespace-only lines
return nil;
}
@@ -225,7 +225,34 @@ index b9b2a80..dc49417 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
@@ -12535,6 +12641,77 @@ - (id)accessibilityFocusedUIElement
@@ -9028,6 +9134,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
ptrdiff_t currentOverlayStart = 0;
ptrdiff_t currentOverlayEnd = 0;
+ block_input ();
specpdl_ref count2 = SPECPDL_INDEX ();
record_unwind_current_buffer ();
if (b != current_buffer)
@@ -9186,6 +9293,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
self.cachedCompletionOverlayEnd = 0;
self.cachedCompletionPoint = 0;
}
+ unblock_input ();
}
/* ---- Notification dispatch (main entry point) ---- */
@@ -9773,6 +9881,10 @@ - (void)dealloc
#endif
[accessibilityElements release];
+#ifdef NS_IMPL_COCOA
+ if (childFrameLastCandidate)
+ xfree (childFrameLastCandidate);
+#endif
[[self menu] release];
[super dealloc];
}
@@ -12533,6 +12645,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. */
@@ -251,9 +278,12 @@ index b9b2a80..dc49417 100644
+ also guards against re-entrance: if Lisp calls below
+ trigger redisplay, the modiff check short-circuits. */
+ EMACS_INT modiff = BUF_MODIFF (b);
+ if (b == childFrameLastBuffer && modiff == childFrameLastModiff)
+ if (!BUFFER_LIVE_P (b))
+ return;
+ childFrameLastBuffer = b;
+ if (EQ (childFrameLastBuffer, make_lisp_ptr (b, Lisp_Vectorlike))
+ && modiff == childFrameLastModiff)
+ return;
+ childFrameLastBuffer = make_lisp_ptr (b, Lisp_Vectorlike);
+ childFrameLastModiff = modiff;
+
+ /* Skip buffers larger than a typical completion popup.
@@ -303,7 +333,7 @@ index b9b2a80..dc49417 100644
- (void)postAccessibilityUpdates
{
NSTRACE ("[EmacsView postAccessibilityUpdates]");
@@ -12545,11 +12722,59 @@ - (void)postAccessibilityUpdates
@@ -12543,11 +12729,59 @@ - (void)postAccessibilityUpdates
/* Re-entrance guard: VoiceOver callbacks during notification posting
can trigger redisplay, which calls ns_update_end, which calls us