aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Don’t stuff keyboard input uselesslyPaul Eggert10 days1-1/+1
| | | | | | | 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.
* Show a message in locked frames in single-kboard modeSean Whitton10 days1-0/+2
| | | | | | | | | | | | | | | | * 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.
* Compare circular lists in 'equal' without error (bug#80456)Mattias Engdegård2026-02-241-9/+18
| | | | | | | | | | | | | | | | | | * 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.
* Stop ENUM_BF worrying about gcc -std=c89 -pedanticPaul Eggert2026-02-211-4/+4
| | | | | | | * 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.
* Port Lisp_Fwd to strict C bitfieldsPaul Eggert2026-02-211-2/+2
| | | | | | | | 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.
* * src/lisp.h (struct Lisp_Fwd): Add comments.Helmut Eller2026-02-121-5/+5
|
* Move the Lisp_Fwd.bufoffset field back to the unionHelmut Eller2026-02-121-3/+6
| | | | | | | | * src/lisp.h (struct Lisp_Fwd): With the predicate enum, we can now pack the offset and the predicate into a one-word struct. (XBUFFER_OFFSET): Use the new field name. * src/buffer.c (DEFVAR_PER_BUFFER): Create the one-word struct. * src/data.c (store_symval_forwarding): Use the new field name.
* Introduce an enum Lisp_Fwd_PredicateHelmut Eller2026-02-121-4/+13
| | | | | | | | | | | | Using an enum instead of a symbol makes it obvious that this field is of no concern to the GC. * src/lisp.h (enum Lisp_Fwd_Predicate): New. (struct Lisp_Fwd): Use it instead of a symbol. * src/buffer.c (DEFVAR_PER_BUFFER): Create the necessary enum constant instead of a symbol. * src/data.c (check_fwd_predicate, check_choice): New helpers. (store_symval_forwarding): Use it.
* Remove struct Lisp_Buffer_ObjfwdHelmut Eller2026-02-121-14/+16
| | | | | | | | | | | | | | * src/lisp.h (struct Lisp_Buffer_Objfwd): Deleted. (struct Lisp_Fwd): Add the fields bufoffset and bufpredicate. Make the type a 1-byte bitfield so that the entire struct still fits in two words. (XBUFFER_OFFSET): Renamed from XBUFFER_OBJFWD. * src/buffer.c (DEFVAR_PER_BUFFER, defvar_per_buffer) (buffer_local_value): Update accordingly. * src/data.c (do_symval_forwarding, store_symval_forwarding) (set_internal, default_value, set_default_internal) (Fmake_local_variable, Fkill_local_variable, Flocal_variable_): Use XBUFFER_OFFSET.
* Remove struct Lisp_Kboard_ObjfwdHelmut Eller2026-02-121-13/+4
| | | | | | | | | * src/lisp.h (struct Lisp_Kboard_Objfwd): Deleted ... (struct Lisp_Fwd): ... replaced with field kbdoffset. (DEFVAR_KBOARD): Use new field. * src/data.c (XKBOARD_OFFSET): Renamed from XKBOARD_OBJFWD. (do_symval_forwarding, store_symval_forwarding (set_default_internal): Use it .
* Remove struct Lisp_ObjfwdHelmut Eller2026-02-121-17/+8
| | | | | | | | | | * src/lisp.h (struct Lisp_Objfwd): Deleted. (struct Lisp_Fwd): Replace it with objvar field. (DEFVAR_LISP, DEFVAR_LISP_NOPRO, DEFVAR_LISP_NOPROX): Use the field. * src/lread.c (defvar_lisp): Updated as needed. * src/pdumper.c (dump_field_fwd): Use the field. * src/data.c (XOBJVAR): Renamed and updated from XOBJFWD. (do_symval_forwarding, store_symval_forwarding): Use it.
* Remove struct Lisp_BoolfwdHelmut Eller2026-02-121-11/+2
| | | | | | | | | * src/lisp.h (struct Lisp Boolfwd): Deleted (struct Lisp_Fwd): Replaced it with a boolvar field. (DEFVAR_BOOL): Update. * src/data.c (XBOOLVAR): Renamed from XBOOLFWD. (do_symval_forwarding, store_symval_forwarding): Use it. * src/pdumper.c (dump_field_fwd): Use boolvar field.
* Remove struct Lisp_IntfwdHelmut Eller2026-02-121-16/+6
| | | | | | | | | | It was a struct with a single field. * src/lisp.h (struct Lisp_Intfwd): Deleted. (struct Lisp_Fwd): Add an intvar field instead. (DEFVAR_INT): Update accordingly. * src/data.c (XINTVAR): Updated and renamed from XFIXNUMFWD. (do_symval_forwarding, store_symval_forwarding): Use it.
* Introduce a struct Lisp_FwdHelmut Eller2026-02-121-42/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This contains the type and an union of Lisp_Objfwd, Lisp_Intfwd etc. lispfwd is now a pointer to a struct Lisp_Fwd; the void *fwdptr field is gone. * src/lisp.h (struct Lisp_Fwd): New. (Lisp_Intfwd, Lisp_Boolfwd, Lisp_Objfwd, Lisp_Buffer_Objfwd) (Lisp_Kboard_Objfwd): The type is in in Lisp_Fwd. (lispwfd): Is now a pointer to struct Lisp_Fwd. (SYMBOL_BLV, SET_SYMBOL_FWD, XFWDTYPE, BUFFER_OBJFWDP): Update accordingly. (defvar_lisp, defvar_lisp_nopro, defvar_bool, defvar_int) (defvar_kboard): These all take now a Lisp_Fwd. (DEFVAR_LISP, DEFVAR_LISP_NOPRO, DEFVAR_BOOL, DEFVAR_INT) (DEFVAR_KBOARD): Update for new types. * src/lread.c (defvar_int, defvar_bool, defvar_lisp_nopro) (defvar_lisp, defvar_kboard): Update for new types. * src/pdumper.c (dump_field_fwd, dump_blv): Update accordingly. (dump_fwd_int, dump_fwd_bool, dump_fwd_obj, dump_fwd_buffer_obj) (dump_fwd): Deleted. * src/buffer.c (DEFVAR_PER_BUFFER, defvar_per_buffer, buffer_local_value) (set_buffer_internal_1): Update accordingly for new types. * src/data.c (XBOOLFWD, XKBOARD_OBJFWD, XFIXNUMFWD, XOBJFWD, boundp) (store_symval_forwarding, swap_in_global_binding) (swap_in_symval_forwarding, find_symbol_value, set_internal) (default_value, set_default_internal, make_blv, Fmake_local_variable): Update accordingly.
* Fix crash where dead frame remains on list of live frames (Bug#80120)Martin Rudalics2026-01-111-0/+1
| | | | | | | * src/fns.c (delq_no_quit): New function. * src/lisp.h: Extern delq_no_quit. * src/frame.c (delete_frame): Call delq_no_quit to remove frame from Vframe_list uninterruptedly (Bug#80120).
* ; Add 2026 to copyright years.Sean Whitton2026-01-011-1/+1
|
* Revert to simpler (and we hope faster) TAGGEDPPaul Eggert2025-12-191-8/+2
| | | | | | | | | | | | | | | | | Suggested by Mattias Engdegård (bug#80021#17). * src/lisp.h (lisp_h_FIXNUMP, lisp_h_TAGGEDP): Go back to the simpler (X&7) == TAG approach for checking object tags. This reverses my commit ccdb08ef4ed8f96e79aa06cf5e806c9c487d58ad “Improve performance of CONSP, FIXNUMP, etc.” dated 2018-08-25 13:39:18 -0700, though it keeps the TAGGEDP function the older commit introduced. Although the older commit improved performance on its circa 2010 platform, when I ran today’s ‘make -C lisp compile-always’ benchmark on Ubuntu 25.10 which uses gcc (Ubuntu 15.2.0-4ubuntu4) on an circa-2021 Intel Xeon W-1350, this patch makes the ‘make -C lisp compile-always’ benchmark 3.1% faster. Although the patch unfortunately also makes the Emacs text segment 0.6% larger, in this case speed and simplicity beat text size in importance.
* Fix some C symbol extern visibilityPaul Eggert2025-12-081-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make some C symbols static if they don’t need to be extern. Also, remove a couple of functions that were discovered to be unused as a result of this process, and mark two extern functions intended to be usable from GDB. * src/buffer.c (previous_overlay_change): * src/composite.c (composition_lisp_table): * src/fileio.c (file_name_directory): * src/frame.c (check_tty): * src/insdel.c (adjust_markers_for_insert): * src/keyboard.c (unread_switch_frame, read_char) (requeued_events_pending_p): * src/sysdep.c (renameat_noreplace) [!HAVE_ANDROID]: * src/textconv.c (get_conversion_field) [!HAVE_ANDROID]: * src/treesit.c (TREESIT_BOB_LINECOL, TREESIT_TS_POINT_1_0) (treesit_buf_tracks_linecol_p, make_treesit_parser) (make_treesit_node): * src/xdisp.c (x_y_to_hpos_vpos): * src/xfaces.c (load_color) [!MSDOS]: * src/xfns.c (x_real_pos_and_offsets): * src/xterm.c (x_dnd_do_unsupported_drop): Now static. Move up if necessary. * src/coding.c (utf8_string_p): * src/keyboard.c (detect_input_pending_ignore_squeezables): Remove; unused. * src/frame.c (gui_set_alpha): * src/textconv.c (start_batch_edit, end_batch_edit, commit_text) (finish_composing_text, set_composing_text) (set_composing_region, textconv_set_point_and_mark) (delete_surrounding_text, request_point_update) (textconv_barrier, replace_text, get_extracted_text) (get_surrounding_text): * src/xdisp.c (gui_union_rectangles): * src/xterm.c (xi_frame_selected_for): Define only if needed. * src/treesit.c (treesit_debug_print_parser_list) (treesit_debug_print_linecol): Declare EXTERNALLY_VISIBLE. * src/xdisp.c (x_y_to_column_row): New function, defined only if needed. All external callers to x_y_to_hpos_vpos changed.
* Align config.h better to src/lisp.hPaul Eggert2025-12-071-20/+11
| | | | | | | | | | | | | | | | | This is mostly a cleanup patch to fix growing discrepancies between src/lisp.h and configure.ac in terms of how they deduce how EMACS_INT aligns. The patch includes a static check that the two methods now agree. It also speeds up ‘configure’ a bit. * configure.ac (ALIGNOF_INT, ALIGNOF_LONG, ALIGNOF_LONG_LONG): Remove; no longer used. (ALIGNOF_EMACS_INT): New macro. (system_malloc): Set to 'no' more consistently with what’s in src/lisp.h. * src/lisp.h (ALIGNOF_EMACS_INT): Do not define here, as config.h defines it now. Check that config.h’s definition equals the actual alignof (EMACS_INT). (USE_USB_TAG): Set more consistently with what’s in configure.ac. (alignas): Don’t second-guess Gnulib.
* Work around a bug in GCC 14 i386 C23 alignasPaul Eggert2025-11-271-7/+11
| | | | | | | | | Problem reported by Helmut Eller (bug#79886). * src/lisp.h (USE_LSB_TAG): Adjust to alignas changes. (alignas): For GCC and Clang, prefer __attribute__ ((__aligned__ (A))) to alignas (A) even if the compiler claims to support the latter. This works around a bug in GCC 14 i386 C23 alignas. No need to worry about whether __alignas_is_defined is defined.
* A few more functions are not purePaul Eggert2025-11-201-5/+5
| | | | | | | | | | | | | | | | | Assuming ATTRIBUTE_PURE means that the function must return, a few more functions that should not be declared with ATTRIBUTE_PURE. The GCC manual (and even the C23 standard, with [[reproducible]]) is not clear about this, and it’s better to be safe. * src/bignum.h (mpz_get_d_rounded): * src/lisp.h (bignum_to_double): No longer pure, as it does not return if memory is exhausted. * src/fns.c (Fproper_list_p): No longer pure, as it does not return if the user quits. * src/gnutls.c (Fgnutls_errorp): No longer pure, as it does not return if it runs into an eassert failure in XSYMBOL_WITH_POS via EQ. * src/lisp.h (bignum_to_intmax, bignum_to_uintmax, bignum_bufsize): No longer pure, as it does not return if it runs into an eassert failure in XBIGNUM via xbignum_val.
* Fix mis-declarations of non-const functionsPaul Eggert2025-11-191-4/+4
| | | | | | | | | | | | | | | | | | | | | | Problem for mpz_get_d_rounded reported by Helmut Eller in: https://lists.gnu.org/r/emacs-devel/2025-11/msg00795.html * lib-src/make-docfile.c (DEFUN_pure): New constant. (write_globals, scan_c_stream): Support "attributes: pure". * src/bignum.h (mpz_get_d_rounded): * src/data.c (Fsymbolp, Fmodule_function_p, Fintegerp, Fnumberp): * src/lisp.h (bignum_to_double, bignum_to_intmax) (bignum_to_uintmax, bignum_bufsize): Now pure, not const, since they depend on current state. For example, Fsymbolp now inspects symbols_with_pos_enabled, and the bignum functions inspect bignum contents in memory. * src/data.c (Feq): * src/xfaces.c (Fface_attribute_relative_p): No longer const, since they might abort when debugging. * src/pdumper.h (pdumper_object_p, pdumper_cold_object_p) (pdumper_find_object_type, pdumper_object_p_precise): These are not const functions. But there is no need to declare them to be pure, either, as they’re inline so the compiler can figure it out.
* Avoid extra newline in user-error logged in *Messages*Eli Zaretskii2025-11-151-0/+1
| | | | | | | | * src/xdisp.c (reset_message_log_need_newline): New function. * src/lisp.h: Add prototype of 'reset_message_log_need_newline'. * src/print.c (print_error_message): Call 'reset_message_log_need_newline' to prevent message3 from outputting a newline after "user-error:". (Bug#79840)
* ; * src/lisp.h (MAX_ALLOCA): Comment on enlarging the value.Eli Zaretskii2025-10-311-1/+15
|
* ; * src/lisp.h (struct Lisp_String): mention terminating NULMattias Engdegård2025-10-221-0/+3
|
* Don't feed the stack overflow detector bad dataMattias Engdegård2025-10-201-1/+1
| | | | | | | * src/lisp.h (record_in_backtrace): Don't record the argument address as stack_top because most of the time it won't be on the C stack at all. * src/eval.c (eval_sub): Do it here instead using an address guaranteed to be on the C stack and we are just in the Lisp interpreter anyway.
* * Make sure the compiler optimizes for symbols_with_pos_enabled 0 in EQAndrea Corallo2025-09-221-1/+1
| | | | * src/lisp.h (EQ): Make use '__builtin_expect'.
* Change EQ to move slow code path into a separate functionPip Cet2025-09-221-4/+7
| | | | | * src/data.c (slow_eq): New function. * src/lisp.h (EQ): Call it.
* ; * src/lisp.h (enum handlertype): Comment accuracy.Mattias Engdegård2025-09-171-1/+1
|
* Disallow string data resizing (bug#79784)Mattias Engdegård2025-08-241-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Only allow string mutation that is certain not to require string data to be resized and reallocated: writing bytes into a unibyte string, and changing ASCII to ASCII in a multibyte string. This ensures that mutation will never transform a unibyte string to multibyte, that the size of a string in bytes never changes, and that the byte offsets of characters remain the same. Most importantly, it removes a long-standing obstacle to reform of string representation and allow for future performance improvements. * src/data.c (Faset): Disallow resizing string mutation. * src/fns.c (clear_string_char_byte_cache): * src/alloc.c (resize_string_data): Remove. * test/src/data-tests.el (data-aset-string): New test. * test/lisp/subr-tests.el (subr--subst-char-in-string): Skip error cases. * test/src/alloc-tests.el (aset-nbytes-change): Remove test that is no longer relevant. * doc/lispref/strings.texi (Modifying Strings): * doc/lispref/sequences.texi (Array Functions): * doc/lispref/text.texi (Substitution): Update manual. * etc/NEWS: Announce.
* Port better to Linux with 1 MiB pagesPaul Eggert2025-08-021-11/+1
| | | | | | * src/lisp.h: Include <sys-limits.h>. (MAX_RW_COUNT): Remove, as it is the same thing as sys-limits.h’s SYS_BUFSIZE_MAX. All uses replaced by SYS_BUFSIZE_MAX.
* Refactor to allow nameless auto stringsPaul Eggert2025-07-241-3/+15
| | | | | | | * src/lisp.h (AUTO_STR, AUTO_STR_WITH_LEN): New macros. Long ago this sort of thing would have been a no-no because we needed to GCPRO the strings. However, GCPRO went away a decade ago.
* Refactor by coalescing MAX_RW_COUNT definitionsPaul Eggert2025-07-211-0/+11
| | | | | | | | * src/emacs.c (read_full): Simplify by assuming MAX_RW_COUNT is defined. * src/lisp.h (MAX_RW_COUNT): Move here from src/sysdep.c. * src/pdumper.c (dump_read_all): Use MAX_RW_COUNT rather than defining our own equivalent.
* ; Avoid compiler warnings in MinGW buildsEli Zaretskii2025-06-011-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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)
* New top-level buffer-local value functionsSean Whitton2025-05-151-1/+2
| | | | | | | | | | | | | | | * src/eval.c (local_toplevel_binding) (Fbuffer_local_toplevel_value, Fset_buffer_local_toplevel_value) (syms_of_eval): New functions. * doc/lispref/variables.texi (Default Value): * lisp/subr.el (setq-local): * etc/NEWS: Document them. * test/lisp/emacs-lisp/lisp-tests.el (core-elisp-tests-4-toplevel-values): New test. * lisp/progmodes/xref.el (xref--show-xref-buffer) (xref-show-definitions-buffer-at-bottom): * lisp/vc/vc-dispatcher.el (vc-setup-buffer): Use set-buffer-local-toplevel-value.
* Add line-column tracking for tree-sitterYuan Fu2025-05-031-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add line-column tracking for tree-sitter parsers. Copied from comments in treesit.c: Technically we had to send tree-sitter the line and column position of each edit. But in practice we just send it dummy values, because tree-sitter doesn't use it for parsing and mostly just carries the line and column positions around and return it when e.g. reporting node positions[1]. This has been working fine until we encountered grammars that actually utilizes the line and column information for parsing (Haskell)[2]. [1] https://github.com/tree-sitter/tree-sitter/issues/445 [2] https://github.com/tree-sitter/tree-sitter/issues/4001 So now we have to keep track of line and column positions and pass valid values to tree-sitter. (It adds quite some complexity, but only linearly; one can ignore all the linecol stuff when trying to understand treesit code and then come back to it later.) Eli convinced me to disable tracking by default, and only enable it for languages that needs it. So the buffer starts out not tracking linecol. And when a parser is created, if the language is in treesit-languages-require-line-column-tracking, we enable tracking in the buffer, and enable tracking for the parser. To simplify things, once a buffer starts tracking linecol, it never disables tracking, even if parsers that need tracking are all deleted; and for parsers, tracking is determined at creation time, if it starts out tracking/non-tracking, it stays that way, regardless of later changes to treesit-languages-require-line-column-tracking. To make calculating line/column positons fast, we store linecol caches for begv, point, and zv in the buffer (buf->ts_linecol_cache_xxx); and in the parser object, we store linecol cache for visible beg/end of that parser. In buffer editing functions, we need the linecol for start/old_end/new_end, those can be calculated by scanning newlines (treesit_linecol_of_pos) from the buffer point cache, which should be always near the point. And we usually set the calculated linecol of new_end back to the buffer point cache. We also need to calculate linecol for the visible_beg/end for each parser, and linecol for the buffer's begv/zv, these positions are usually far from point, so we have caches for all of them (in either the parser object or the buffer). These positions are far from point, so it's inefficient to scan newlines from point to there to get up-to-date linecol for them; but in the same time, because they're far and outside the changed region, we can calculate their change in line and column number by simply counting how much newlines are added/removed in the changed region (compute_new_linecol_by_change). * doc/lispref/parsing.texi (Using Parser): Mention line-column tracking in manual. * etc/NEWS: Add news. * lisp/treesit.el: (treesit-languages-need-line-column-tracking): New variable. * src/buffer.c: Include treesit.h (for TREESIT_EMPTY_LINECOL). (Fget_buffer_create): (Fmake_indirect_buffer): Initialize new buffer fields. (Fbuffer_swap_text): Add new buffer fields. * src/buffer.h (ts_linecol): New struct. (buffer): New buffer fields. (BUF_TS_LINECOL_BEGV): (BUF_TS_LINECOL_POINT): (BUF_TS_LINECOL_ZV): (SET_BUF_TS_LINECOL_BEGV): (SET_BUF_TS_LINECOL_POINT): (SET_BUF_TS_LINECOL_ZV): New inline functions. * src/casefiddle.c (casify_region): Record linecol info. * src/editfns.c (Fsubst_char_in_region): (Ftranslate_region_internal): (Ftranspose_regions): Record linecol info. * src/insdel.c (insert_1_both): (insert_from_string_1): (insert_from_gap_1): (insert_from_buffer): (replace_range): (del_range_2): Record linecol info. * src/treesit.c (TREESIT_BOB_LINECOL): (TREESIT_EMPTY_LINECOL): (TREESIT_TS_POINT_1_0): New constants. (treesit_debug_print_linecol): (treesit_buf_tracks_linecol_p): (restore_restriction_and_selective_display): (treesit_count_lines): (treesit_debug_validate_linecol): (treesit_linecol_of_pos): (treesit_make_ts_point): (Ftreesit_tracking_line_column_p): (Ftreesit_parser_tracking_line_column_p): New functions. (treesit_tree_edit_1): Accept real TSPoint and pass to tree-sitter. (compute_new_linecol_by_change): New function. (treesit_record_change_1): Rename from treesit_record_change, handle linecol if tracking is enabled. (treesit_linecol_maybe): New function. (treesit_record_change): New wrapper around treesit_record_change_1 that handles some boilerplate and sets buffer state. (treesit_sync_visible_region): Handle linecol if tracking is enabled. (make_treesit_parser): Setup parser's linecol cache if tracking is enabled. (Ftreesit_parser_create): Enable tracking if the parser's language requires it. (Ftreesit__linecol_at): (Ftreesit__linecol_cache_set): (Ftreesit__linecol_cache): New functions for debugging and testing. (syms_of_treesit): New variable Vtreesit_languages_require_line_column_tracking. * src/treesit.h (Lisp_TS_Parser): New fields. (TREESIT_BOB_LINECOL): (TREESIT_EMPTY_LINECOL): New constants. * test/src/treesit-tests.el (treesit-linecol-basic): (treesit-linecol-search-back-across-newline): (treesit-linecol-col-same-line): (treesit-linecol-enable-disable): New tests. * src/lisp.h: Declare display_count_lines. * src/xdisp.c (display_count_lines): Remove static keyword.
* Avoid name clashes with static GnuTLSPaul Eggert2025-04-191-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Work around a bug in GnuTLS 3.7.11 and earlier: when built statically, its mistakenly exports symbols hash_lookup and hash_string, which collide with Emacs symbols of the same name, preventing temacs from linking statically. Problem reported by Greg A. Woods (Bug#77476). Because GnuTLS never uses hash_lookup or hash_string this issue ordinarily doesn’t seem to prevent temacs from linking to GnuTLS on GNU/Linux, as it’s linked dynamically and the dynamic linker never needs to resolve references to either symbol. However, I suppose a clash or bug could occur even with dynamic linking if Emacs later loads a module that uses either symbol. Although GnuTLS should be fixed, Emacs should link statically to current and older GnuTLS versions in the meantime, and it should avoid potential problems with dynamic linking. Renaming the two clashing names is an easy way to do this. For consistency with the new name for hash_lookup, also rename hash_lookup_with_hash and hash_lookup_get_hash. * src/fns.c (hash_find_with_hash): Rename from hash_lookup_with_hash. (hash_find): Rename from hash_lookup. (hash_find_get_hash): Rename from hash_lookup_get_hash. (hash_char_array): Rename from hash_string. All uses changed.
* Use a pristine copy of argv to restart EmacsJens Schmidt2025-04-131-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | argv as left after main has proccessed the command-line can differ both in order and contents of the original command-line arguments, which can lead to surprising results when restarting emacs on the cooked argv through `kill-emacs'. Starting from that observation, consistenly use variables 'initial_cmdline' on Windows, 'initial_argc', 'initial_argv' on non-Windows, and 'initial_argv0' in all ports. * src/lisp.h: Declare 'initial_argv0', limit declaration of 'initial_argv' and 'initial_argc' to non-Windows ports. * src/emacs.c: Likewise, but for the definitions. (init_cmdargs): Move initialization of 'initial_argv' and 'initial_argc' ... (copy_args) [!WINDOWSNT]: ... to this new function ... (main): ... and call that in 'main', also initializing 'initial_argv0' before the command-line processing. * src/emacs.c (Fkill_emacs): * src/pgtkterm.c (pgtk_term_init): * src/sysdep.c (emacs_perror): * src/xterm.c (x_term_init): Use 'initial_argv0' where only that is required. (Bug#77389)
* ; Correct typos in commentary and error messagesPo Lu2025-03-101-2/+2
| | | | | | | * src/lisp.h (USE_LSB_TAG): * src/pdumper.c (pdumper_load): Correct typos in commentary and error messages.
* Re-port to 32-bit systems without alignment primitivesPo Lu2025-03-091-9/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac (ALIGNOF_INT, ALIGNOF_LONG, ALIGNOF_LONG_LONG): New variables. (emacs_cv_alignas_unavailable): Define if alignas and structure alignment primitives are unavailable. In such an environment, the MSB tagging scheme must be enabled, as must the GNU malloc. * msdos/sed2v2.inp: Adjust correspondingly. * src/alloc.c (union emacs_align_type): Remove types which contain flexible array members. The address of a field subsequent to an aggregate with flexible array members cannot validly be taken. (mark_memory) [!USE_LSB_TAG && !WIDE_EMACS_INT]: Strip type bits before scanning memory. * src/emacs.c (main): * src/eval.c (Fautoload_do_load): * src/fns.c (Frequire): Rename a number of illogically named fields. * src/lisp.h (ALIGNOF_EMACS_INT): Define to the natural alignment of EMACS_INT. (IDEAL_GCALIGNMENT): New macro. (USE_LSB_TAG): Disable if no alignment specifiers are available, WIDE_EMACS_INT is undefined, and the natural alignment of EMACS_INT falls short of LSB tagging's requirements. (gflags): Rename illogically named fields and don't define them as bitfields, which runs afoul of certain compiler issues. (will_dump_p, will_bootstrap_p, will_dump_with_pdumper_p) (dumped_with_pdumper_p): Adjust accordingly. * src/pdumper.c (VM_SUPPORTED): Define to 0 when !USE_LSB_TAG. It is better to read dump files into the heap by hand than to be supplied with an address that is not representable. (_dump_object_start_pseudovector): Rename to dump_object_start_pseudovector, to avoid encroaching on reserved names. (START_DUMP_PVEC): Adjust correspondingly. (dump_mmap_contiguous_vm): Preserve errno around failure cleanup. (dump_bitset_bit_set_p): Work around certain compiler issues. (pdumper_load) [!USE_LSB_TAG]: Reject dump file allocations that are not representable as Lisp_Objects. Tested on i386-unknown-solaris2.10, sparc-sun-solaris2.10.
* (replace_range): Delete argument `markers`Stefan Monnier2025-03-061-2/+1
| | | | | | | | * src/lisp.h (replace_range): * src/insdel.c (replace_range): Delete argument `markers`, always true. * src/editfns.c (Ftranslate_region_internal): * src/cmds.c (internal_self_insert): * src/search.c (Freplace_match): Adjust callers accordingly.
* Make Emacs buildable with -std=c11.Philipp Stephani2025-03-041-1/+1
| | | | | | | | | With -std=c11, GCC doesn't recognize 'asm' as a keyword, see https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html and https://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html. Use __asm__ instead. * src/lisp.h (flush_stack_call_func): Use __asm__ instead of asm.
* Port to modern GCC and pdumper on MS-DOSPo Lu2025-02-201-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * config.bat (mvOk): Protoize. (djgppOk): Include sys/version.h for _DJGPP_MINOR. * lisp/loadup.el: If system-type is ms-dos, dump bootstrap-emacs as b-emacs.dmp. * msdos/INSTALL: Document new versions of tools that have been verified successfully to compile Emacs. * msdos/emacs.djl: New linker script that arranges to link symbols in `.subrs' in a contiguous part of data, as the DJGPP runtime appears to treat any non-data and non-text section as allocatable. * msdos/mainmake.v2 (install): Install emacs.dmp alongside emacs.exe. * msdos/sed1v2.inp (CFLAGS): Define to -O2 -g3. (LDFLAGS): Provide the said linker script. (HAVE_PDUMPER): Define to yes. (UNEXEC_OBJ, PAXCTL_dumped, PAXCTL_notdumped): Delete. (DUMPING): Set to pdumper. (MAKE_PDUMPER_FINGERPRINT): Don't erase this variable. Don't stubify or set minstack. Remove native-comp specific directives. Don't remove temacs prior to copying and replace `pdmp' extension with DOS-conformant `dmp'. * msdos/sed2v2.inp (HAVE_UNEXEC): Remove definition. (HAVE_PDUMPER): Define to 1. * msdos/sed6.inp (top_srcdir): Define appropriately. * msdos/sedlibmk.inp (HAVE_BLKCNT_T): Define to 1. * src/emacs.c (load_pdump) [MSDOS]: Use `dmp' suffix. * src/pdumper.c (Fdump_emacs_portable) [MSDOS]: Replace ".pdmp" suffixes with ".dmp".
* (replace_range): Delete last arg, always the negation of the first boolStefan Monnier2025-02-181-1/+1
| | | | | | | | | * src/insdel.c (replace_range): Merge last arg, with `prepare`. Rename `prepare` to `run-mode-hooks`. * src/lisp.h (replace_range): Adjust accordingly. * src/editfns.c (Ftranslate_region_internal): * src/cmds.c (internal_self_insert): * src/search.c (Freplace_match): Adjust callers.
* Improve malloc Lisp alignment commentaryPaul Eggert2025-02-011-1/+1
| | | | Prompted by a private email from Pip Cet.
* Merge branch 'scratch/no-purespace' into 'master'Stefan Kangas2025-02-011-124/+11
|\
| * Fix define_error docstring for pure space removalStefan Kangas2025-01-081-2/+1
| | | | | | | | * src/lisp.h (define_error): Adjust docstring for pure space removal.
| * Remove unused function my_heap_startStefan Kangas2024-12-121-1/+0
| | | | | | | | | | * src/alloc.c (my_heap_start) [DOUG_LEA_MALLOC && GNU_LINUX]: Remove unused function. Update callers.
| * Pure storage removal: Adjust nativecomp codePip Cet2024-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/comp.el (comp-curr-allocation-class, comp-ctxt) (comp--emit-for-top-level, comp--emit-lambda-for-top-level) (comp--finalize-relocs): Remove 'd-impure' allocation class. * src/comp.c (PURE_RELOC_SYM, DATA_RELOC_IMPURE_SYM) (TEXT_DATA_RELOC_IMPURE_SYM): Remove definitions. (comp_t): Remove 'pure_ptr', 'check_impure', 'data_relocs_impure', 'd_impure_idx'. (helper_link_table): Remove 'pure_write_error'. (obj_to_reloc): Adjust to removal of 'data_relocs_impure'. (emit_PURE_P): Remove function. (declare_imported_data, declare_runtime_imported_funcs) (emit_ctxt_code): Adjust to removed fields. (define_setcar_setcdr): Don't call 'CHECK_IMPURE'. (define_CHECK_IMPURE): Remove function. (Fcomp__compile_ctxt_to_file0, check_comp_unit_relocs, load_comp_unit) (Fcomp__register_lambda): Adjust to removed allocation class 'd-impure'. (syms_of_comp): Don't define 'd-impure'. * src/comp.h (struct Lisp_Native_Comp_Unit): Drop support for allocation class 'd-impure'. * src/lisp.h (allocate_native_comp_unit): * src/pdumper.c (dump_do_dump_relocation): Adjust to struct change.
| * Pure storage removal: Remove purecopy hash table flagPip Cet2024-12-121-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/emacs-liqsp/comp.el (comp--jump-table-optimizable): Adjust comment. * src/category.c (hash_get_category_set): * src/emacs-module.c (syms_of_module): * src/fns.c (make_hash_table): Remove 'purecopy' flag and update docstring. (Fmake_hash_table): Ignore ':purecopy' argument. * src/frame.c (make_frame): * src/image.c (xpm_make_color_table_h): * src/lisp.h (struct Lisp_Hash_Table): Drop 'purecopy' flag. * src/pdumper.c (dump_hash_table): Don't dump 'purecopy' flag. * src/print.c (print_object): Don't print 'purecopy' flag * src/json.c (json_parse_object): * src/lread.c (readevalloop, read_internal_start): * src/pgtkterm.c (syms_of_pgtkterm): * src/profiler.c (export_log): * src/xfaces.c (syms_of_xfaces): * src/xterm.c (syms_of_xterm): Adjust calls to 'make_hash_table'.