Commit graph

50575 commits

Author SHA1 Message Date
Mattias Engdegård
f605e6ede3 ; * src/lread.c (read_internal_start): Simplify.
This removes code that became dead in the non-recursive reader reform.
2025-07-09 19:23:47 +02:00
Andrea Corallo
48a5917681 Nativecomp don't materialize non-materializable objects (bug#78606)
The native compiler should not try to generate in rendered code
immediate floats produced by the constrain on the '=' operator.

* test/src/comp-tests.el (comp-test-78606-1): Add test.
* test/src/comp-resources/comp-test-funcs.el (comp-test-78606-1-f): New
function.
* src/comp.c (emit_mvar_rval): Check if an immediate is materializable.
* lisp/emacs-lisp/comp.el (comp-ctxt): Add 'non-materializable-objs-h'
slot.
(comp--fwprop-insn): Update call.
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-=): Add parameter.
2025-07-09 17:32:07 +02:00
Pip Cet
a76506f131 Fix crashes when "emacsclient -nw" frames are suspended (bug#78980)
* src/frame.c (frame_redisplay_p): Start loop with 'f', not its parent
frame.  Simplify return expression.
2025-07-09 14:09:53 +00:00
Sean Whitton
b03f11d9ac print_error_message: Handle user-error to the echo area specially
* src/print.c (print_error_message): For a user-error that is to
be printed to the echo area, use message3 in order to preserve
fontification.
2025-07-09 11:45:13 +01:00
Martin Rudalics
2fc402cb0b Handle invalid frame_or_window slots in tty input events (Bug#78966)
* src/frame.c (make_terminal_frame): Initialize terminal's
top_frame slot if it has not been set up yet (Bug#78966).
* src/keyboard.c (kbd_buffer_get_event): Do not assume that the
event's frame_or_window slot always produces a valid frame
(Bug#78966).
(tty_read_avail_input): Try to make sure that the input event we
create has a valid frame_or_window slot (Bug#78966).  Add assertion
to that purpose.
2025-07-09 09:52:01 +02:00
Yuan Fu
564b947745
Add a synchronous way to get parser change ranges (bug#78402)
This commit only adds the new function, the fix for the bug is
in the next commit.

* doc/lispref/parsing.texi (Using Parser): Add docs.
* lisp/treesit.el (treesit): Add shortdoc.
* src/treesit.c (treesit_get_affected_ranges): New function
extracted from treesit_call_after_change_functions.
(treesit_call_after_change_functions): Extract out.
(treesit_ensure_parsed): Return affected regions.
(Ftreesit_parser_changed_regions): New function that returns the
affected regions.
2025-07-08 23:39:36 -07:00
Mattias Engdegård
c120a338e6 Cheaper char counting when reading symbols
* src/lread.c (read0): Strength reduction.
2025-07-07 17:27:21 +02:00
Mattias Engdegård
32a0367554 Refactor buffering code in the Lisp reader
Abstract the buffering in the reader with a struct and plain functions
instead of rather unhygienic preprocessor macros.

* src/lread.c (READ_AND_BUFFER, INVALID_SYNTAX_WITH_BUFFER):
Removed, replaced with...
(readbuf_t, readbuf_grow, add_char_to_buffer, read_and_buffer)
(invalid_syntax_with_buffer): ...these new functions and struct.
(read0): Use new code instead of old preprocessor macros.
2025-07-07 17:11:55 +02:00
Mattias Engdegård
501bb04e53 ; * src/lread.c (skip_lazy_string): more precise comment
The bool vector compat hack is there for a bug in Emacs 19 only.
2025-07-07 17:11:55 +02:00
Mattias Engdegård
d13693ef4e Read non-ASCII chars from unibyte string sources as raw bytes
Previously, latin-1 was incorrectly assumed (bug#70988).

* src/lread.c (readchar): Convert to raw byte.
* test/src/lread-tests.el (lread-unibyte-string-source): New test.
2025-07-07 11:30:07 +02:00
Mattias Engdegård
f2f7675621 Print non-ASCII chars in unibyte symbols as raw bytes
Previously, latin-1 was incorrectly assumed (bug#70988).

* src/print.c (print_object): Call the correct function.
* test/src/print-tests.el (print-unibyte-symbols): New test.
2025-07-07 11:30:07 +02:00
Mattias Engdegård
553a6c407f Read characters from functions as multibyte
Previously, latin-1 was incorrectly assumed (bug#70988).

* src/lread.c (readchar): Set multibyte flag.
* test/src/lread-tests.el (lread-function-source): New test.
2025-07-07 11:30:07 +02:00
Stefan Monnier
b93d49a378 (Ftranspose_regions): Fix bug#76124
* src/editfns.c (Ftranspose_regions): Be careful that ELisp code could
move the gap from under our feet.

* test/src/editfns-tests.el (editfns-tests--bug76124): New test.
2025-07-06 19:15:51 -04:00
Eli Zaretskii
4288dc7751 Merge from origin/emacs-30
3f7787c979 ; * lisp/replace.el (query-replace-help): Fix help text (...
b10596a630 ; * lisp/emacs-lisp/warnings.el (warning-display-at-botto...
060f964906 Handle ts_node_type return NULL (bug#78938)
5bdacbe460 Improve documentation of 'warning-display-at-bottom'
30dae2ad23 Handle the case when ts_node_type returns NULL (bug#78938)
985ad1da76 ; * lisp/emacs-lisp/bytecomp.el (compilation-safety): Doc...
de18407f51 ; * doc/lispref/functions.texi (Mapping Functions): Fix w...
2025-07-05 06:02:36 -04:00
Yuan Fu
060f964906
Handle ts_node_type return NULL (bug#78938)
* src/treesit.c (treesit_traverse_match_predicate): Handle the
case when ts_node_type returns NULL.
(Ftreesit_node_type): Add some comment.
2025-07-04 13:22:14 -07:00
Yuan Fu
30dae2ad23
Handle the case when ts_node_type returns NULL (bug#78938)
* src/treesit.c (Ftreesit_node_type): Handle NULL.
2025-07-03 23:40:59 -07:00
Eli Zaretskii
205d69e7e6 Avoid segfaults due to C-g when a thread does GC
* src/keyboard.c (handle_interrupt): Don't forcibly switch threads
if a non-main thread was in GC when the signal handler was called.
2025-07-03 16:19:09 +03:00
Po Lu
987cd7012d Properly invalidate XRender surfaces when only EmacsFrame is resized
* src/xterm.c (handle_one_xevent): Drop XRender surfaces when
the frame widget is resized, rather than when the toplevel is.
(bug#77988)
2025-06-28 22:14:35 +08:00
Pip Cet
6b19eb53c5 Avoid extra output in Vprin1_to_string_buffer (bug#78842)
print_error_message can throw after producing some output, so use
unwind-protect to ensure prin1-to-string-buffer is cleared.

* src/print.c (erase_prin1_to_string_buffer): New.
(Ferror_message_string): Use it to catch errors thrown in
'print_error_message'.
* test/src/print-tests.el (error-message-string-circular): Expand
test.
2025-06-28 10:46:08 +00:00
Paul Eggert
dd1efa5309 Port varargs macros better to C99
C99 prohibits passing zero args to macro’s ‘...’.
* lib-src/seccomp-filter.c (RULE0): New macro, which is like RULE
except with zero args.  All zero-arg uses of RULE changed to RULE0.
* src/comp.c (compile_function, Fcomp__init_ctxt, syms_of_comp):
Change ‘CALLN (Fmake_hash_table)’ to ‘Fmake_hash_table (0, NULL)’,
since CALLN requires at least two args in C99.
2025-06-27 23:54:45 -07:00
Stefan Monnier
6c0bbf0f92 (Finsert_file_contents): Refine commit d07af40d88
* src/fileio.c (Finsert_file_contents): Inhibit ask-supersession
only if we're VISITing in a non-narrowed buffer (bug#78866).

* test/src/fileio-tests.el (ert--tests-dir): New var.
(fileio-tests--insert-file-contents-supersession): New test.
2025-06-27 23:11:39 -04:00
Eli Zaretskii
dd95447b05 Avoid segfault when profiling Lisp programs with threads
* src/eval.c (backtrace_top): Don't segfault if current_thread is
NULL.  (Bug#76970)
2025-06-21 11:53:24 +03:00
Eli Zaretskii
8201e7e7a7 ; * src/xfaces.c (init_xfaces) <face_attr_sym>: Add :family (bug#78813). 2025-06-21 09:45:02 +03:00
Paul Eggert
037fb02135 process-attributes uses CLOCK_BOOTTIME for uptime
* src/sysdep.c (get_host_uptime) [GNU_LINUX || CYGWIN || __ANDROID__]:
New function, replacing get_host_boot_time.
Use CLOCK_BOOTTIME instead of inspecting /proc/stat.
All callers changed.  This should be an even better way to fix Bug#63496.
2025-06-17 17:11:17 -07:00
Paul Eggert
73cebbb87b process-attributes uses /proc/stat for boot time
With a Linux kernel, use /proc/stat rather than get_boot_time
to get boot time, since when Emacs is running in a container
we want the underlying host boot time, not the container boot time.
This should be a better way to fix Bug#63496.
* src/sysdep.c: Do not include boot-time.h.
(get_host_boot_time) [GNU_LINUX || CYGWIN || __ANDROID__]:
New function.
(system_process_attributes) [GNU_LINUX || CYGWIN || __ANDROID__]:
Use it instead of get_boot_time.
2025-06-17 12:25:16 -07:00
Eli Zaretskii
06b74b04cb Prevent redisplay slowdown with non-zero vscroll
* src/xdisp.c (try_scrolling): Don't loop when the
partially-visible cursor line is at the top of the window.  This
looping are pointless, and just makes redisplay slow for no reason.
(Bug#78766)
2025-06-17 16:00:04 +03:00
Paul Eggert
477112ebc3 process-attributes now uses get_boot_time
I noticed this issue while looking into Bug#63496.
GNU Emacs does not infer the boot time consistently on GNU/Linux
and similar platforms: android_notifications_notify_1 and
get_boot_sec use Gnulib’s boot-time module, but process-attributes
has idiosyncratic code that evidently predates that module.
The idiosyncratic code returns an unstable etime, which is a minor bug.
Simplify process-attributes by just using Gnulib.
This returns a stable etime.
It may also fix Bug#63496; if not, we can fix Gnulib later.
* src/sysdep.c: Include <boot-time.h>.
(get_up_time) [GNU_LINUX || CYGWIN || __ANDROID__]: Remove.
(system_process_attributes) [GNU_LINUX || CYGWIN || __ANDROID__]:
Use get_boot_time instead of get_up_time.
2025-06-15 19:22:48 -07:00
Mattias Engdegård
ebdad09c5a * src/bytecode.c (exec_byte_code): Remove superfluous condition
Bytecode should never be able to set anything to Qunbound because that
value is not accessible from Lisp.  Found by Pip Cet.
2025-06-15 17:50:32 +02:00
Mattias Engdegård
08a7477d22 * src/fns.c (mapcar1): Less lax type checking
Previously, mapcar etc would crash or return nonsense when passed a
record.  Found by Pip Cet.
2025-06-15 10:50:59 +02:00
Eli Zaretskii
336253ddd3 Merge from origin/emacs-30
df3fb94f09 Insert missing step to make use of directory tracking OSC...
1bed294958 * lisp/keymap.el (keymap-set): Refer to 'key-description'...
941158fc13 Support new tree-sitter grammar filename format (bug#78754)
888f846d37 Fix crash when evaluating "(signal nil 5)" (bug#78738)
51b9e92ab8 Merge branch 'emacs-30' of git.savannah.gnu.org:/srv/git/...
c0a913ea4f ; * doc/lispref/modes.texi (Font Lock Basics): Remove old...
37de076017 Adapt emba integration (don't merge)
2025-06-14 11:23:54 -04:00
Steven Allen
4d88b925ba Improve documentation of the internal Lisp_Process->status field
Contrary to the existing documentation here, the value of this
field cannot be the symbols open or closed.  Furthermore, this
field is never set to "stop" for network connections.
* src/process.h (Lisp_Process): Improve/fix documentation of the
'status' field.  (Bug#78784)
2025-06-14 18:02:40 +03:00
Eli Zaretskii
69254cd51a ; * src/profiler.c (export_log): Fix whitespace (bug#78762). 2025-06-14 17:56:01 +03:00
Zach Shaftel
009cdc8ae0 Fix segfault in profiler-cpu-log and profiler-memory-log (bug#78763)
* src/profiler.c (export_log): Check if a log has been allocated first,
and return nil if it hasn't.
(Fprofiler_cpu_log, Fprofiler_memory_log): Doc fix.
* test/src/profiler-tests.el (profiler-tests-cpu-profiler)
(profiler-tests-memory-profiler): New tests.
2025-06-14 17:54:06 +03:00
Eli Zaretskii
82766b71a4 ; Fix warnings in MinGW builds
* src/w32fns.c (msh_mousewheel): Declare.
* src/treesit.c (treesit_debug_print_linecol): Fix format
specifiers.

* lib-src/pop.c (pfn_getaddrinfo, pfn_freeaddrinfo): Now static.
2025-06-14 16:56:44 +03:00
Eli Zaretskii
3927402af0 Support 'C-g C-g C-g' "urgent quit" feature on MS-Windows
* src/w32fns.c (post_character_message): Support triple-C-g.
(Bug#78737)
2025-06-14 11:57:42 +03:00
Yuan Fu
941158fc13
Support new tree-sitter grammar filename format (bug#78754)
Previously Emacs only looks for filenames like
libtree-sitter-json.so.0.0.  Now Emacs also look for filenames
like libtree-sitter-json.so.15.0.

* src/treesit.c:
(treesit_load_language_push_for_each_suffix): Add versioned
candidate to candidate list too.
2025-06-10 23:46:53 -07:00
Jim Porter
24e6cd4233 Improve documentation for display property functions
Specifically, use the term "display specification" more consistently to
distinguish from "display property", which is the full value of the
'display' text property.

* src/xdisp.c (find_display_property): Rename PROP to SPEC.
(Fget_display_property): Rename PROP to SPEC and improve docstring.

* lisp/emacs-lisp/subr-x.el (add-display-text-property): Rename PROP to
SPEC and improve docstring.

* doc/lispref/display.texi (Display Property): Reword documentation to
more-consistently refer to display specifications.
2025-06-10 22:09:26 -07:00
Po Lu
231c4f20ea Port to Android API 36
* java/AndroidManifest.xml.in: Update targetSdkVersion to 36.

* java/INSTALL: Document revised compilation dependencies.

* java/org/gnu/emacs/EmacsActivity.java (interceptBackGesture):
New function.
(onCreate): Invoke the same to register back gesture callbacks
on Android 16 or better.

* java/org/gnu/emacs/EmacsWindow.java (onBackInvoked): New
function.

* src/keyboard.c (lispy_function_keys): Amend with new symbols
introduced in Android API 36.
2025-06-11 10:34:49 +08:00
Pip Cet
888f846d37 Fix crash when evaluating "(signal nil 5)" (bug#78738)
The docstring already warns against calling signal with a nil
error symbol, which is for internal use only, but we can avoid crashing
in this case.

* src/eval.c (Fsignal): Produce a "peculiar error" for more arguments
involving non-lists.
2025-06-10 12:00:30 +00:00
JD Smith
9b30934756 Fix vertical-motion when an image is at EOL under word-wrap
* src/xdisp.c (move_it_in_display_line_to): Fix return value under
word-wrap when a screen line ends with an image that "just fits".
(Bug#67604)
2025-06-07 12:57:52 +03:00
Eli Zaretskii
bcf005fa77 Improve documentation of treesit "thing"
* src/treesit.c (syms_of_treesit):
* lisp/treesit.el (treesit-cycle-sexp-type):
(treesit-thing-at, treesit-thing-at-point): Doc fixes.

* doc/lispref/parsing.texi (User-defined Things): Improve
documentation of treesit "thing" and related functions; add
cross-references and indexing.
2025-06-05 10:30:44 +03:00
Eli Zaretskii
8c4ff60cf4 ; * src/nsterm.m (ns_draw_stretch_glyph_string): Fix a thinko (bug#78654). 2025-06-04 19:56:58 +03:00
Alan Third
50e3bce315 Fix NS port screen geometry report (bug#76051)
* src/nsfns.m (Fns_display_monitor_attributes_list): Fix the arithmetic
to calculate the origin of the visible frame.
2025-06-02 18:34:10 +01:00
shipmints
9cc5f1c697 Fix ns_make_monitor_attribute_list (bug#76691)
This is the NS implementation for 'display-monitor-attributes-list'.
Change implementation from IORegistry to direct introspection
of NSScreen.

* src/nsfns.m (ns_make_monitor_attribute_list): Use localizedName
selector on NSScreen.  For anonymous displays, synthesize names
of the form ("%dx%d@%d,%d" width height x y).
(ns_get_name_from_ioreg) (ns_screen_name): Removed.
2025-06-02 18:34:10 +01:00
Eli Zaretskii
f77c8c7d45 ; Avoid compiler warnings in MinGW builds
* src/w32proc.c (child_proc_count, child_procs)
(Vw32_valid_locale_ids, Vw32_valid_codepages): Declare 'static'.
* src/w32inevt.c (faked_key): Declare.
* src/w32heap.c (data_region_base, data_region_end, heap): Declare.
* src/w32console.c (keyboard_handle, current_tty, cost): Declare.
* src/w32.c: Declare function pointers 'static'.
(excptr, excprec, ctxrec, g_b_init_compare_string_w)
(g_b_init_debug_break_process, LookupAccountSid_Name, dir_static)
(winsock_lib, _wsa_errlist): Declare.
* src/w32uniscribe.c: Declare function pointers 'static'.
(uniscribe_available, harfbuzz_available): Declare.
* src/w32term.c: Declare function pointers 'static'.
(vertical_scroll_bar_min_handle, horizontal_scroll_bar_min_handle)
(vertical_scroll_bar_top_border)
(vertical_scroll_bar_bottom_border)
(horizontal_scroll_bar_left_border)
(horizontal_scroll_bar_right_border, last_scroll_bar_drag_pos):
Declare 'static'.
* src/w32xfns.c (input_available, interrupt_handle, lpHead)
(lpTail, nQueue): Declare.
* src/w32menu.c: Declare function pointers 'static'.
* src/w32term.h (w32_frame_parm_handlers): Declare.
* src/w32fns.c: Declare function pointers 'static'.
(w32_darkmode, w32_color_map, deferred_msg_head, tip_frame)
(tip_timer, tip_last_string, tip_last_frame, tip_last_parms):
* src/lisp.h (daemon_type): Declare for WINDOWSNT as well.
* nt/cmdproxy.c (escape_char, child, interactive): Declare 'static'.
(Bug#78193)
2025-06-01 12:05:23 +03:00
Eli Zaretskii
4b527088e6 ; * src/fns.c (fixnum_float_cmp): Don't use non-ASCII characters. 2025-05-31 17:32:49 +03:00
Martin Rudalics
433a031d24 Have 'delete-frame' delete initial daemon frame only if FORCE is non-nil
* src/frame.c (delete_frame): Delete initial daemon frame only
if FORCE is non-nil (Bug#78583).
(Fdelete_frame): Rewrite doc-string to mention that it can
delete an initial daemon frame if and only if FORCE is non-nil.
* etc/NEWS:
* doc/lispref/frames.texi (Deleting Frames): Mention that
'delete-frame' can delete an initial daemon frame if and only if
FORCE is non-nil.
2025-05-29 11:33:28 +02:00
Pip Cet
d14fc6b75f Fix unsafe SDATA usage in print.c (bug#78590)
* src/print.c (print_string_1): Renamed from 'print_string', with an
extra argument to disable nonascii escaping.
(print_string): New function.
(print_object): Use 'print_string_1', not 'strout'.
2025-05-28 19:22:57 +00:00
Gerd Möllmann
6279a9e8ef Do child frame shortcut only on Cocoa (bug#78616)
* src/nsterm.m ([EmacsWindow constrainFrameRect:toScreen:]):
Return early for child frames only on Cocoa.
2025-05-28 12:59:50 +02:00
Eli Zaretskii
3b5226af3f Fix DST time calculations on MS-Windows
* src/w32.c (w32_fix_tzset): New function.
* src/timefns.c (emacs_localtime_rz, tzlookup):
* src/w32.c (sys_localtime): Call 'w32_fix_tzset'.
(Bug#11281)
2025-05-26 19:53:21 +03:00