Commit graph

51106 commits

Author SHA1 Message Date
Juri Linkov
c94d58ddbf Fix the tab close button appearance when clicking (bug#76394)
* src/xdisp.c (handle_tab_bar_click): Use the variable 'close_p'
to show mouse face as sunken/raised only when clicked
on the close button.  Clicking elsewhere on the tab should not
change the close button's appearance using DRAW_MOUSE_FACE.
2026-06-09 18:49:32 +03:00
Pip Cet
3106dc7766 Assert we don't double-free timers (bug#81108)
* src/atimer.c (cancel_atimer): Assert that we found the timer.
2026-06-06 10:22:43 +00:00
Pip Cet
90314895dd Don't cancel random timers in x_get_foreign_selection (bug#81108)
* src/pgtkselect.c (pgtk_display_selection_waiting_message):
(pgtk_cancel_atimer):
(pgtk_get_foreign_selection):
* src/xselect.c (x_display_selection_waiting_message):
(x_cancel_atimer):
(x_get_foreign_selection): Use a pointer to a timer variable, which is
cleared when the timer runs or is otherwise cancelled.  Don't cancel
the timer twice.
2026-06-06 10:22:29 +00:00
Pip Cet
5cd7785b0a Fix use-after-free in Ffuncall_with_delayed_message (bug#81108)
* src/eval.c (with_delayed_message_display):
(with_delayed_message_cancel):
(Ffuncall_with_delayed_message): Use new temporary data
structure.  Cancel timer at most once.
2026-06-06 10:22:20 +00:00
Andrea Alberti
3801c09ae2 Don't resurrect invisible child frames when rebuilding parent links
On the NS port, -[EmacsWindow setParentChildRelationships] reattaches
every child frame to its parent via -addChildWindow:ordered:, which also
orders the child window onto the screen.  This runs whenever the
parent/child relationships are rebuilt, e.g., when entering non-native
fullscreen, which allocates a fresh EmacsWindow whose initializer
rebuilds the relationships.  A child frame that Emacs had made invisible
(e.g. a corfu/company completion popup) was thereby brought back as a
stale, non-responsive child frame.  Emacs never repaints to clear it
because frame_redisplay_p trusts FRAME_VISIBLE_P on the NS port and
avoids dealing with the child frame when it is marked as invisible.

Native fullscreen does not trigger this: -toggleFullScreen: hands off to
AppKit without allocating a new window, so the rebuild never runs.

A hidden child frame is normally detached from its parent already: Emacs
hides it with -orderOut: (ns_make_frame_invisible), which per Apple's
documentation removes a child window from its parent before ordering it
out.  The fix is therefore not to re-attach a child while it is
invisible; ns_make_frame_visible already reinstates the parent/child link
when the frame is shown again.

* src/nsterm.m ([EmacsWindow setParentChildRelationships]): Only
re-attach a child window when the frame is marked visible.
(ns_make_frame_visible): Explain, with a reference to Apple's
documentation, why the parent/child link must be reinstated on show.
2026-06-05 19:22:29 +01:00
Dirk-Jan C. Binnema
6df1d33b6c Fmake_xwidget: Use about:blank workaround only when needed
* src/process.c (glib_installs_sigchld_handler): New variable.
(init_process_emacs): Set it when GLib overrides Emacs's SIGCHLD
handler.
* src/process.h (glib_installs_sigchld_handler): Declare.
* src/xwidget.c (Fmake_xwidget): Skip the "about:blank"
workaround when glib_installs_sigchld_handler is false.
2026-06-04 15:35:18 +01:00
Dmitry Gutov
07e02917ee [GTK3] Re-fix the stored values for width and height
* src/gtkutil.c (xg_frame_set_char_size)
(xg_frame_set_size_and_position): Round WIDTH and HEIGHT to
multiples of SCALE without adding toolbar/menubar (bug#80662).
2026-06-03 16:24:48 +03:00
Eli Zaretskii
f357a549ac Prevent segfaults due to frame resizing at the wrong time
* src/dispextern.h:
* src/xdisp.c (dont_resize_frames): New variable.
(unwind_format_mode_line): Decrement 'dont_resize_frames'.
(gui_consider_frame_title, display_mode_line, Fformat_mode_line):
Increment 'dont_resize_frames'.
* src/dispnew.c (do_pending_window_change): Don't resize frames if
'dont_resize_frames' is non-zero.  (Bug#81121)

(cherry picked from commit 94eb6389d4)
2026-06-01 15:05:52 +03:00
Po Lu
d8933b9f07 Fix the MSDOS build
* msdos/sedlibmk.inp (GL_GNULIB_MEMEQ, GL_GNULIB_STREQ)
(GL_GNULIB_STRNUL): New substitutions, replacing that of
GL_GNULIB_STRINGEQ.

* src/term.c (init_tty) [MSDOS]: Assign appropriate value to
tty->TN_max_colors.

Do not merge to master.
2026-05-28 13:07:32 +08:00
João Távora
7892ae5eaf Fix pathological slowness in flex completion
The 'completion-regexp-list' optimization in
completion--flex-all-completions-1, a cheap pre-filter via a trivial
regexp, performs very poorly for longer patterns and strings, so drop
it.  That alone recovers fairly decent performance for the flex
completion when compared to the 'hotfuzz' point of reference.

We then recover the cheap rejection with an O(N+M) pre-check in the
Fcompletion__flex_cost_gotoh C scorer.  This kicks in the common case
(completion-ignore-case is nil) and pays off especially when the table
is already a list and 'all-completions' needn't cons.

See:
  https://lists.gnu.org/archive/html/emacs-devel/2026-04/msg01081.html
  https://lists.gnu.org/archive/html/emacs-devel/2026-05/msg00519.html

* lisp/minibuffer.el (completion--flex-all-completions-1): Remove
regexp pre-filter.

* src/minibuf.c (Fcompletion__flex_cost_gotoh): Add subsequence
pre-check.
2026-05-24 04:23:51 +01:00
Martin Rudalics
d6f7b2d99b Save/restore old_buffer slot via window configurations (Bug#81097)
With Emacs 31 the old_buffer slot of a window gets overwritten
with the buffer unshown in that window when that window is
deleted.  Fset_window_configuration triggers that when calling
delete_all_child_windows.  If a window configuration gets saved
and restored in one and the same redisplay cycle, the change
time stamps of the window and its frame will be equal and
'window-buffer-change-functions' may wrongly decide that the
window's buffer has not changed because its buffer and
old_buffer slots refer to the same buffer (Bug#81097).  Fix that
by saving and restoring the old_buffer slot.

* src/window.c (struct saved_window): Add 'old_buffer' slot.
(Fset_window_configuration): Restore old_buffer slot.
(save_window_save): Save old_buffer slot.
2026-05-22 19:33:57 +02:00
Dmitry Gutov
2936b36164 Fix "assertion 'GTK_IS_WINDOW (window)' failed"
* src/gtkutil.c (xg_frame_set_size_and_position): Remove a
gtk_window_resize call which used a wrong value type
(GdkX11Window instead of GtkWindow).  The original motivation
for that line seems to be fixed by later changes (bug#80662).
2026-05-22 06:46:47 +03:00
Dmitry Gutov
98348a0bdc [Xt] Fix child frame resizing glitch
* src/widget.c (EmacsFrameResize): Exit early for child frames
(bug#81077).
2026-05-22 01:50:03 +03:00
Eli Zaretskii
1832a93547 ; * src/fns.c (Fequal): Doc fix. 2026-05-17 10:37:01 +03:00
Eli Zaretskii
d3c72b8389 ; * src/xdisp.c (display_line): Fix commentary (bug#80693). 2026-05-16 11:54:43 +03:00
Andrea Alberti
a981517b72 Fill margins with 'margin' face on truncated screen lines
* src/xdisp.c (display_line): Remove the unnecessary condition that
row->used of the margin areas is zero, for when we call
'extend_face_to_end_of_line'.  (Bug#80693)
2026-05-16 11:48:34 +03:00
Eli Zaretskii
f4c326c378 ; * src/sfnt.c (sfnt_read_cmap_format_12): Assert there's no overflow. 2026-05-15 15:00:35 +03:00
Dmitry Gutov
196fd80689 [GTK3, HiDPI] Fix width/height round-trip through ConfigureNotify
* src/gtkutil.c (xg_frame_set_char_size)
(xg_frame_set_size_and_position): Truncate WIDTH and HEIGHT to
be multiples of the scale factor (bug#80662).
2026-05-11 03:32:29 +03:00
Dmitry Gutov
acc07f1a03 [GTK3] On Expose, repaint the border before the content
* src/xterm.c (handle_one_xevent): Move the
x_clear_under_internal_border call before expose_frame, for less
chance of implicit flush to screen in between (bug#80662).
2026-05-11 02:03:30 +03:00
Eli Zaretskii
6a605c65a8 Fix vertical-motion across overlay strings with embedded newlines
* src/indent.c (Fvertical_motion): Handle the case of an overlay
string on invisible text at point.  (Bug#80989)
2026-05-09 14:59:54 +03:00
Eli Zaretskii
5579893ed7 ; Don't block/unblock input in text_extents methods
* src/xftfont.c (xftfont_text_extents):
* src/ftcrfont.c (ftcrfont_text_extents): Don't block/unblock
input.  (Bug#80863)
2026-05-09 12:22:02 +03:00
Eli Zaretskii
6ba05106f4 Fix display images in the display margins
* src/xdisp.c (handle_single_display_spec): Set the iterator face
to use 'margin' when displaying in the margins.  (Bug#80693)
2026-05-09 08:58:59 +03:00
Alan Third
543d8a7a9d [NS] Fix deprecated variable (bug#80985)
* src/nsterm.h (NSLevelIndicatorStyleContinuousCapacity): Define in
macOS < 10.15.
2026-05-08 14:07:56 +01:00
Zeke Dou
2f73996647 Move ns_init_colors() after init_callproc() (bug#80752)
'data-directory' needs to be established in advance of 'ns_init_colors'
to ensure the file "etc/rgb.txt" is read.  This was encountered on an
out-of-tree Nix build.

* src/emacs.c (main): Move the 'ns_init_colors' after 'init_callproc'.

Copyright-paperwork-exempt: yes
2026-05-07 17:32:02 +01:00
Eli Zaretskii
4beb8e8963 Fix infloop in redisplay due to continuation glyphs
* src/xdisp.c (display_line): When inserting continuation glyphs,
account for the border glyph in non-rightmost windows on TTY
frames.  (Bug#80975)
2026-05-07 17:45:19 +03:00
Dmitry Gutov
f20e3e473d [GTK3] Move the frame to position before showing
* src/xterm.c (x_make_frame_visible): Move XMoveWindow call before
gtk_widget_show_all, so that the move happens before the frame
become visible (bug#80662).
2026-05-07 06:27:27 +03:00
Dmitry Gutov
6c3dc7aafd [GTK3] Improve the resize -> hide -> show scenario
* src/gtkutil.c (xg_frame_set_char_size)
(xg_frame_set_size_and_position): Call gtk_window_resize for
child frames too, to record _GtkWindowGeometryInfo#resize_width
and resize_height.  They are later looked up by
gtk_widget_show_all in x_make_frame_visible (bug#80662).
Without this the widgets go back and forth between the
remembered and actual sizes after make-visible.
2026-05-07 06:27:27 +03:00
Stéphane Marks
581db34a77 ; Fix crash in macOS Accessibility Zoom timer (bug#80624)
* src/nsterm.m (cancel_ns_deferred_UAZoomChangeFocus_timer): New function.
([EmacsView windowWillClose:]): New method. Cancel the timer if the window
closes before it runs.
([EmacsView deferredhandler:]): Guard against emacsframe being deleted before
the timer runs.
2026-05-06 23:17:09 +01:00
Dmitry Gutov
14f17722aa Fix flicker of child frame right after make-frame-visible
* src/xterm.c (x_make_frame_visible): Call SET_FRAME_GARBAGED
before making a child frame visible (bug#80943).
2026-05-06 04:31:50 +03:00
Eli Zaretskii
d48b774524 ; Fix last change
* src/xdisp.c (extend_face_to_end_of_line): Fix last argument to
'append_stretch_glyph', to avoid assertion violations.  (Bug#80693)
2026-05-05 11:22:56 +03:00
Andrea Alberti
d24b10ca75 Introduce 'margin' face for window margin background
A new basic face 'margin' is used for text displayed in the left and
right margin areas, i.e., the areas typically used by VCS and LSP
packages for per-line annotations.  Its background defaults to the
frame default, preserving existing behavior for users who do not
customize it.
* etc/NEWS: Document the new 'margin' face.
* lisp/faces.el (margin): Add 'margin' face, inheriting from 'default'.
* src/dispextern.h (face_id): Add MARGIN_FACE_ID.
* src/xdisp.c (face_at_pos): Use 'margin' as the base face for
strings displayed in margin areas so that they inherit the gutter
background by default.
(extend_face_to_end_of_line): Compute 'margin_fill_face_id' from the
'margin' face.  Use while loops to explicitly fill all empty character
slots in both left and right margins for both GUI and TTY branches.
(display_line): Call 'extend_face_to_end_of_line' for beyond-EOB rows
when the window has margins.  Also extend the existing condition for
text rows with empty margins to trigger when the 'margin' face
background differs from the frame default, not only when the default
face is remapped.
* src/xfaces.c (realize_basic_faces): Realize 'margin' as a basic
face to support face-remapping and efficient lookup.
(Bug#80693)
2026-05-05 11:21:57 +03:00
Stefan Monnier
a952324e9b keyboard.c: Allow SIGINT to quit in batch mode, instead of exit
In terminal sessions, SIGINT is turned into a `quit` ELisp signal,
but in batch it has traditionally killed Emacs.  It can be very
useful to cause a `quit` from outside the process when running
in batch (e.g. for "batch" sessions that provide a REPL via stdin/out),
so add a new var 'kill-emacs-on-sigint' to control that behavior.
(bug#80942)

* src/keyboard.c (handle_interrupt_signal): Obey `kill_emacs_on_sigint`.
(init_keyboard): Use `deliver_interrupt_signal` for SIGINT also for
batch sessions.
(syms_of_keyboard): New variable `kill_emacs_on_sigint`.

* test/src/keyboard-tests.el (keyboard-sigint-to-quit): New test.

* doc/emacs/cmdargs.texi (Initial Options): Mention the effect of
`kill-emacs-on-sigint` in batch mode.
2026-05-04 12:49:35 -04:00
Dmitry Gutov
9ff0768804 Re-add a call to clear_under_internal_border in clear_garbaged_frames
* src/xdisp.c (clear_garbaged_frames): Re-add the call to
clear_under_internal_border, reverting that part of commit
a6a3b32208 as not essential to the fix (bug#80662).
2026-05-04 05:22:03 +03:00
Eli Zaretskii
d51a472231 ; * src/sfnt.c (sfnt_read_name_table): Avoid 32-bit overflow. 2026-05-02 14:17:14 +03:00
Eli Zaretskii
0d0891c1bb ; Fix an issue with counting glyphs on TTY frames
* src/dispnew.c (fake_current_matrices): Fix the 'used' count of
glyphs for the right margin and the text-area.  (Bug#80900)
2026-05-02 13:26:46 +03:00
Eli Zaretskii
1b14d6f92b * src/.gdbinit: Ignore SIGPIPE. (Bug#80911) 2026-05-02 10:03:53 +03:00
Dmitry Gutov
6cd5b16dd0 Resize child frames with GTK3 immediately too
* src/gtkutil.c (xg_frame_set_char_size): Resize child frame and
its GTK widget hierarchy immediately.  Update the "desired" Cairo
surface dimensions.  Skip waiting for events. (bug#80662)
Remove the unnecessary call to clear_under_internal_border.
2026-05-01 04:57:49 +03:00
Dmitry Gutov
73fe7a7097 Simplify the fullscreen adjustment in xg_frame_set_char_size
* src/gtkutil.c (xg_frame_set_char_size): Simplify.  Use the
fullscreen value check to alter the values of outer_width and
outer_height rather than have several larger branches (bug#80662).
2026-05-01 04:57:49 +03:00
Dmitry Gutov
049a94b4e5 Remove the effect of x_gtk_resize_child_frames=hide
* src/gtkutil.c (xg_frame_set_char_size): Remove the effect of
x_gtk_resize_child_frames, effectively reverting that part of
c49d379f17 (bug#80662).

* src/pgtkfns.c (syms_of_pgtkfns): Remove defsyms Qhide and
Qresize_mode, never used with PGTK.

* src/xfns.c (x-gtk-resize-child-frames): Update docstring.
2026-05-01 04:57:49 +03:00
Dmitry Gutov
83b19f4d0f Don't wait out the whole event timeout unnecessarily
* src/xterm.c (x_wait_for_event): If f->wait_event_type has been
cleared (in handle_one_xevent), don't go into pselect wait.

* src/androidterm.c (android_wait_for_event): Likewise.
2026-05-01 04:57:49 +03:00
Dmitry Gutov
a6a3b32208 Try to resize or resize-and-move child frames in one update
This pertains to X11 toolkit builds.  Other ports (including
PGTK) seem to have mostly atomic window updates already.

* src/xterm.c (x_set_window_size_1): Resize the Xt widget eagerly,
so the next redraw is not clipped.  Update the "desired" Cairo
surface dimensions.  Skip waiting for next XEvent.  Do all that
for child frames only.  Update old comments (bug#80662).
(x_set_window_size_and_position_1): Same.  Also clear the widget's
cached position coordinates (we don't keep them up to date).
(x_set_window_size, x_set_window_size_and_position): Skip
redrawing the border on child frames, it will happen during
redisplay anyway.

* src/gtkutil.c (xg_frame_set_size_and_position): On child
frames, resize the GTK widget hierarchy immediately.  Update the
"desired" Cairo surface dimensions.  Skip waiting for events.

* src/widget.c (EmacsFrameResize):
When resize should be a no-op, exit early (minor optimization).
(EmacsFrameExpose): Redraw the border on the last Expose event.

* src/xdisp.c (clear_garbaged_frames): Don't redraw borders here.

* src/xfns.c (x_window): Undo the previous change in bit_gravity
in the no-toolkit build.  StaticGravity works the best for it
thanks to no nesting in window configuration.
2026-05-01 04:57:49 +03:00
Paul Eggert
da4ab3d738 Pacify GCC 16.0.1 -Wanalyzer-null-dereference in xdisp.c
* src/xdisp.c (glyph_string_containing_background_width):
Although it’s not immediately obvious whether the GCC 16 warning
is valid, adding an eassume here shouldn’t hurt.
2026-04-30 17:56:26 -07:00
Randy Taylor
edc19c3536 Always compile w32image.c on MinGW (Bug#80924)
This enables features unrelated to native image APIs, such as
'w32-export-frame' and 'yank-media', which need to call GDI+
functions.
* configure.ac (HAVE_W32) [!CYGWIN]: Always include w32image.o in
W32_OBJ.
* etc/NEWS: Drop 'yank-media' '--without-native-image-api' caveat.
* src/emacs.c (main):
* src/w32select.c (convert_dibv5_to_png):
* src/w32term.c (w32_draw_image_foreground): Replace
HAVE_NATIVE_IMAGE_API with WINDOWSNT.
* src/w32.c (term_ntproc): Remove redundant HAVE_NATIVE_IMAGE_API guard.
* src/w32fns.c (Fw32_export_frame) [!WINDOWSNT]: Return nil on Cygwin.
2026-04-30 18:52:22 +03:00
Collin Funk
51ae6e12b9 Pacify -Wunused-but-set-variable from gcc 16 and clang 13
* src/coding.c: Remove file wide ignore pragma for
-Wunused-but-set-variable.
(detect_coding_XXX) <consumed_chars>: Mention that this variable might
need to be declared with the MAYBE_UNUSED attribute.
(detect_coding_utf_8, detect_coding_emacs_mule, detect_coding_iso_2022)
(encode_designation_at_bol, detect_coding_sjis, detect_coding_big5)
(detect_coding_ccl, detect_coding_charset) <consumed_chars>: Use the
MAYBE_UNUSED attribute.
2026-04-29 22:45:52 -07:00
Paul Eggert
4fcc8a473a ; Spelling fixes. 2026-04-29 22:45:51 -07:00
Eli Zaretskii
3ce42ffd60 ; * src/treesit.c (treesit_pred_with_guard): Fix style conventions. 2026-04-30 07:47:02 +03:00
Yuan Fu
4e420d0b20
In tree-sitter, signal if predicate function causes reparse
A reparse will make the TSTreeCursor or TSNode to possibly point
to freed memory (because the TSTree they point to is freed.)

* src/treesit.c (treesit_pred_with_guard): New function.
(treesit_predicate_pred):
(treesit_eval_predicates):
(Ftreesit_query_capture):
(treesit_traverse_match_predicate):
(treesit_build_sparse_tree): Add guard that signals if buffer is
changed when calling predicate function.
(Qtreesit_buffer_changed): New symbol.
2026-04-29 16:36:48 -07:00
Basil L. Contovounesios
dee5ca5acd ; Avoid mutation in string-collate-lessp example. 2026-04-29 14:42:39 +02:00
Eric S. Raymond
3897a808d9 ; Fix an inconsistency in C symbol naming
This is the one case out of 1902 where the C name didn't match the subr
name.

* src/xfns.c (Fx_display_last_user_time): renamed to Fx_display_set_last_user_time
2026-04-28 13:34:26 -04:00
Eli Zaretskii
5cee4fa0ff ; Fix last change
* etc/NEWS: Announce the change in 'sqlite-close'.
* src/sqlite.c (Fsqlite_close): Fix commentary.
(Bug#80908).
2026-04-27 13:47:17 +03:00