1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-05-31 01:32:00 -07:00
Commit graph

182346 commits

Author SHA1 Message Date
Jim Porter
e9847f8263 Handle Lisp errors in Eshell workers
* lisp/eshell/esh-worker.el (eshell-worker-name): New generic function.
(eshell-worker--error): New defsubst.
(eshell-output-object-to-target, eshell-close-target): Wrap
'cl-call-next-method' in error handlers.

* test/lisp/eshell/esh-worker-tests.el
(esh-worker-test/pipe/error-handling)
(esh-worker-test/map-lines/error-handling)
(esh-worker-test/apply-lines/error-handling): New tests.
2026-05-27 18:35:14 -07:00
Jim Porter
a1cbfe27b1 Add 'apply-lines' and 'map-lines' Eshell commands
* lisp/eshell/esh-worker.el (eshell-map-lines-worker)
(eshell-apply-lines-worker): New structs.
(eshell-map-lines-worker--apply): New generic function.
(eshell-output-object-to-target, eshell-close-target): New methods.
(eshell/map-lines, eshell/apply-lines): New functions.

* test/lisp/eshell/esh-worker-tests.el (eshell-test-line-number): New
defvar...
(eshell-test-number): ... use it in this new function.
(esh-worker-test/map-lines/eshell-one-line)
(esh-worker-test/map-lines/eshell-multiple-lines)
(esh-worker-test/map-lines/eshell-multiple-batches)
(esh-worker-test/map-lines/external-one-line)
(esh-worker-test/map-lines/external-multiple-lines)
(esh-worker-test/map-lines/numbers)
(esh-worker-test/map-lines/numeric-conversion)
(esh-worker-test/apply-lines/eshell-one-line)
(esh-worker-test/apply-lines/eshell-multiple-lines)
(esh-worker-test/apply-lines/external-one-line)
(esh-worker-test/apply-lines/external-multiple-lines)
(esh-worker-test/apply-lines/numbers)
(esh-worker-test/apply-lines/numeric-conversion): New tests.
2026-05-25 17:20:19 -07:00
Jim Porter
751dccb17e Add basic support in Eshell for piping to Lisp commands
* lisp/eshell/esh-worker.el:
* test/lisp/eshell/esh-worker-tests.el: New files.

* lisp/eshell/esh-cmd.el (eshell-lisp-command): Call 'eshell-get-pipe'
when the command is a pipe target.

* lisp/eshell/em-basic.el (eshell/echo): Mark as producing literal
results.
2026-05-25 17:20:19 -07:00
Jim Porter
be067246af Add some initial generic functions to support Eshell tasks
* lisp/eshell/esh-util.el (eshell-task-p, eshell-task-status)
(eshell-task-active-p): New generic functions.
(eshell-process-list-p): Obsolete in favor of...
(eshell-task-list-p): ... this.  Update callers.
(eshell-make-process-list): Obsolete in favor of...
(eshell-make-task-list): ... this.  Update callers.

* lisp/eshell/esh-proc.el (eshell-task-p, eshell-task-status)
(eshell-task-active-p): New functions.
2026-05-24 17:30:19 -07:00
Jim Porter
c58dd07fc1 Add 'eshell-convert-args' utility function
* lisp/eshell/esh-cmd.el (eshell-lisp-command): Extract from here...
* lisp/eshell/esh-util.el (eshell-convert-args): ... to this new
function.
2026-05-24 17:30:19 -07:00
Jim Porter
47cda4ecac Allow writing a lambda function as a command in Eshell
* lisp/eshell/esh-cmd.el (eshell-lisp-command): Don't try to call a
literal lambda.

* test/lisp/eshell/esh-cmd-tests.el (esh-cmd-test/literal-lambda): New
test.
2026-05-24 17:30:19 -07:00
Pip Cet
b72dcebdab Avoid crash in self-insert-command with non-ASCII auto-fill
* src/cmds.c (internal_self_insert): If the autofill function changed
the newline character we inserted, don't attempt to restore point.
* test/src/cmds-tests.el (self-insert-nonascii-autofill): New.
2026-05-24 12:32:28 +00:00
Pip Cet
7f8ac8bf6f Avoid crash in self-insert-command for peculiar arguments
* src/cmds.c (internal_self_insert): Don't call auto-fill-function
after inserting zero newlines.
* test/src/cmds-tests.el (self-insert-zero-newlines): New.
2026-05-24 11:51:38 +00:00
Pip Cet
94dbab2fe4 Fix 'do_casify_natnum' for events with all flags set
* src/casefiddle.c (do_casify_natnum): Extend range a little, to cover
character events with all modifier flags set.
* test/src/casefiddle-tests.el (casefiddle-allflags): New test.
2026-05-24 10:11:33 +00:00
Pip Cet
c146e3643c Fix off-by-one error in 'styled_format'
This would (rarely) result in composition properties being shared
across the concatenation of two copies of a string.

* src/editfns.c (styled_format): Include the first argument in the
range.
* test/src/editfns-tests.el (editfns-tests--format-composition-property):
New.
2026-05-24 09:23:05 +00:00
Yuan Fu
6932c940fd
Fold calls to fix_position into treesit_check_position (bug#80830)
* src/treesit.c (treesit_check_position): Return the validated
value.
(Ftreesit_node_first_child_for_pos):
(Ftreesit_node_descendant_for_range):
(Ftreesit_query_capture):
(Ftreesit__linecol_at): Fold calls to fix_position into
treesit_check_position in treesit.c.
2026-05-23 22:55:31 -07:00
Paul Eggert
e7a333f18e EVENT_INIT via a compound literal
This pacifies GCC 16.1.1 x86-64 -Warray-bounds when compiling with
-fsanitize=address.  It’s also cleaner on more-typical platforms.
* src/termhooks.h (EVENT_INIT): Define via a compound literal
rather than via a memset plus an assignment.  This evaluates the
argument lvalue only once, and is more likely to catch type errors.
2026-05-23 19:18:54 -07:00
Paul Eggert
7bfde4d50b sfnt.c eassert vs assert
Use eassert uniformly, instead of assert.
* src/sfnt.c [!TEST]: Do not include <assert.h> or use assert.
(eassert) [TEST]: New macro.
2026-05-23 19:18:54 -07:00
Paul Eggert
c4e20777c2 Better size overflow checking for sfnt.c
* src/sfnt.c (memory_full_up) [TEST]: New static function.
(xmalloc, xcalloc, xrealloc): Use it instead of aborting.
(eassert) [TEST]: Remove; no longer needed.
(xaddmalloc, xaddrealloc): New static convenience functions.
(sfnt_read_cmap_format_12, sfnt_read_loca_table_short)
(sfnt_read_loca_table_long, sfnt_read_glyf_table)
(sfnt_read_simple_glyph, sfnt_read_compound_glyph)
(sfnt_read_glyph, sfnt_build_append, sfnt_build_outline_edges)
(sfnt_raster_glyph_outline, sfnt_build_outline_fedges)
(sfnt_raster_glyph_outline_exact, sfnt_read_hmtx_table)
(sfnt_read_name_table, sfnt_read_meta_table)
(sfnt_read_ttc_header, sfnt_read_fpgm_table)
(sfnt_read_prep_table, sfnt_create_uvs_context)
(sfnt_read_gvar_table, sfnt_read_packed_deltas)
(sfnt_vary_simple_glyph, sfnt_vary_compound_glyph):
Use the new functions to test for size overflow more reliably.
Use a cleaner way to decide whether a pointer addresses
the heap not the stack and thus needs freeing.
Fix a few more unlikely overflows.
(sfnt_read_cmap_format_12): The recently-added eassert is no
longer needed, so remove it.
(sfnt_read_simple_glyph): Initialize glyph->simple early
to simplify later code, as is done in similar functions.
Complicate size test to avoid potential unsigned overflow.
2026-05-23 19:18:54 -07:00
Paul Eggert
7e0d4fae01 Simplify sfnt.c by using long long
Even the earliest Android had plain ‘long long’,
so use that instead of doing it by hand.
* src/sfnt.c (struct sfnt_large_integer, sfnt_multiply_divide_1)
(sfnt_multiply_divide_2, sfnt_large_integer_add)
(sfnt_multiply_divide_round) [!INT64_MAX]: Remove.
(sfnt_multiply_divide, sfnt_multiply_divide_rounded)
(sfnt_mul_fixed, sfnt_mul_fixed_round, sfnt_div_fixed)
(sfnt_div_f26dot6, sfnt_mul_f26dot6, sfnt_mul_f26dot6_round)
(sfnt_mul_f2dot14, sfnt_dot_fix_14): Simplify by using long long.
2026-05-23 19:18:54 -07:00
Paul Eggert
2e91ed5f12 Prefer ptrdiff_t to size_t when either will do
Signed types are a bit safer, as they avoid some comparison confusion
and -fsanitize=undefined can check more misuses of them.
* src/alloc.c (lisp_malloc, lisp_align_malloc)
(allocate_string_data, allocate_vector_from_block, object_bytes):
* src/coding.c (from_unicode_buffer):
* src/decompress.c (acc_size, accumulate_and_process_md5):
* src/emacs.c (load_seccomp, shut_down_emacs):
* src/fns.c (sxhash_bignum):
* src/ftfont.c (get_adstyle_property):
* src/image.c (lookup_image, xpm_init_color_cache)
(xpm_cache_color):
* src/json.c (json_out_str, struct json_parser)
(json_make_object_workspace_for_slow_path)
(json_make_object_workspace_for, json_parse_array)
(json_parse_object):
* src/sysdep.c (get_current_dir_name_or_unreachable)
(init_sys_modes, convert_speed):
* src/termchar.h (struct tty_display_info):
* src/textconv.h (struct textconv_conversion_text):
* src/xfns.c (struct x_xim_text_conversion_data)
(x_encode_xim_text):
* src/xselect.c (struct transfer, c_size_for_format)
(x_size_for_format, selection_data_for_offset)
(selection_data_size, x_start_selection_transfer)
(x_continue_selection_transfer):
Prefer ptrdiff_t to size_t when either will do.
* src/term.c (Ftty__set_output_buffer_size):
Limit output buffer size to PTRDIFF_MAX as well as to SIZE_MAX.
2026-05-23 19:18:53 -07:00
Paul Eggert
82ad01b631 Fix format typos in never-executed textconv.c
* src/textconv.c (really_commit_text, really_replace_text):
Use %td not %zd.
2026-05-23 19:18:53 -07:00
Paul Eggert
fbd2f781b2 Be more careful about X selection sizes
* src/xselect.c (selection_data_for_offset):
Offset is size_t, not long, since that’s what caller passes.
(selection_data_size): Truncate large selection sizes to a value
that is more likely to work without involving undefined behavior.
Do not exceed X_ULONG_MAX which is all X can handle, or
PTRDIFF_MAX which can confuse underlying code.
(x_start_selection_transfer): Invoke selection_data_size just once.
2026-05-23 19:18:53 -07:00
Paul Eggert
1bee33c1c8 sfnt_parse_languages does not need USE_SAFE_ALLOCA
* src/sfntfont.c (sfnt_parse_languages):
Simplify so that no local array is needed.
2026-05-23 19:18:53 -07:00
Paul Eggert
ece22174e5 Omit useless android_get_image casts
* src/android.c (android_get_image):
Omit useless and confusing casts.
2026-05-23 19:18:53 -07:00
Paul Eggert
4e5103a980 Document PTRDIFF_MAX <= SIZE_MAX assumption
* src/alloc.c: New static_assert.
2026-05-23 19:18:53 -07:00
Paul Eggert
d12e8a94f7 Update src/alloc.c comments 2026-05-23 19:18:53 -07:00
Paul Eggert
19264b6912 adjust_glyph_matrix reallocation improvement
* src/dispnew.c (adjust_glyph_matrix):
Use xfree + xcalloc instead of xnrealloc + memset,
as there is no need to preserve the old contents.
2026-05-23 19:18:53 -07:00
Paul Eggert
64eb869b68 Be more careful about size multiplication
* src/alloc.c (xcalloc): New function.
* src/dispnew.c (save_current_matrix):
* src/fns.c (Finternal__hash_table_histogram):
* src/nsfns.m (Fns_display_monitor_attributes_list):
* src/pgtkfns.c (Fpgtk_display_monitor_attributes_list):
* src/pgtkselect.c (pgtk_own_selection):
* src/profiler.c (make_log):
* src/sfnt.c (sfnt_poly_edges_exact):
* src/xfns.c (x_get_monitor_attributes_xinerama)
(x_get_monitor_attributes_xrandr, Fx_display_monitor_attributes_list):
Use it instead of multiplying by hand, conceivably with overflow.
* src/profiler.c (make_log):
Check for overflow in internal size calculations.
Use xnmalloc instead of multiply + xmalloc.
* src/sfnt.c (xzalloc) [TEST]: Remove, replacing with ...
(xicalloc) [TEST]: ... this new function.  All callers changed.
(eassert) [TEST]: New macro.
* src/treesit.c (treesit_calloc_wrapper): Remove, replacing its
use with xcalloc.
2026-05-23 19:18:53 -07:00
Paul Eggert
c72e6cdc46 Avoid memsets in coding.c
* src/coding.c (detect_coding_utf_16, Fset_coding_system_priority):
Rewrite memset to initializers.
2026-05-23 19:18:53 -07:00
Paul Eggert
ced12fa114 Avoid memsets in charset.c
* src/charset.c (load_charset_map_from_file)
(load_charset_map_from_vector, Fdefine_charset_internal):
Rewrite memset to xzalloc or initializers.
2026-05-23 19:18:53 -07:00
Paul Eggert
42a8e12088 Avoid memsets in atimer.c
* src/atimer.c (start_atimer, turn_on_atimers):
Rewrite memset+assignments to xzalloc or initializers.
2026-05-23 19:18:53 -07:00
Paul Eggert
52ccc1b8d3 Avoid memsets in pop.c
* lib-src/pop.c (socket_connection):
Rewrite memset+assignments to designated initializers.
2026-05-23 19:18:53 -07:00
Paul Eggert
17215532dc Avoid a memset in emacsclient get_server_config
* lib-src/emacsclient.c (get_server_config):
Rewrite memset+assignments to compound literal.
2026-05-23 19:18:53 -07:00
Paul Eggert
ad8af430e6 Avoid a memset in alloc-colors.c
* admin/alloc-colors.c (main): Simplify.
2026-05-23 19:18:53 -07:00
Paul Eggert
8c69ba718e Fix emit_static_object comment (no bzero call) 2026-05-23 19:18:53 -07:00
Paul Eggert
1e0b0bed28 Avoid a memset in allocate_widget_instance
* lwlib/lwlib.c (allocate_widget_instance):
Simplify via xzalloc.
2026-05-23 19:18:53 -07:00
Paul Eggert
3461b450c5 Don’t silently truncate file names in exec.c
* exec/exec.c (format_pid): Simplify.  No need for a local array.
(exec_0): Shrink local buffer.
If names are too long, fail instead of silently truncating them.
Be cautious in case symlink is zero length (shouldn’t be possible
in Android, but it’s easy to be safe).
2026-05-23 19:18:53 -07:00
Paul Eggert
25a07c30e5 Don’t use VLA in etags.c mercury_decl
* lib-src/etags.c (mercury_decl): Don’t use a VLA,
as C11+ says VLAs are optional.  Instead, redo to
omit the need for an array at all.
2026-05-23 19:18:53 -07:00
Paul Eggert
b1d338d89a Fix misleading x_dnd_begin_drag_and_drop API
* src/xterm.c (x_dnd_begin_drag_and_drop): The n_ask_actions arg
is an int, not a size_t, as XChangeProperty supports only int and
our caller passes an int.
2026-05-23 19:18:53 -07:00
Paul Eggert
4d85084509 Fix unlikely json.c size overflow calculations
* src/json.c (json_out_grow_buf)
(json_make_object_workspace_for_slow_path)
(json_byte_workspace_put_slow_path):
Use xpalloc rather than doing it by hand.
* src/json.c (json_out_grow_buf):
Change arg from needed bytes to minimum increment of bytes.
Caller changed.
2026-05-23 19:18:52 -07:00
Paul Eggert
5fd1e0bbef Coalesce load_seccomp comparisons
* src/emacs.c (load_seccomp): One comparison, not two.
2026-05-23 19:18:52 -07:00
Paul Eggert
9851c5ea34 Shrink STRING_BYTES_MAX slightly
* src/alloc.c (STRING_BYTES_MAX): Also don’t allow sizes to exceed
PTRDIFF_MAX in internal calculations when calling malloc, as those
are problematic even if the final number of bytes does not exceed
PTRDIFF_MAX.
2026-05-23 19:18:52 -07:00
Paul Eggert
59b2f8f1dc Plug default_PATH memory leak
* src/emacs.c (default_PATH): Fix very-unlikely memory leak.
2026-05-23 19:18:52 -07:00
Paul Eggert
1eb2e052bb New function memory_full_up
* src/alloc.c (memory_full_up): New function.  Replace all callers
of memory_full (SIZE_MAX) with callers to this function.
This simplifies callers and should make future changes easier.
It also saves a whopping 296 bytes in executable size
with gcc 16.1.1 20260515 (Red Hat 16.1.1-2) x86-64.
2026-05-23 19:18:52 -07:00
Sean Whitton
a96fc7d546 Merge from origin/emacs-31
4f13f52a3a * build-aux/git-hooks/commit-msg: Replace Markdown-style ...
dd42133315 vc-test--rename-file: Disable part of test for SCCS
eb653865c3 markdown-ts-mode: Don't enable unconditionally by default

# Conflicts:
#	etc/NEWS
2026-05-23 17:30:21 +01:00
Sean Whitton
4f13f52a3a * build-aux/git-hooks/commit-msg: Replace Markdown-style quotation. 2026-05-23 17:25:07 +01:00
Sean Whitton
dd42133315 vc-test--rename-file: Disable part of test for SCCS
* test/lisp/vc/vc-tests/vc-tests.el (vc-test--rename-file):
Disable part of test for SCCS.
2026-05-23 16:53:36 +01:00
Rahul Martim Juliato
eb653865c3 markdown-ts-mode: Don't enable unconditionally by default
* lisp/textmodes/markdown-ts-mode.el (markdown-ts-mode-maybe):
New function.
(auto-mode-alist): Bind ".md", ".markdown", and ".mdx" to
'markdown-ts-mode-maybe' instead of 'markdown-ts-mode'.
* etc/NEWS: Update the 'markdown-ts-mode' entry.
2026-05-23 16:25:09 +01:00
Sean Whitton
7fe595465b vc-refresh-state: Use cond*
This is okay with regard to bootstrapping because vc-hooks.el is
loaded after loaddefs.el in loadup.el.

* lisp/emacs-lisp/cond-star.el (cl-lib): Don't require, so we
can use cond* in preloaded files.
(cond*-convert-condition): Replace calls to cl-assert.
* lisp/vc/vc-hooks.el (vc-refresh-state): Use cond*.
2026-05-23 12:47:24 +01:00
Eli Zaretskii
ccc94458fb Merge from origin/emacs-31
7a17f97baa Prettify special glyphs
f13287fde0 Revert "sh-script: Mark + and * as punctuation rather tha...
70b79b3ed8 Rename `icalendar-recur' type and related functions
3d2bb233f2 ; Minor Tramp changes
f6281d757d ; * etc/NEWS: Tell how to disable 'markdown-ts-mode'.
142b1e0d4c Fix Lisp injection via X-Draft-From in Gnus
d6f7b2d99b Save/restore old_buffer slot via window configurations (B...
e0fbecaf65 Adapt ert-remote-temporary-file-directory settings
3de7f0ce5e Fix warning message in 'markdown-ts-mode--initialize'
7df8604ea6 ; Improve documentation of lazy-highlight in search and r...
2936b36164 Fix "assertion 'GTK_IS_WINDOW (window)' failed"
98348a0bdc [Xt] Fix child frame resizing glitch
13b29eebc1 Eglot: use standard face for completion annotations (bug#...

# Conflicts:
#	etc/NEWS
2026-05-23 07:23:33 -04:00
Manuel Giraud
7a17f97baa Prettify special glyphs
* lisp/disp-table.el (prettify-special-glyphs-mode): New mode to
display nicer special glyphs.
(special-glyphs): New face for displaying special glyphs when
the minor mode is active.
(prettify-special-glyphs-saved-truncation)
(prettify-special-glyphs-saved-continuation): Internal variables
to save previous special glyphs.
* etc/NEWS: Announce the change.  (Bug#80628)
2026-05-23 14:12:19 +03:00
Elias Gabriel Perez
741feca497 New tool bar icons for artist-mode
* etc/images/artist-mode/README:
* etc/images/artist-mode/char-for-spray.xpm:
* etc/images/artist-mode/char-to-fill.xpm:
* etc/images/artist-mode/ellipse.xpm:
* etc/images/artist-mode/eraser.xpm:
* etc/images/artist-mode/fill.xpm:
* etc/images/artist-mode/line.xpm:
* etc/images/artist-mode/pen.xpm:
* etc/images/artist-mode/poly-line.xpm:
* etc/images/artist-mode/rectangle.xpm:
* etc/images/artist-mode/spray.xpm:
* etc/images/artist-mode/square.xpm:
* etc/images/artist-mode/text.xpm:
* etc/images/artist-mode/char-for-spray.pbm:
* etc/images/artist-mode/char-to-fill.pbm:
* etc/images/artist-mode/ellipse.pbm:
* etc/images/artist-mode/eraser.pbm:
* etc/images/artist-mode/fill.pbm:
* etc/images/artist-mode/line.pbm:
* etc/images/artist-mode/pen.pbm:
* etc/images/artist-mode/poly-line.pbm:
* etc/images/artist-mode/rectangle.pbm:
* etc/images/artist-mode/spray.pbm:
* etc/images/artist-mode/square.pbm:
* etc/images/artist-mode/text.pbm: New files.
* lisp/textmodes/artist.el (artist-tool-bar-map): New variable.
(artist-mode, artist-mode-exit): Use it (bug#80644).
2026-05-23 11:50:10 +01:00
Eli Zaretskii
f13287fde0 Revert "sh-script: Mark + and * as punctuation rather than a symbol constituent"
This reverts commit b3c0aee42b.
It caused regressions in 'sh-script', see bug#80794 and
bug#80854.
2026-05-23 13:27:49 +03:00
Richard Lawrence
70b79b3ed8 Rename `icalendar-recur' type and related functions
More context in Bug#80786 and:
https://lists.gnu.org/archive/html/emacs-orgmode/2026-03/msg00286.html

`icalendar-recur' as a type name for RRULE values was confusing and made
the accessors for this type difficult to discover, because `icalendar-recur-'
is also used as a prefix in icalendar-recur.el.  This change renames the
`icalendar-recur' type to `icalendar-rrule-value' and renames the
accessor functions for these values appropriately.

* lisp/calendar/icalendar-parser.el:  Rename symbols as follows:
(icalendar-recur): `icalendar-rrule-value'
(icalendar-read-recur-rule-part): `icalendar-read-rrule-part'
(icalendar-print-recur-rule-part): `icalendar-print-rrule-part'
(icalendar-recur-rule-part): `icalendar-rrule-part'
(icalendar-read-recur): `icalendar-read-rrule-value'
(icalendar-print-recur): `icalendar-print-rrule-value'
(icalendar--recur-value-types): `icalendar--rrule-value-types'
(icalendar-recur-value-p): `icalendar-rrule-value-p'
(icalendar-recur-freq): `icalendar-rrule-freq'
(icalendar-recur-interval-size): `icalendar-rrule-interval-size'
(icalendar-recur-until): `icalendar-rrule-until'
(icalendar-recur-count): `icalendar-rrule-count'
(icalendar-recur-weekstart): `icalendar-rrule-weekstart'
(icalendar-recur-by*): `icalendar-rrule-by*'.
(icalendar-rrule):
(icalendar-index-insert):
(icalendar-index-get): Update references.
* lisp/calendar/icalendar-recur.el (icalendar-recur-find-interval):
(icalendar-recur-nth-interval):
(icalendar-recur-next-interval):
(icalendar-recur-previous-interval):
(icalendar-recur-refine-from-clauses):
(icalendar-recur-recurrences-in-interval):
(icalendar-recur-recurrences-in-window):
(icalendar-recur-recurrences-to-count):
(icalendar-recur-tz-observance-on): Update references.
* lisp/calendar/diary-icalendar.el: Update references.
* lisp/calendar/icalendar-shortdoc.el (icalendar): Update shortdoc examples.
* lisp/gnus/gnus-icalendar.el: Update references.
* test/lisp/calendar/diary-icalendar-tests.el:
* test/lisp/calendar/icalendar-parser-tests.el:
* test/lisp/calendar/icalendar-recur-tests.el: Update references in tests.
2026-05-23 13:25:19 +03:00