Commit graph

50978 commits

Author SHA1 Message Date
Stefan Monnier
ea5f15d096 Fix signal calls where the data argument is not a list
* test/src/thread-tests.el (threads-join-error):
* test/src/emacs-module-resources/mod-test.c (Fmod_test_signal):
* src/print.c (print_bind_overrides):
* lisp/url/url-future.el (url-future-finish, url-future-errored)
(url-future-call, url-future-cancel): Make sure signal's data is a list.

* test/src/emacs-module-tests.el (mod-test-non-local-exit-signal-test):
Adjust accordingly.
2026-03-10 00:13:31 -04:00
Pip Cet
f254b2cc19 Fix infloop when decoding incomplete embedded UTF-8 input
* src/coding.c (decode_coding_iso_2022): Record conversion result for
incomplete data.
2026-03-07 11:36:58 +00:00
Eli Zaretskii
06471a82c8 Fix segfaults in 'kbd_buffer_get_event'
* src/keyboard.c (kbd_buffer_get_event): Ignore selection-request
events when accessing the frame of an event.  Suggested by dick
r. chiang <dick.r.chiang@gmail.com>.  (Bug#80558)
2026-03-07 09:49:22 +02:00
Stéphane Marks
b7aca342e6 ; Move ns_init_colors from Fns_list_colors to emacs.c (bug#80377)
Support calls to ns_lisp_to_color or Fns_list_colors in headless
environments where ns_term_init is not called, and calls before
ns_term_init runs.

* src/emacs.c (main): Call ns_init_colors when not in dump mode.
* src/nsfns.m (ns_init_colors): Make public function.
(Fns_list_colors): Remove ns_init_colors call.
* src/nsterm.h: extern ns_init_colors.
2026-03-07 00:04:21 +00:00
Martin Rudalics
8034e48630 Additional fixes for 'get-mru-frame' (Bug#80397)
* src/frame.c (delete_frame): Call 'get-mru-frame' safely and
with EXCLUDE-FRAME argument set up correctly.
* lisp/frame.el (get-mru-frames, get-mru-frame): Fix doc-strings.
2026-03-06 09:51:21 +01:00
Martin Rudalics
1f30f37df8 Fix segfault introduced by recent 'get-mru-frame' change
* src/frame.c (delete_frame): Fix segfault when deleting a
frame and 'get-mru-frame' returns that frame.
2026-03-05 11:22:55 +01:00
Alan Third
d40e5050be Fix seg fault when image dimensions don't match (bug#80518)
* src/image.c (four_corners_best): [USE_CAIRO] Reset the image
dimensions to real values.
(Fimage_transforms_p): Fix typo.
2026-03-04 19:21:36 +00:00
Mattias Engdegård
dfa4a0e5a2 Faster JSON string serialisation (bug#80529)
* src/json.c (json_out_string):
Optimise for runs of non-special ASCII chars.

This seems to be a a substantial performance gain for long strings but a
smaller regression for short strings (up to 6 chars or thereabouts,
depending on cpu, compiler, and/or C library).  Still likely worth it.

Suggested by Pavel <cyberkm@gmail.com>.
2026-03-03 17:21:16 +01:00
Manuel Giraud
d272dedf8c Add mirroring for special glyphs (bug#80440)
See initial discussion here:
https://lists.gnu.org/archive/html/emacs-devel/2026-02/msg00400.html

* lisp/international/characters.el (pairs): Populate
special-mirror-table.
* src/xdisp.c (produce_special_glyphs): Add two arguments.  One
to identify the paragraph direction and one to identify that the
glyph is produced on the left hand side of a window.  Mirror
glyph defined in the display table according to the new
special-mirror-table.  Bidi mirroring always takes precedence.
(init_iterator, insert_left_trunc_glyphs, display_line)
(display_string): Call 'produce_special_glyphs' with new arguments.
(syms_of_xdisp) <special-mirror-table>: New char-table.
* etc/NEWS: Announce the change.
2026-03-03 16:24:58 +02:00
Sean Whitton
1f9b6223e1 ; Move documentation for multiple-terminals-merge-keyboards. 2026-03-03 11:14:10 +00:00
Eli Zaretskii
f46eaf609e ; * src/w32image.c (w32_gdip_export_frame): Add error checking. 2026-03-02 17:03:17 +02:00
Eli Zaretskii
a755d7fcf0 Teach Emacs on MS-Windows how to export frame screenshots
* src/w32image.c (w32_gdip_export_frame): New function.
(gdiplus_init): Load 'GdipCreateBitmapFromHBITMAP' from GDI+ DLL.
* src/w32fns.c (Fw32_export_frame): New primitive.

* etc/NEWS: Announce the new primitive.
2026-03-01 15:08:51 +02:00
Sean Whitton
d78a1db462 New variable 'multiple-terminals-merge-keyboards'
* src/keyboard.c (syms_of_keyboard):
<multiple_terminals_merge_keyboards>: New variable.
(read_event_from_main_queue): Mention it in message.
* lisp/cus-start.el: Make it customizable.
* src/callint.c (Ffuncall_interactively):
* src/keyboard.c (Frecursive_edit):
* src/minibuf.c (read_minibuf): When its value is true, don't
enter single-kboard mode (bug#79892).
* admin/notes/multi-tty:
* etc/NEWS: Document it.
2026-02-28 20:54:56 +00:00
Paul Eggert
aed1c8b536 Don’t stuff keyboard input uselessly
Also, document stuffing better.
* src/keyboard.c (stuff_buffered_input):
Give up on stuffing if it fails.
* src/sysdep.c (stuff_char): Return failure indication.
2026-02-28 09:09:22 -08:00
Sean Whitton
62ab58972c ; * src/callproc.c (command-line-max-length): Use DEFVAR_INT. 2026-02-28 15:50:10 +00:00
Sean Whitton
342e002c87 Show a message in locked frames in single-kboard mode
* src/keyboard.c (kbd_buffer_get_event): Pass the event's frame
up to the caller by means of a new 'struct frame **' argument.
(read_event_from_main_queue): Show a message in locked frames in
single-kboard mode (bug#79892).
* src/xdisp.c (log_message): Factor out of message3.
(message3): Call it.
(message3_nolog): Rename to ...
(message3_frame_nolog): ... this.  New 'struct frame *' argument
which causes temporarily switching to another frame when
displaying the message.
(message3_frame, message3_nolog): New functions.
* src/lisp.h: Declare message3_frame and message3_frame_nolog.
* admin/notes/multi-tty: Remove notes on showing a message.
2026-02-28 15:34:16 +00:00
Eli Zaretskii
b540c45bc5 Document that string ARG of 'kill-emacs' might not work
* src/emacs.c (Fkill_emacs):
* doc/lispref/os.texi (Killing Emacs): Document that EXIT-DATA
being a string doesn't always work.  (Bug#80435)
2026-02-28 16:10:08 +02:00
Eli Zaretskii
0d017fc7ce ; Fix the documentation of 'overlays-in' etc.
* src/buffer.c (Foverlays_in):
* lisp/subr.el (remove-overlays):
* doc/lispref/display.texi (Finding Overlays, Managing Overlays):
* etc/NEWS: Improve the documentation of recent changes in
behavior of 'overlays-in' and 'remove-overlays'.  (Bug#80242)
2026-02-28 15:36:07 +02:00
Eli Zaretskii
a36d0c66e4 ; Remove unused declarations from w32heap.c
* src/w32heap.c (RtlCreateHeap_Proc, PRTL_HEAP_COMMIT_ROUTINE)
(RTL_HEAP_PARAMETERS): Remove unused declarations (bug#76041).
2026-02-28 14:58:33 +02:00
Eli Zaretskii
d366c8cf23 ; * src/w32proc.c (new_child): Update comment (bug#76041). 2026-02-28 14:53:34 +02:00
Sean Whitton
3b223db8a7 Initialize command-line-max-length with sysconf(3)
* lisp/subr.el (command-line-max-length): Move from here ...
* src/callproc.c (syms_of_callproc): <Vcommand_line_max_length>:
... to here.  Initialize by calling sysconf(3) if possible.
2026-02-28 10:23:11 +00:00
Boris Buliga
1c4f09aadc Fix macOS 26 scrolling lag and input handling issues (bug#80268)
macOS 26 introduced new event processing behavior that causes scrolling
lag and input handling problems in Emacs.  This patch disables two
features via NSUserDefaults when built against the macOS 26 SDK:
- NSEventConcurrentProcessingEnabled
- NSApplicationUpdateCycleEnabled

This fix is based on the equivalent patch in emacs-mac by Mitsuharu
Yamamoto.  See: https://bitbucket.org/mituharu/emacs-mac/commits/e52ebfd

* src/nsterm.m (ns_term_init): Disable problematic event processing
when built for macOS 26+.
2026-02-27 20:27:53 +00:00
Sean Whitton
eca81082a1 ; Fix some comments. 2026-02-27 18:17:36 +00:00
Sean Whitton
9d7130439a ; Copy out log message from when branch was first introduced. 2026-02-27 16:02:49 +00:00
Eli Zaretskii
76c7c867d6 Fix bug on MS-Windows with frame title when system-name is non-ASCII
* src/w32.c (sys_gethostname): Convert system name to UTF-8.
Ensure the buffer passed to 'gethostname' is large enough.
(Bug#80472)
2026-02-27 17:55:05 +02:00
Martin Rudalics
cbd437f792 ; Fix doc-string of 'window-combination-resize'
* src/window.c (syms_of_window): Fix doc-string of
'window-combination-resize'.
2026-02-26 10:22:11 +01:00
Mattias Engdegård
a84530ac2e Speed up 'equal'-comparison of vectorlike objects
* src/fns.c (internal_equal_1): Switch on the vectorlike type instead of
using a sequence of type predicates.
2026-02-24 12:49:53 +01:00
Mattias Engdegård
2505af27c6 Compare circular lists in 'equal' without error (bug#80456)
* src/lisp.h (FOR_EACH_TAIL_INTERNAL): Divvy up the code into...
(FOR_EACH_TAIL_BASIC, FOR_EACH_TAIL_STEP_CYCLEP): ...these macros,
so that they can be used in more flexible ways.
* src/fns.c (internal_equal_1): Detect circular lists and call...
(internal_equal_cycle): ...this function that keeps comparing
but now detecting cycles in the other argument.

* lisp/emacs-lisp/testcover.el (testcover-after):
Remove unnecessary error handling.
* test/src/fns-tests.el (test-cycle-equal): Adapt and extend.
* test/lisp/emacs-lisp/testcover-resources/testcases.el
(testcover-testcase-cyc1): Remove case that no longer applies.

* doc/lispref/objects.texi (Equality Predicates): Update.
* etc/NEWS: Announce.
2026-02-24 12:47:52 +01:00
Collin Funk
29440eedac Add SHA-3 support to secure-hash
* admin/merge-gnulib (GNULIB_MODULES): Add crypto/sha3-buffer.
* lib/sha3.c: New file, imported by running admin/merge-gnulib.
* lib/sha3.h: Likewise.
* m4/sha3.m4: Likewise.
* lib/gnulib.mk.in: Updated by admin/merge-gnulib.
* m4/gnulib-comp.m4: Likewise.
* src/fns.c: Include sha3.h
(Fsecure_hash_algorithms): Add Qsha3_224, Qsha3_256, Qsha3_384, and
Qsha3_512.
(secure_hash): Likewise.
(Fsecure_hash): List the SHA-3 algorithms in the docstring.
(syms_of_fns): Define Qsha3_224, Qsha3_256, Qsha3_384, and Qsha3_512.
* test/lisp/net/gnutls-tests.el (gnutls-tests-internal-macs-upcased):
Filter out the new SHA-3 algorithms since they are currently not
implemented in gnutls.
* test/src/fns-tests.el (test-secure-hash): Add test cases for the new
algorithms.
* doc/lispref/text.texi (Checksum/Hash): List the SHA-3 algorithms.
Mention that they are considered secure.
* etc/NEWS: Mention the new feature.
2026-02-23 00:22:17 -08:00
Michael Albinus
195d2f7a74 * src/dbusbind.c: Include fcntl.h if needed. (Bug#80373) 2026-02-22 16:30:19 +01:00
Stéphane Marks
77aac20ce6 New user option 'after-delete-frame-select-mru-frame' (bug#80397)
Users can revert to the old 'delete-frame' behavior of selecting
the oldest frame in 'frame-list' rather than the most-recently
used frame.

* src/frame.c (delete_frame): Consult
'after-delete-frame-select-mru-frame'.
(syms_of_frame): New defvar
'after-delete-frame-select-mru-frame'.
* etc/NEWS: Reflect the new user option.
2026-02-22 10:33:34 +01:00
Paul Eggert
64c2df0e19 Stop ENUM_BF worrying about gcc -std=c89 -pedantic
* src/lisp.h (ENUM_BF): Modernize ENUM_BF doc for latest compilers
that still have a beef with enum bitfields.  Simplify by dropping
support for ‘gcc -std=c89 -pedantic’, as it’s been many years
since Emacs worked with C89, for other reasons.
2026-02-21 20:26:30 -08:00
Paul Eggert
89ce923eb3 Port Lisp_Fwd to strict C bitfields
ISO C does not require C compilers to support enum bitfields.
Problem found with IBM XL C for AIX 16.1 (2018), which IBM
supports through 2029.
* src/lisp.h (struct Lisp_Fwd): Use ENUM_BF instead of declaring
enum bitfields directly.
2026-02-21 20:26:30 -08:00
Alan Third
a61c098a51 Fix GNUstep width calculation (bug#80331)
* src/nsfns.m (Fx_display_mm_height): 'dpi' should have been 'px_to_mm'.

Co-authored-by: Shay Elkin <shay@elkin.io>
2026-02-21 18:50:23 +00:00
Shay Elkin
a7dbf2427a Use real display geometry on NS (bug#80331)
In nsfns.m, `x-display-mm-height' and `x-display-mm-weight' computes the
display size by dividing its (logical) pixel dimensions by 92 dpi.

This would often give wrong results: by default, logical pixels on in
macOS are computed to 72 dpi, but that can be changed by the user.

As macOS multi-screen geometry is all computed based on the main
screen's cooridnate system, use its dpi to compute the physical size of
the bounding box containing all the screens.

* src/nsfns.m (Fx_display_mm_height):
(Fx_display_mm_width): Calculate the total physical display size
using the main-screen's geometry.

Copyright-paperwork-exempt: yes
2026-02-21 17:37:56 +00:00
Alan Third
7478e6ae7d Fix SVG CSS handling (bug#80384)
This reverts commit 9f5d17cd72, but
includes the fix for adding user CSS after the generated CSS.

* src/image.c (svg_load_image): Set the CSS stylesheet using the librsvg
functions, instead of inserting it into the wrapper.
2026-02-21 17:29:40 +00:00
Eli Zaretskii
f3555fc846 Avoid segfaults if someone sets 'composition-function-table' to nil
* src/composite.c (composition_compute_stop_pos)
(composition_reseat_it): Recreate 'composition-function-table' if
it ever becomes garbled.  (Bug#80462)
2026-02-21 19:27:17 +02:00
Stefan Monnier
6b101f17b8 Fix predicate of plist-member on function-history
The keys of this plist are strings and should thus be compared
with `equal`.  `eq` works surprisingly often (because we often
happen to use exactly the same string) but not always.

* lisp/loadhist.el (loadhist-unload-element):
* src/data.c (add_to_function_history): Pass `equal` to `plist-member`.
2026-02-20 23:37:48 -05:00
Stéphane Marks
54d0764665 Add frame-use-time, get-mru-frame, use mru frame in delete-frame (bug#80397)
* lisp/frame.el (get-mru-frame): New defun.
* src/frame.c (delete_frame): Call 'get-mru-frame' (when force
is not Qnoelisp) to select the most recently used frame that is
not the deleted frame as the candidate to select.
(syms_of_frame): Qget_mru_frame new DEFSYM.
* doc/lispref/frames.texi: Document the new functions.
* etc/NEWS: Announce the new functions.
2026-02-18 19:28:21 +02:00
Eli Zaretskii
9df4dee8d5 ; Fix last change in treesit.c
* src/treesit.c (ts_tree_cursor_copy) [WINDOWSNT]: Define and load
from the DLL if 'ts_tree_cursor_goto_previous_sibling' is not
available.  This fixes the MS-Windows build broken by the last
change here.  (Bug#80108)
2026-02-18 14:25:24 +02:00
Yuan Fu
25149aec99
Change back tree-sitter version requirement (bug#80108)
Now we use treesit_traverse_sibling_helper when it exists, and
use the old code otherwise. So we still support older
tree-sitter versions.

* configure.ac (LIBSYSTEMD_CFLAGS): Add back old config checking
for the malloc function. Add another check for
ts_tree_cursor_goto_previous_sibling.
* src/treesit.c: (treesit_traverse_sibling_helper): Add back the
old code that doesn't require
ts_tree_cursor_goto_previous_sibling.
2026-02-17 17:55:18 -08:00
Basil L. Contovounesios
09f2e436ba ; Remove stale commentary in dispnew.c.
* src/dispnew.c: Remove commentary that used to relate to
WINDOW_TO_FRAME_VPOS and WINDOW_TO_FRAME_HPOS.
2026-02-17 15:22:20 +01:00
Basil L. Contovounesios
8cd687c5c6 ; Fix typo in struct image commentary. 2026-02-17 15:22:06 +01:00
Basil L. Contovounesios
0e451ce2ea ; Fix image_error argument in webp_load. 2026-02-17 15:12:02 +01:00
Eli Zaretskii
69694381a4 Fix handling of window-specific overlays in buffer iteration for display
* src/xdisp.c (compute_display_string_pos): Pay attention to
'display' properties that come from overlays, in case the overlays
are window-specific.  Call 'handle_display_prop' with the argument
OVERLAY non-nil, if the property is from an overlay.
(compute_display_string_end): Accept an additional argument, a
pointer to the window; all callers changed.  Pay attention to
'display' properties that come from overlays, in case the overlays
are window-specific.  In particular, if the property comes from an
overlay, use that overlay's end position as the next place where
the 'display' property changes, effectively disregarding any
properties on buffer text that is replaced by this overlay's
'display' property.
(handle_single_display_spec): Always use the end position of the
overlay which determined the 'display' property as the end of the
property, to make sure we obey windows-specific overlays.
* src/bidi.c (bidi_fetch_char): Adapt to the above change.
* src/dispextern.h: Adjust prototype of 'compute_display_string_end'.
(Bug#80255)
2026-02-14 13:36:38 +02:00
Eli Zaretskii
f452b18e87 ; * src/xfaces.c (face_at_buffer_position): Fix next_overlay per bug#80242. 2026-02-14 12:39:03 +02:00
Eli Zaretskii
6aefaca819 Adjust documentation to changes in 'overlays-in' and 'overlays-at'
* src/buffer.c (overlays_in): Fix commentary to match the code.
(Foverlays_in, Foverlays_at): Doc fixes.  (Bug#80242)

* test/src/buffer-tests.el (test-overlays-at-2): Add one test.

* doc/lispref/display.texi (Finding Overlays): Update and improve
the documentation of 'overlays-in' and 'overlays-at'.

* etc/NEWS: Announce the changes.
2026-02-14 11:37:52 +02:00
Paul Eggert
5d310e0059 Pacify GCC with gdk-pixbuf 2.44
* src/pgtkfns.c (xg_set_icon_from_xpm_data):
* src/xfns.c (xg_set_icon_from_xpm_data):
gdk-pixbuf 2.44 (2025-09) deprecated xg_set_icon_from_xpm_data,
and this breaks --enable-gcc-warnings builds.
For now, pacify GCC by using a pragma.
2026-02-13 17:44:46 -08:00
Paul Eggert
e847bcca0c Remove vla.h
Uses of <vla.h>’s macro VLA_ELEMS were removed some time ago.
* admin/merge-gnulib (GNULIB_MODULES): Remove vla.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
* lib/vla.h: Remove.
* src/fns.c, src/lread.c: Do not include <vla.h>.
2026-02-13 17:44:46 -08:00
João Távora
aa181cd352 Rewrite flex completion with Gotoh algorithm
The greedy regexp matching, broken scoring and broken highlight were
sources of frequent complaints about the 'flex' matching style.  This
commit fixes that.

Inspired by the 'hotfuzz' style (available at
https://github.com/axelf4/hotfuzz) it uses a modified version of Gotoh's
1982 dynamic programming algorithm. It is strictly more correct than the
"old" flex.  For example, when matching the pattern 'goto' to no longer
will 'eglot-format' be sorted before some hypothetical much better
'goobarbaz-goto'.  And of course the highlighting is also correctly
placed on the 'goto', not scattered across the candidate.

Regarding performance, it is faster than the naive 'flex', primarily
because of the Elisp rewrite in minibuffer.el.  The matching and costing
algorithm matters but is not the bottleneck.

The Elisp parts of the style were almost completely decoupled from the
pcm/substring styles in lisp/minibuffer.el.  Only
'completion-flex-try-completion' uses some of pcm's code for pattern
augmentation.

* src/minibuf.c (completion--flex-cost-gotoh): New function.

* lisp/minibuffer.el (completion-flex--pattern-str): New variable.
(flex-score-match-tightness): Make obsolete.
(completion--flex-all-completions-1): New helper function.
(completion-flex-try-completion, completion-flex-all-completions): Rewrite.
(completion-substring--all-completions): No longer take transform-pattern-fn.
(completion--flex-adjust-metadata): Tweak.
(completion--flex-score, completion--flex-score-1)
(completion--flex-score-last-md, completion-flex--make-flex-pattern): Delete.

* test/lisp/minibuffer-tests.el (completion--sorted-flex-completions):
New helper function.
(completion-flex-test-non-ascii): New test.
(completion--pcm-score): Delete.
(completion-pcm-test-3, completion-pcm-test-4)
(completion-substring-test-1, completion-substring-test-2)
(completion-flex-test-2, completion-flex-test-3): Tweak.

* etc/NEWS: Describe change.
2026-02-13 23:46:11 +00:00