summaryrefslogtreecommitdiff
path: root/src/editfns.c
AgeCommit message (Collapse)Author
2026-05-26ARRAYELTS → countofPaul Eggert
C2y will standardize countof as the macro that Emacs uses the name ARRAYELTS for. Switch to the standard name, which is supported by GCC 16+, by Clang 21, and by the Gnulib stdcountof-h module already in use for compilers that do not support countof. Also, use countof in a few places where we missed using ARRAYELTS. * admin/coccinelle/arrayelts.cocci: Suggest countof, not ARRAYELTS. * admin/merge-gnulib (GNULIB_MODULES): Add stdcountof-h, as it is now a direct rather than an indirect dependency. * exec/trace.c, src/lisp.h, src/sfnt.c: Include <stdcountof.h>. (ARRAYELTS): Remove. All uses replaced by countof. * lib-src/ebrowse.c, lib-src/etags.c, lib-src/make-docfile.c: * lib-src/seccomp-filter.c, lwlib/lwlib-Xaw.c: Prefer <stdcountof.h> and countof to doing things by hand.
2026-05-24Fix off-by-one error in 'styled_format'Pip Cet
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-23New function memory_full_upPaul Eggert
* 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-17Make styled_format more compatible with igcPaul Eggert
* src/editfns.c (styled_format): Don’t call SAFE_ALLOCA_LISP_EXTRA, as this makes life more difficult in the feature/igc3 branch. Also, allocate another byte for the format string trailing '\0', so that we don’t rely in the str2num trick with trailing '\1'. Problems reported by Pip Cet (Bug#81057#32). Also, check alloca size more exactly. Ameliorate the extra conditional branches by doing all the internal size calculations before a conditional branch on overflow.
2026-05-17Shrink styled_format's frame quite a bitPaul Eggert
Problem reported by Helmut Eller (Bug#81057). On x86-64 this patch shrinks USEFUL_PRECISION_MAX from 16382 to 1074, SPRINTF_BUFSIZE from 21318 to 1386, and sizeof initial_buffer from 22318 to 2386. This also fixes a problem reported privately by Pip Cet: exactly formatting the smallest positive IEEE double 2**-1074 with %f needs %.1074f and 1074 is DBL_MANT_DIG - DBL_MIN_EXP, not merely 1 - DBL_MIN_EXP. * src/editfns.c (USEFUL_PRECISION_MAX, SPRINTF_BUFSIZE): Base these on double, not long double, since long double is not the worst case (it is used only for converted u?intmax_t). (USEFUL_PRECISION_MAX): Add DBL_MANT_DIG - 1 as per Pip Cet.
2026-05-17Grow styled_format's frame somewhatPaul Eggert
* src/editfns.c (styled_format): Don’t subtract sizeof initial_buffer from sa_avail (bug#81057).
2026-05-17Streamline styled_format aux allocationPaul Eggert
* src/editfns.c (styled_format): Streamline allocation of auxiliary tables, by allocating them all in one go rather than via separate alloca / mallocs.
2026-01-01; Add 2026 to copyright years.Sean Whitton
2025-12-26December 2025 spelling fixesPaul Eggert
Some of the fixes are to continue to use American rather than British spelling. * doc/misc/modus-themes.org (my-modus-themes-engraved-faces): Fix misspelled ‘:foreground’s. * etc/themes/modus-themes.el (modus-themes-faces): Fix misspelled ‘modus-themes-bold’. * lisp/emacs-lisp/rx.el (rx--normalize-char-pattern): Rename from rx--normalise-char-pattern. (rx--optimize-or-args): Rename from rx--optimise-or-args. * lisp/frame.el (frame--special-parameters): Fix misspelled "right-divider-width". * lisp/net/tramp.el (tramp-fingerprint-prompt-regexp): Use American spelling “centered”, to match current libfprintf. * lisp/org/org-fold-core.el (org-fold-core--optimize-for-huge-buffers): Rename from org-fold-core--optimise-for-huge-buffers. (org-fold-core-update-optimization): Rename from org-fold-core-update-optimisation, leaving an alias behind. (org-fold-core-remove-optimization): Rename from org-fold-core-remove-optimisation, leaving an alias behind. * lisp/org/org.el (org-advertized-archive-subtree): This alias is now obsolete. * lisp/play/zone.el (zone-ignored-buffers): Fix misspelling of ‘zone--buffer-encrypted-p’. * lisp/progmodes/csharp-mode.el (csharp-ts-mode-faces): Fix misspelling of ‘csharp’ group. * lisp/vc/vc.el (vc-clonable-backends-custom-type): Rename from vc-cloneable-backends-custom-type, leaving an alias behind. * test/lisp/emacs-lisp/bytecomp-tests.el: (bytecomp-tests--warn-arity-non-compiled-callee): Rename from bytecomp-tests--warn-arity-noncompiled-callee. (bytecomp-test-defface-spec): Reword a deliberate misspelling of “default” that is so common I don’t want it to pollute the spelling dictionary. * test/lisp/emacs-lisp/package-vc-tests.el: (package-vc-tests-preserve-artifacts): Rename from package-vc-tests-preserve-artifacts. * test/lisp/eshell/em-prompt-tests.el: (em-prompt-test/forward-backward-paragraph-1): Reword a deliberate misspelling of “goodbye” that is so common I don’t want it to pollute the spelling dictionary.
2025-12-22; * src/editfns.c (styled_format): fix build for C99 compilersMattias Engdegård
2025-12-22Simplify new %b/%B code many years from nowPaul Eggert
* src/editfns.c (styled_format): Do %b and %B with sprintf if sprintf is known to support them. This will let us simplify this code many years from now. (Bug#79990)
2025-12-22Add binary format specifications '%b' and '%B'Jacob S. Gordon
These produce the binary representation of a number. '%#b' and '%#B' prefix with '0b' and '0B', respectively. (bug#79990) * etc/NEWS: Announce change. * doc/lispref/strings.texi (Formatting Strings): Describe new format specs and add to comment on reconstructing the value with 'read'. * src/editfns.c (format): Update doc string. (styled_format): Add support for '%b' and '%B'. To remain portable, avoid use of 'sprintf' by converting by hand. * test/src/editfns-tests.el (format-binary-zero, format-binary-floats) (format-binary-nonzero-integers): Add tests. (read-large-integer): Add binary test cases. Co-authored-by: Paul Eggert <eggert@cs.ucla.edu>
2025-12-21Remove binary-as-unsigned (bug#79990)Paul Eggert
This experimental variable caused more trouble than it cured: it was rarely used, and when used it tended to be used incorrectly. * src/editfns.c (binary-as-unsigned): Remove. All uses removed.
2025-12-20Improve handling of non-ASCII characters in 'transpose-regions'Jens Schmidt
* src/editfns.c (Ftranspose_regions): Separate code related to character semantics from that related to byte semantics and in that way leverage optimizations for regions of equal length with respect to both semantics. Move and update comments dating back to the initial implementation. * test/src/editfns-tests.el (editfns-tests--transpose-regions-tests) (editfns-tests--transpose-regions-markups) (editfns-tests--transpose-regions): New test and accompanying variables.
2025-12-20Fix byte-vs-char length issue in 'transpose-regions'Jens Schmidt
* src/editfns.c (Ftranspose_regions): Calculate length of range between regions both in units of bytes and characters and use these values as appropriate.
2025-11-08; Fix doc strings of the various 'insert-*' functionsEli Zaretskii
* src/editfns.c (Finsert_before_markers) (Finsert_and_inherit_before_markers, Finsert_char, Finsert_byte) (Finsert_buffer_substring): Clarify the effect on markers. (Bug#79692)
2025-10-11Merge from origin/emacs-30Eli Zaretskii
1895ba3ba3b ; Document %i format 85db0ac0d6e ; * doc/lispref/nonascii.texi (Explicit Encoding): Fix a ... c119a3600ed ; * doc/lispref/tips.texi (Documentation Tips): Document ... Also fix trailing whitespace in test files.
2025-10-11; Document %i formatEli Zaretskii
* src/editfns.c (Fformat): Doc fix. * doc/lispref/strings.texi (Formatting Strings): Document %i.
2025-09-13Merge from origin/emacs-30Eli Zaretskii
47454566772 ; * lisp/dired-x.el (dired-find-subdir): Doc fix (bug#794... 0832e5fec56 ; * lisp/vc/vc.el (vc-print-root-log): Improve docstring ... 2fafcdbf6ac ; Minor copyedits in src/editfns.c
2025-09-09; Minor copyedits in src/editfns.cEli Zaretskii
* src/editfns.c (Fbuffer_string, Freplace_buffer_contents) (styled_format): Avoid using non-ASCII characters in doc strings and comments.
2025-07-06(Ftranspose_regions): Fix bug#76124Stefan Monnier
* 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-05-03Add line-column tracking for tree-sitterYuan Fu
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.
2025-04-28Update tree-sitter subroutine in Fsubst_char_in_regionYuan Fu
Some explanation: Fsubst_char_in_region used to have a branch, one branch path calls replace_range, one branch path modifies the buffer directly. replace_range already calls treesit_record_change within it, so we needed to make sure we only call treesit_record_change in the other branch path. After I added the call to treesit_record_change, some changes are made to Fsubst_char_in_region, and the branch was removed. So no wonder Stefan had the confusion and wrote the FIXME note. Now that the branch is gone, we can indeed call treesit_record_change in the end like signal_after_change. * src/editfns.c (Fsubst_char_in_region): Move to end.
2025-04-18Merge from savannah/emacs-30Yuan Fu
01d4eb3dd42 ; Improve doc string of 'insert-char' 93ad8407ed8 * admin/notes/emba: Fix docker build instruction. b901290ae7f * doc/lispref/text.texi (Margins): Grammar fix. 16855c89dde Merge branch 'emacs-30' of git.savannah.gnu.org:/srv/git/... 8792d3431b1 Backport: Fix tree-sitter tests on Emba # Conflicts: # test/infra/Dockerfile.emba
2025-04-18; Improve doc string of 'insert-char'Eli Zaretskii
* src/editfns.c (Finsert_char): Doc fix. Suggested by Lactose ‎ <lactose@allthingslinux.org> (bug#77889).
2025-04-16(Freplace_region_contents): Treat point as insert-before markerStefan Monnier
Experience suggests that it's more often useful to keep point at the end of the replacement than it is to keep point at the beginning of the replacement. This also aligns the behavior of `replace-region-contents` with that of `insert`. * src/insdel.c (replace_range): Treat PT like an insert-before marker. * src/editfns.c (Freplace_region_contents): Adjust docstring accordingly.
2025-04-13; * src/editfns.c (Freplace_region_contents): Doc fix (bug#76313).Eli Zaretskii
2025-04-12(replace-buffer-contents): Mark as obsolete, again.Stefan Monnier
* lisp/subr.el (replace-buffer-contents): Mark as obsolete, again. * src/editfns.c (Freplace_region_contents): Add interactive form.
2025-04-07(Freplace_region_contents): Fix point preservation (bug#77607)Stefan Monnier
* src/editfns.c (Freplace_region_contents): Save excursion around temporary restriction (bug#77607) and remove `record_unwind_protect_excursion` made redundant by commit 40d8650d5177.
2025-04-05Merge from origin/emacs-30Eli Zaretskii
38fec86281e ; Improve the documentation of 'slice' display spec (bug#... 3f05b455f7e ; * src/editfns.c (Fmessage): Mention 'inhibit-message' (...
2025-04-02Pacify gcc -Wclobbered in Freplace_region_contentsPaul Eggert
* src/editfns.c (Freplace_region_contents): Redo slightly to pacify gcc -Wclobbered, by hoisting the eassume out of SCHARS and into the caller later, where it’ll do more good anyway.
2025-03-30; * src/editfns.c (Fmessage): Mention 'inhibit-message' (bug#77257).Eli Zaretskii
2025-03-29(replace-region-contents): Improve and promote (bug#76313)Stefan Monnier
Swap the role of `replace-region-contents` and `replace-buffer-contents`, so `replace-region-contents` is the main function, implemented in C, and `replace-buffer-contents` is a mere wrapper (marked as obsolete). Also remove the need to rely on narrowing and on describing the new text as a function. Finally, allow MAX-SECS==0 to require a cheap replacement, and add an INHERIT argument. * src/editfns.c: Include `coding.h`. (Freplace_region_contents): Rename from `Freplace_buffer_contents`. Change calling convention to that of `replace-region-contents`. Add more options for the SOURCE argument. Add INHERIT argument. Skip the costly algorithm if MAX-SECS is 0. * src/insdel.c (replace_range): Allow NEW to be a buffer. * lisp/subr.el (replace-buffer-contents): New implementation. * lisp/emacs-lisp/subr-x.el (replace-region-contents): Delete. * doc/lispref/text.texi (Replacing): Document new API for `replace-region-contents`. Remove documentation of `replace-buffer-contents`. * test/src/editfns-tests.el (replace-buffer-contents-1) (replace-buffer-contents-2, replace-buffer-contents-bug31837): Use `replace-region-contents`. (editfns--replace-region): Delete. (editfns-tests--replace-region): Use `replace-region-contents`. Adds tests for new types of SOURCE args.
2025-03-11(Freplace_buffer_contents): Preserve markers more carefullyStefan Monnier
Use `replace_range` rather than `delete+insert`. * src/insdel.c (replace_range): Allow NEW to specify a chunk of buffer text. * src/editfns.c (Freplace_buffer_contents): Use it. * test/src/editfns-tests.el (replace-buffer-contents-1): Remove incorrect check which happened to succeed because point was not preserved carefully enough. Make the replacement text share a bit more content to make the test a bit more strict. (editfns-tests--replace-region): Doesn't fail any more.
2025-03-06(replace_range): Delete argument `markers`Stefan Monnier
* 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.
2025-02-28* test/src/editfns-tests.el (editfns--replace-region): New testStefan Monnier
This test fails, sadly, because `replace-buffer-contents` is not careful enough to something like `replace_range`.
2025-02-23(Ftranspose_regions): Fix text-properties for len1==len2Stefan Monnier
When `len1_byte == len2_byte`, the code presumed that len1==len2 as well in its handling of text-properties. Fix that case. While at it, try and reduce code duplication by hoisting common code out of `if`s, and throw away the optimization for `len_mid == 0` which only saved 3 trivial function calls. * src/editfns.c (Ftranspose_regions): Shuffle the code a bit. * test/src/editfns-tests.el (editfns-tests--transpose-equal-but-not): New test.
2025-02-18(replace_range): Delete last arg, always the negation of the first boolStefan Monnier
* 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.
2025-02-18* src/editfns.c (Fsubst_char_in_region): Delete left-over codeStefan Monnier
This code was missed back in 2000 (commit 1b16afa45bb6).
2025-02-03Fix GC-related crashes in styled_format (bug#75754)Pip Cet
This approach ensures we don't use an SSDATA pointer after GC, and that no Lisp callback code can modify the format string while we're working on it. * src/editfns.c (styled_format): Operate on a copy of the format string rather than the original. Ensure final NUL byte is copied.
2025-01-23Fix GC bug causing incorrect 'format' output (Bug#75754)Pip Cet
This fixes the correctness bug discovered in bug#75754, but not the performance issue or excessive stack usage. * src/editfns.c (styled_format): Split 'info' array into two arrays, one of them allocated via SAFE_ALLOCA_LISP for GC protection.
2025-01-04Merge from origin/emacs-30Eli Zaretskii
6468c3f7a74 Update doc string of 'insert' 6d8c3c0cbe4 Use `keymap*-set' over `global-set-key'/`define-key' in e... 4b2bb63b7ac Fix documentation and prompt in 'package-isolate' 55f43f5b220 ; Fix typo in treesit-explore-mode 921f454f508 Update fontification for attribute values in heex-ts-mode ae2589ea7a5 Add expression handling to heex-ts-mode 0cacf806391 ; * etc/NEWS: Document change of 'make-cursor-line-fully-... f47a29da5c4 * lisp/man.el (Man-mode): Improve docstring. # Conflicts: # etc/NEWS
2025-01-04Update doc string of 'insert'Ulrich Müller
* src/editfns.c (Finsert): Mention 'decode-coding-string' instead of the obsolete 'string-as-multibyte' in doc string. (Bug#75345)
2025-01-02Update copyright year to 2025Stefan Kangas
Run "TZ=UTC0 admin/update-copyright".
2025-01-01Update copyright year to 2025Paul Eggert
Run "TZ=UTC0 admin/update-copyright".
2024-08-22Prefer static_assert to verifyStefan Kangas
Although static_assert is C11-specific, and Emacs remains on C99, it has been backported to older compilers by Gnulib. Gnulib has already changed to prefer static_assert, and we can do the same. * lib-src/asset-directory-tool.c (main_2): * src/alloc.c (BLOCK_ALIGN, aligned_alloc, lisp_align_malloc) (vectorlike_nbytes, allocate_pseudovector): * src/android.c (android_globalize_reference, android_set_dashes): * src/android.h: * src/androidfont.c (androidfont_draw, androidfont_text_extents): * src/androidvfs.c: * src/bidi.c (BIDI_CACHE_MAX_ELTS_PER_SLOT, bidi_find_bracket_pairs): * src/buffer.c (init_buffer_once): * src/casefiddle.c (do_casify_multibyte_string): * src/dispnew.c (scrolling_window, scrolling): * src/editfns.c (styled_format): * src/emacs-module.c (module_extract_big_integer): * src/fileio.c (Fdo_auto_save): * src/fns.c (next_almost_prime, hash_string): * src/fringe.c (init_fringe): * src/keyboard.h (kbd_buffer_store_event_hold): * src/keymap.c: * src/lisp.h (memclear, reduce_emacs_uint_to_hash_hash, modiff_incr): * src/lread.c (skip_lazy_string): * src/pdumper.c (dump_bignum, Fdump_emacs_portable) (dump_do_dump_relocation, pdumper_load): * src/process.c (make_process, Fmake_process, connect_network_socket): * src/regex-emacs.c: * src/sort.c (tim_sort): * src/sysdep.c (init_random, SSIZE_MAX): * src/thread.c: * src/timefns.c (trillion_factor): * src/unexelf.c: * src/xterm.c (x_send_scroll_bar_event): Prefer static_assert to Gnulib verify. Remove import of verify.h, except when used for other reasons.
2024-05-17Port to certain Android environments with no GUIPo Lu
* configure.ac (USER_FULL_NAME): Define to android_user_full_name only when a GUI system is being built. Otherwise, set to pw->pw_gecos or NULL consistently with the presence of pw->pw_gecos. * src/editfns.c (Fuser_full_name): Adjust to match. Accept NULL values from USER_FULL_NAME.
2024-04-29Take fields into account during text conversionPo Lu
* lisp/cus-edit.el (Custom-mode): Enable text conversion, now that fields are correctly treated. * src/alloc.c (mark_frame): Mark f->conversion.field. * src/androidterm.c (android_update_selection): Adjust conversion region and selection position by the field start and end. * src/editfns.c (find_field): Export function. * src/frame.c (make_frame): Clear f->conversion.field. * src/frame.h (struct text_conversion_state) <field>: New field. * src/lisp.h (find_fields, reset_frame_conversion): Export functions. * src/minibuf.c (Fread_from_minibuffer): Reset frame conversion if Voverriding_text_conversion_style is set. * src/textconv.c (textconv_query): Narrow to field. (reset_frame_conversion): New function. (reset_frame_state): Clear conversion field. (really_delete_surrounding_text): Narrow to field. (locate_and_save_position_in_field): New function. (really_request_point_update, really_set_point_and_mark) (complete_edit_check, handle_pending_conversion_events_1) (handle_pending_conversion_events, get_conversion_field) (set_composing_region, textconv_set_point_and_mark, replace_text) (get_extracted_text, get_surrounding_text, report_point_change): Compute, narrow to and offset by the currently active field whenever point is updated or a command is received. (syms_of_textconv): Revise doc strings. * src/textconv.h (get_conversion_field): Export function.
2024-02-24* src/editfns.c (Fget_pos_property): Fix thinko (bug#69358)Stefan Monnier
2024-02-05Prefer `ITREE_FOREACH` over `overlays_in`Stefan Monnier
Use `ITREE_FOREACH` instead of `overlays_in` if that can save us from allocating an array. * src/buffer.c (overlays_in): Mark as static. (mouse_face_overlay_overlaps): Use `ITREE_FOREACH` instead of `overlays_in`. (disable_line_numbers_overlay_at_eob): Same, and also change return value to a boolean. * src/buffer.h (overlays_in): Don't declare. * src/editfns.c (overlays_around): Delete function. (Fget_pos_property): Use `ITREE_FOREACH` and keep the "best so far" instead of using `overlays_in` and sorting the elements. * src/lisp.h (disable_line_numbers_overlay_at_eob): Change return type to a boolean. * src/xdisp.c (should_produce_line_number): Adjust accordingly.