aboutsummaryrefslogtreecommitdiffstats
path: root/src/treesit.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Improve documentation of treesit "thing"Eli Zaretskii2025-06-051-9/+13
| | | | | | | | | | * 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.
* Improve reporting of language-grammar library ABI version mismatchEli Zaretskii2025-05-181-4/+14
| | | | | | | | | * lisp/treesit.el (treesit-ready-p): More accurate wording of message when grammar library fails to load. * src/treesit.c (treesit_load_language): Improve message when reporting library ABI version mismatch. Suggested by Soham Gumaste <sohamg2@gmail.com>.
* Add line-column tracking for tree-sitterYuan Fu2025-05-031-48/+736
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove parent-node field from tree-sitter parsersYuan Fu2025-03-111-32/+0
| | | | | | | * src/treesit.c (make_treesit_parser): Remove field. (Ftreesit_parser_parent_node): (Ftreesit_parser_set_parent_node): Remove * src/treesit.h (Lisp_TS_Parser): Remove field.
* Avoid defining unneeded variables on Cygw32Kazuhiro Ito2025-03-061-1/+1
| | | | | | | | | | | | | | | | | | | | lisp/term/w32-win.el contained definitions of variables which were not used on Cygw32. It is now to split into two files, common part and Windows native build specific part. The latter is a new file, lisp/term/w32-nt.el. * src/image.c (Qlibpng_version, Qlibgif_version) (Qlibjpeg_version): Don't define on Cygw32 build. * src/treesit.c (Qtree_sitter__library_abi): Ditto. * lisp/term/w32-win.el (dynamic-library-alist, libpng-version) (libgif-version, libjpeg-version, libgnutls-version) (tree-sitter--library-abi, gui-backend-set-selection) (gui-backend-get-selection, gui-backend-selection-owner-p) (gui-selection-exists-p): Moved to lisp/term/w32-nt.el. * lisp/term/w32-nt.el: New file, separated Windows native build specific part from lisp/term/w32-win.el. * lisp/loadup.el: Load term/w32-nt.el on Windows native build. (Bug#75926)
* Merge from origin/emacs-30Eli Zaretskii2025-03-011-10/+10
|\ | | | | | | 2dbf7d0b1b2 Use character position for ranges in treesit_sync_visible...
| * Use character position for ranges in treesit_sync_visible_regionYuan Fu2025-02-231-10/+10
| | | | | | | | | | | | * src/treesit.c (treesit_sync_visible_region): Use character position instead of byte position when comparing to ranges, because the ranges are in character position.
| * ; Fix Cygw32 build (bug#75926)Eli Zaretskii2025-01-291-1/+1
| | | | | | | | (cherry picked from commit cb62a47896bb21420a709c655034e8acfcb08082)
| * Update copyright year to 2025Stefan Kangas2025-01-021-1/+1
| | | | | | | | Run "TZ=UTC0 admin/update-copyright".
* | ; Fix documentation of recent treesit changesEli Zaretskii2025-02-281-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | * src/treesit.c (Ftreesit_query_capture) (Ftreesit_parser_embed_level, Ftreesit_parser_set_embed_level) (Ftreesit_parser_set_parent_node): * lisp/treesit.el (treesit-query-range) (treesit-query-range-by-language, treesit-range-settings) (treesit-range-rules, treesit--parser-at-level) (treesit--update-ranges-non-local, treesit--update-ranges-local) (treesit--update-range-1): Fix wording and typos in doc strings. * doc/lispref/parsing.texi (Pattern Matching): Fix wording.
* | Enable treesit-query-capture to return grouped capturesYuan Fu2025-02-271-9/+43
| | | | | | | | | | | | | | | | This is needed for creating embedded parsers for embedded code blocks of which language cannot be known ahead of time. E.g., markdown and org mode's code block. * src/treesit.c (Ftreesit_query_capture): Add parameter GROUPED.
* | Add tree-sitter-parser-embed-level and parent-nodeYuan Fu2025-02-271-0/+69
| | | | | | | | | | | | | | | | | | | | | | | | Add parser properties embed-level and parent-node. They'll be help us implement arbitrarily nested embeded parser, and navigation across embedded and host parsers, respectively. * src/treesit.c: (Ftreesit_parser_embed_level): (Ftreesit_parser_set_embed_level): (Ftreesit_parser_parent_node): (Ftreesit_parser_set_parent_node): New functions.
* | Merge branch 'scratch/no-purespace' into 'master'Stefan Kangas2025-02-011-18/+18
|\ \
| * | Pure storage removal: Replace calls to removed functionsPip Cet2024-12-121-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/alloc.c (string_bytes, pin_string, valid_lisp_object_p) (process_mark_stack, survives_gc_p, syms_of_alloc): * src/androidterm.c (android_term_init): Replace call to 'build_pure_c_string'. * src/buffer.c (init_buffer_once, syms_of_buffer): * src/bytecode.c (exec_byte_code): * src/callint.c (syms_of_callint): * src/callproc.c (syms_of_callproc): * src/category.c (Fdefine_category): * src/coding.c (syms_of_coding): * src/comp.c (Fcomp__compile_ctxt_to_file0) (maybe_defer_native_compilation, syms_of_comp): * src/data.c (Fsetcar, Fsetcdr, Fdefalias, Faset, syms_of_data): * src/dbusbind.c (syms_of_dbusbind): * src/doc.c (Fsnarf_documentation): * src/emacs-module.c (syms_of_module): * src/eval.c (Finternal__define_uninitialized_variable) (Fdefconst_1, define_error, syms_of_eval): * src/fileio.c (syms_of_fileio): * src/fns.c (Ffillarray, Fclear_string, check_mutable_hash_table): * src/fontset.c (syms_of_fontset): * src/frame.c (make_initial_frame): * src/haikufns.c (syms_of_haikufns): * src/intervals.c (create_root_interval): * src/keyboard.c (syms_of_keyboard): * src/keymap.c (Fmake_sparse_keymap, Fset_keymap_parent) (store_in_keymap, syms_of_keymap): * src/lisp.h: * src/lread.c (Fload, read0, intern_c_string_1, define_symbol) (Fintern, defsubr, syms_of_lread): * src/pdumper.c (Fdump_emacs_portable): * src/pgtkfns.c (syms_of_pgtkfns): * src/pgtkterm.c (syms_of_pgtkterm): * src/process.c (syms_of_process): * src/search.c (syms_of_search): * src/sqlite.c (syms_of_sqlite): * src/syntax.c (syms_of_syntax): * src/treesit.c (syms_of_treesit): * src/w32fns.c (syms_of_w32fns): * src/xdisp.c (syms_of_xdisp): * src/xfaces.c (syms_of_xfaces): * src/xfns.c (syms_of_xfns): * src/xftfont.c (syms_of_xftfont): * src/xterm.c (syms_of_xterm): Remove calls to 'PURE_P', 'CHECK_IMPURE', 'Fpurecopy', and replace calls to 'build_pure_c_string', 'pure_list', 'pure_listn', etc., by impure equivalents.
* | | Fix tree-sitter language remappingYuan Fu2025-01-291-18/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/treesit.c (resolve_language_symbol): Move forward. (treesit_ensure_query_compiled): Resolve language remapping here. (Ftreesit_parser_list): Don't resolve language remaping here, because there's no need: parsers now carries the remapped language. (Ftreesit_query_compile): Don't resolve language remapping here, because we resolve language remapping when actually compiling the query. Also we want the query to carry the unmapped language.
* | | ; Fix Cygw32 buildEli Zaretskii2025-01-291-1/+1
| | |
* | | ; Fix last changeEli Zaretskii2025-01-201-3/+3
| | | | | | | | | | | | | | | | | | * src/treesit.c (Ftreesit_parser_create): Fix comment wording. * doc/lispref/parsing.texi (Using Parser): Fix wording and markup.
* | | Make treesit-language-remap-alist completely transparent (bug#72388)Yuan Fu2025-01-191-4/+7
| | | | | | | | | | | | | | | | | | | | | * doc/lispref/parsing.texi (Using Parser): Update manual. * src/treesit.c (Ftreesit_parser_create): Use the LANGUAGE argument given as the language for the parser, not the actual language.
* | | Fix treesit.el testsYuan Fu2025-01-171-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | * lisp/treesit.el (treesit--imenu-merge-entries): (Ftreesit_parser_set_included_ranges): Warn in the docstring that the function is destructive/owns the argument. * test/src/treesit-tests.el (treesit-range-fixup-after-edit): (treesit-imenu): Fix tests.
* | | Remap language symbol in treesit-query-compile (bug#72388)Yuan Fu2025-01-171-1/+4
| | | | | | | | | | | | * src/treesit.c (Ftreesit_query_compile): Use remapped language.
* | | ; Fix wording and coding style of a recent commitEli Zaretskii2025-01-141-6/+2
| | | | | | | | | | | | | | | | | | * src/treesit.c (treesit_traverse_match_predicate): Fix style. * doc/lispref/parsing.texi (User-defined Things): Fix wording.
* | | Prefer calln to CALLN where applicableStefan Kangas2025-01-141-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/callint.c (read_file_name): * src/comp.c (CALL0I, CALL1I, CALL2I, CALL4I, declare_imported_func): * src/data.c (Ffset, notify_variable_watchers): * src/eval.c (Ffuncall_with_delayed_message): * src/keymap.c (Fdescribe_buffer_bindings): * src/minibuf.c (Fread_buffer, Fcompleting_read): * src/pdumper.c (Fdump_emacs_portable): * src/print.c (print_vectorlike_unreadable): * src/treesit.c (treesit_traverse_match_predicate) (treesit_build_sparse_tree): Prefer calln to CALLN.
* | | Add 'and', 'named', and 'anonymous' predicate for tree-sitterYuan Fu2025-01-121-5/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/lispref/parsing.texi (User-defined Things): Mention the new predicate. * src/treesit.c (treesit_traverse_validate_predicate): Recognize named, anonymous, and and predicates. (treesit_traverse_match_predicate): Handle named, anonymous, and and predicates.
* | | Use the treesit thing 'list' with symbol property 'treesit-thing-symbol'Juri Linkov2025-01-101-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/lispref/parsing.texi (User-defined Things): Mention new functions 'treesit-forward-list', 'treesit-down-list', 'treesit-up-list', 'treesit-show-paren-data' that use the thing 'list' with the symbol property 'treesit-thing-symbol' (bug#73404). * lisp/treesit.el: Put the property 'treesit-thing-symbol' on the symbol 'list'. (treesit--forward-list-with-default, treesit-down-list) (treesit-up-list, treesit-navigate-thing) (treesit-show-paren-data--categorize, treesit-major-mode-setup): Replace 'sexp-list' with 'list'. * lisp/progmodes/c-ts-mode.el (c-ts-mode--thing-settings): * lisp/progmodes/js.el (js-ts-mode): * lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode): * lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode) (tsx-ts-mode): * lisp/textmodes/html-ts-mode.el (html-ts-mode): Replace 'sexp-list' with 'list'. * src/treesit.c (treesit_traverse_validate_predicate) (treesit_traverse_match_predicate): Check if the 'pred' symbol has the property 'Qtreesit_thing_symbol'. (syms_of_treesit): New symbol 'Qtreesit_thing_symbol'.
* | | Update copyright year to 2025Paul Eggert2025-01-011-1/+1
| | | | | | | | | | | | Run "TZ=UTC0 admin/update-copyright".
* | | Merge branch 'scratch/tty-child-frames'Gerd Möllmann2024-12-191-1/+1
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for child frames on tty The redisplay part is complete. The frame-handling part supports use-cases like Posframe, Corfu, and child frames acting like tooltips. Other use-cases of child frames are not currently supported. In particular, trying to create minibuffer-only child frames on ttys will signal an error. * src/xfaces.c (free_frame_faces): Change formatting slightly. * src/xdisp.c (redisplay_trace, move_tracxe): Print to stderr because stdout screws up terminal display. (init_iterator): Remove a #ifdef HAVE_WINDOW_SYSTEM. (clear_garbaged_frames): Return a bool telling if we cleared matrix. (echo_area_display): Use combine_updates on tty frames. (redisplay_internal): Changes for redisplay of tty child windows. (deep_copy_glyph_row): Take a frame parameter. (display_tty_menu_item): Changes because of function signature changes. * src/w32term.c (w32_read_socket): Don't use FRAME_OBSCRURED_P, which has been removed. * src/w32inevt.c (do_mouse_event): Workaround for mouse events on child frafmes. * src/w32console.c (w32con_write_glyphs, w32con_update_end): Use glyphs' frame for faces. * src/treesit.c (treesit_load_language): Pacify a warning. * src/w32console.c (w32con_clear_end_of_line): Set glyph's frame. * src/terminal.c (cursor_to, raw_cursor_to): Handle case that frame is a child frame. * src/termhooks.h: Declare formerly static functions. * src/term.c (tty_hide_cursor, tty_show_cursor): Make externally visible. (tty_write_glyphs): Determine faces based on a glyph's frame. (tty_write_glyphs_with_face): Take a struct face argument instead of a face id. Callers changed. (tty_insert_glyphs): Use faces, not face ids. (append_glyph, append_composite_glyph, append_glyphless_glyph): Set glyph's frame. (turn_on_face, turn_off_face): Take face argument instead of face id. Callers adapted. (Fresume_tty): Act on root frame. (tty_draw_row_with_mouse_face): Handle child frames. (restore_desired_matrix): Make sure glyphs' is live. (set_tty_hooks): Set terminal's frame_raise_lower_hook. (tty_frame_geometry, Ftty_frame_geometry, Ftty_frame_edges) (Ftty_frame_list_z_order, Ftty_frame_restack) (tty_display_dimension, Ftty_display_pixel_width) (Ftty_display_pixel_height): New functions. (syms_of_term): Defsubr new Lisp functions. * src/minibuf.c (read_minibuf): Use combine_updates for tty frames. * src/frame.h (struct frame): Always define parent_frame. Change 'visible' to be a boolean. Always define 'undecorated' and 'no_accept_focus'. Add 'z_order'. (FRAME_OBSCURED_P): Removed. (FRAME_PARENT_FRAME): Make it a function. (SET_FRAME_VISIBLE): Take a bool parameter, not an int. (FRAME_INTERNAL_BORDER_WIDTH): Don't special-base HAVE_WINDOW_SYSTEM. * src/frame.c (decode_tty_frame): New function. (set_menu_bar_lines): Set menu bar lines and height to 0 for tty child frames. Compute min height differently. (adjust_frame_size): Set FrameCols/Rows only for root tty frames. Mark tty root frame garbaged if child frame is adjusted. Run some code even if not HAVE_WINDOW_SYSTEM. (make_frame): Run some code even if not HAVE_WINDOW_SYSTEM. (make_terminal_frame): Implement child frame creation. (tty_child_pos_param, tty_child_size_param) (tty_child_frame_rect): New functions. (Fmake_terminal_frame): Parts rewritten for child frames. (do_switch_frame): Add child frame support. (Fframe_ancestor_p): Define if not HAVE_WINDOW_SYSTEM. (Fmake_frame_visible, Fmake_frame_invisible) (Fframe_visible_p, Fraise_frame): Handle tty frames differently. (store_frame_param): Signal error if trying to re-parent a tty child frame. (Fframe_parameters): Report some additional tty frame parameters. (Fmodify_frame_parameters): Handle tty child frames. (Fset_frame_position): Ditto. (frame_parms): Define index for additional frame parameters. (handle_frame_param): New function. (gui_set_frame_parameters_1): Use handle_frame_param. * src/disptab.h (DISP_TABLE_EXTRA_SLOTS): Change to 12. (enum box): New enumeration. * src/dispnew.c (check_rows): New function, #if 0. (frame_matrix_frame): Variable removed. (line_hash_code): Take glyph's frame into account. (build_frame_matrix_from_leaf_window): Do not copy glyphs from rows that aren't enabled. (fill_up_glyph_row_with_spaces): Add frame parameter, uses changed. (fill_up_glyph_row_area_with_spaces): Add frame parameter. Set glyph's frame to it. (fill_up_frame_row_with_spaces): Ditto. (set_frame_matrix_frame): Function removed. (make_current): Change signature. Callers changed. (mirrored_line_dance): Take a frame argument, not a matrix. (redraw_frame): Don't clear_frame a child frame. (struct rect): New. (rect_intersect, frame_pos_abs, frame_rect_abs, root_frame) (max_child_z_order, is_frame_ancestor, frames_with_root) (frames_with_parent, frame_z_order_cmp, Fframe__z_order_lessp) (frames_in_reverse_z_order, tty_raise_lower_frame, is_tty_frame) (is_tty_child_frame, is_tty_root_frame, first_enabled_row) (make_matrix_current, prepare_desired_root_row) (make_glyph_space, neutralize_wide_char, produce_box_glyphs) (produce_box_sides, produce_box_line, copy_child_glyphs) (update_window_frame, update_initial_frame, flush_terminal) (abs_cursor_pos, is_in_matrix, is_cursor_obscured) (terminal_cursor_magic, combine_updates_for_frame) (combine_updates): New functions. (update_frame): Rewritten. (Fdisplay__update_for_mouse_movement): Take a MOUSE_FRAME param. (syms_of_display): New symbol frame--z-order--lessp, tty-non-selected-cursor. New subr Sframe__z_order_lessp. Provide tty-child-frames. * src/dispextern.h (struct glyph): Add member 'frame'. (CHAR_GLYPH_SPACE_P): Add FRAME parameter. All uses changed. (GLYPH_EQUAL_P): Compare glyphs' frame. (SET_CHAR_GLYPH): Add parameter FRAME. (SET_CHAR_GLYPH_FROM_GLYPH): Ditto. * src/chartab.c (Fmake_char_table): Allow more than 10 display table slots. * lisp/xt-mouse.el (xterm-mouse--handle-mouse-movement): Use new terminal parameter xterm-mouse-frame. (xterm-mouse-position-function): Ditto. (xterm-mouse-event): Determine frame under mouse and compute frame-relative coordinates. Set terminal parameter xterm-mouse-frame. * lisp/tty-tip.el: New file implementing tooltip for ttys. * lisp/paren.el (show-paren-function): Don't check if display-graphics-p when using child frames. * lisp/frame.el (frame-at): New function. (tty-frame-geometry, tty-frame-edges, tty-frame-restack) (tty-display-pixel-height, tty-frame-list-z-order) (tty-display-pixel-width): Declare C function. (frame-geometry): Use tty-frame-geometry. (frame-edges): Use tty-frame-edges. (frame-list-z-order): Use tty-frame-list-z-order. (frame-restack): Use tty-frame-restack. (display-pixel-height): Use tty-display-pixel-height. (display-pixel-width): Use tty-display-pixel-width. * lisp/disp-table.el (display-table): Increase size to 12. (box-horizontal, box-vertical, box-down-right, box-down-left) (box-up-right, box-up-left): New display table slot names for box-drawing characters. (display-table-slot, set-display-table-slot): Extend doc string. (describe-display-table): Display new display table slots. (standard-display-unicode-special-glyphs): New function setting up Unicode characters for display table entries. * .gitignore: Don't ignore patch files, they are useful to see in Magit status buffer when applying patches (git am).
| * | More fixes for w32 console buildEli Zaretskii2024-10-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * src/w32term.c (w32_read_socket): Don't use FRAME_OBSCURED_P, which was removed. * src/frame.h (struct frame): Move !HAVE_NTGUI to its original place. * src/treesit.c (treesit_load_language): Shut up GCC warning.
* | | Make treesit-query-compile compile compiled-query eagerlyYuan Fu2024-12-041-11/+25
| | | | | | | | | | | | | | | | | | | | | * src/treesit.c (treesit_ensure_query_compiled_signal): Extrat out into a function. (Ftreesit_query_compile): If EAGER is non-nil and QUERY is a lazily compiled query, compile it eagerily.
* | | Merge from emacs-30Yuan Fu2024-12-011-1/+4
|\ \ \ | | |/ | |/| | | | | | | | | | | | | | | | | | | cf4f1387a65 ; Update tree-sitter manual 3c7687c1dd1 Allow passing nil to treesit-node-match-p (bug#74612) 748b19e56e8 Update to version 2.58 of librsvg API (bug#74606) 4c67f636c08 Fix decoding of non-ASCII email attachments bd8a6f70fb9 Prevent "Selecting deleted buffer" error with dabbrev-expand 0a753603a53 ; (dictionary-search-interface): Fix bug#74511.
| * | Allow passing nil to treesit-node-match-p (bug#74612)Yuan Fu2024-12-011-1/+4
| | | | | | | | | | | | * src/treesit.c (Ftreesit_node_match_p): Return nil if NODE is nil.
* | | Merge from origin/emacs-30Eli Zaretskii2024-11-231-0/+11
|\ \ \ | |/ / | | / | |/ |/| | | | | | | | | | | | | | | | | | | | | | | 74a972cace6 Skip proced refine tests on Darwin c50ce03afc1 ; Fix recent additions to the manuals c818c5bbafd ; * lisp/term/w32-win.el (tree-sitter--library-abi): Decl... b71d3b2f52f ; Better clarify function types in C-h f (bug#73626) 59b3eae481d ; Introduce type specifiers to the elisp manual (bug#73626) 83fc3cf53a4 Future-proof loading tree-sitter library on MS-Windows 3eb30186825 ; Improve documentation of 'category' in display-buffer a... 4d80c4f4858 ; More accurate documentation of 'set-mark-command' 70dd5705e11 Fix overriding 'c-ts-mode' by 'c-mode' 331610aef05 ; Improve vc-dir help-echo 9c484d51012 ; Avoid assertion violations in "temacs -Q" 8dc9dfdc381 lisp/progmodes/c-ts-mode.el: Demote loading c-ts-mode as ... 426bce8a675 ; In PROBLEMS mention issue with .Xresources on Gnome des...
| * Future-proof loading tree-sitter library on MS-WindowsEli Zaretskii2024-11-211-0/+11
| | | | | | | | | | | | | | | | | | * src/treesit.c (syms_of_treesit) <tree-sitter--library-abi>: New internal variable. * lisp/term/w32-win.el (dynamic-library-alist): Use 'tree-sitter--library-abi' to select a proper libtree-sitter DLL version.
* | Merge from origin/emacs-30Eli Zaretskii2024-09-211-22/+27
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | 4b9a8fd6074 etags-regen-file-extensions: Add .pm 956f14ae5e9 * src/treesit.c (treesit_debug_print_parser_list): Fix co... 300d05ecb4c Type-check argument to network-lookup-address-info 0f0f21b7f27 ; Improve doc strings of options related to numbered backups f0daa2f2153 Conservative heuristic for tree-sitter parser ranges (bug... 035024b4e5a ; Fix treesit.c printing 8771310a10d ; * admin/notes/unicode: Need to run textsec-tests (bug#7... 4c6f45fa8ee Re-enable GC mark trace buffer by default c6077015894 ; * src/haiku_support.cc: Correct last change. ae22ad7f624 ; Add even more tests for previous commit 460b9d705ab Fix treesit_sync_visible_region's range fixup code (bug#7... 81347c1aaf2 ; * etc/PROBLEMS: Fix last change (bug#73207). a82b7f3e823 Document unavailability of frame geometry on Wayland
| * * src/treesit.c (treesit_debug_print_parser_list): Fix compiler warning.Andrea Corallo2024-09-191-2/+2
| |
| * Conservative heuristic for tree-sitter parser ranges (bug#73324)Yuan Fu2024-09-171-23/+18
| | | | | | | | | | | | | | | | * src/treesit.c (treesit_sync_visible_region): If the parser's original ranges don't overlap with visible region, give it a zero range, rather than don't set any range. * test/src/treesit-tests.el (treesit-range-fixup-after-edit): Test new behavior.
| * ; Fix treesit.c printingYuan Fu2024-09-171-2/+2
| | | | | | | | | | * src/treesit.c (treesit_debug_print_parser_list): Use PRIuPTR so 32bit systems compile without warnings.
| * Fix treesit_sync_visible_region's range fixup code (bug#73264)Yuan Fu2024-09-151-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | new_ranges_head | v ( )->( )->( )->( )->( ) ^ ^ | | | lisp_ranges (loop head) | prev_cons -> set cdr to nil to cut of the rest result: ( )->( ) * src/treesit.c (treesit_sync_visible_region): Cut off this cons and the rest, not set the current range's end to nil. * test/src/treesit-tests.el: (treesit-range-fixup-after-edit): Add tests for all cases.
* | Merge from origin/emacs-30Eli Zaretskii2024-09-141-86/+129
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | d509a356997 Fix regression in widget-move (bug#72995) ef0276de82b ; * lisp/cus-edit.el (setopt): Doc fix. (Bug#73098) b115c2d5eba ; * lisp/minibuffer.el (completion-pcm--merge-completions... 3cda1fdc3b7 Correctly include fixed strings before a prefix wildcard ... 57d93d0259a ; * lisp/treesit.el (treesit-major-mode-setup): Doc fix. ad289f364e5 ; Improve documentation of 'easy-menu-define' 3cad7cc8dc8 Set treesit-primary-parser for c and elixir ts mode 2f243fb91d6 ; Minor doc fix in treesit.el 6a6d7925c9d Fix range handling so it works for multibyte buffer (bug#... 76faf7e6091 Revert "Read more on each call to treesit's buffer reader" c70bd0e3fe9 Fix tree-sitter indent preset prev-adaptive-prefix 272df33fb8b ; * CONTRIBUTE: Minor copyedits. 8e1187e336f Improve NEWS entries ca3932121a8 Don't fail uniquify-tests in non-version-controlled sourc... 79f68597aba ; * etc/ORG-NEWS: Fix typo. d66b70f3607 * doc/misc/auth.texi: Minor copy edits. 2c6b7b2da9f ; * admin/MAINTAINERS: Remove some entries for Artur Mala... 11e7ae3964e Fix bug#72254 # Conflicts: # etc/NEWS
| * Fix range handling so it works for multibyte buffer (bug#73204)Yuan Fu2024-09-141-83/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Here by multibyte buffer I mean buffer that includes non-ASCII characters. The problem is illustrated by this comment, which I copied from the source: ====================================================================== (ref:bytepos-range-pitfall) Suppose we have the following buffer content ([ ] is a unibyte char, [ ] is a multibyte char): [a][b][c][d][e][ f ] and the following ranges (denoted by braces): [a][b][c][d][e][ f ] { }{ } So far so good, now user deletes a unibyte char at the beginning: [b][c][d][e][ f ] { }{ } Oops, now our range cuts into the multibyte char, bad! ====================================================================== * src/treesit.c (treesit_debug_print_parser_list): Minor fix. (treesit_sync_visible_region): Change the way we fixup ranges, instead of using the bytepos ranges from tree-sitter, we use the cached lisp charpos ranges. (treesit_make_ts_ranges): New function. (Ftreesit_parser_set_included_ranges): Refactor out the new function treesit_make_ts_ranges. (Ftreesit_parser_included_ranges): Rather than getting the ranges from tree-sitter, just return the cached lisp ranges. * src/treesit.h (Lisp_TS_Parser): Add some comment. * test/src/treesit-tests.el (treesit-range-fixup-after-edit): New test.
| * Revert "Read more on each call to treesit's buffer reader"Yuan Fu2024-09-141-4/+2
| | | | | | | | | | | | | | | | This reverts commit bf23382f1f2d6ea072db4e4750f8a345f77a3ef2. We move around the gap, narrow regions, ralloc, etc, and don't have a way to invalidate previously given range. So tree-sitter can't be given the full range.
* | Add Ftreesit_grammar_locationYuan Fu2024-09-121-13/+58
| | | | | | | | | | | | | | | | | | | | | | * src/treesit.c (treesit_loaded_lang): New struct. (treesit_load_language): Return a struct instead of just the language object. The struct contains both the language object and the path to the shared library. (Ftreesit_language_available_p, Ftreesit_language_abi_version) (treesit_ensure_query_compiled, Ftreesit_parser_create): Update call of treesit_load_language. (Ftreesit_grammar_location): New function.
* | Merge from savannah/emacs-30Po Lu2024-09-111-27/+121
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ee3e3a63111 ; Update version number of exec/configure.ac c5925b6ba5f Fix heex-ts-mode indentation following previews elixir-mo... c3383be5f04 ; * admin/make-tarball.txt: Improve last change. 8ddb54117f1 ; * admin/make-tarball.txt: Remove now unnecessary config... 7e194d33f90 * lisp/ldefs-boot.el: Update. 9019536ea66 Fix use of Uniscribe font driver in MinGW build 5c55c860db7 Avoid crashes in redisplay in batch-mode testing ba2190e1ae7 ; * etc/NEWS: Fix indentation. 818c0cc9a51 eglot-test-rust-completion-exit-function: Fix failure in ... f47297782bd ; * doc/lispref/searching.texi (Rx Notation): Simplify rx... 03e56981675 Clarify the semantics of 'string-pixel-width' 9f0603207b1 ; * src/treesit.c: Minor cleanups of recent changes. e0d3f743957 * src/treesit.c (treesit_debug_print_parser_list): Fix fo... bed38ded730 ; * src/treesit.c (treesit_debug_print_parser_list): Fix ... 18c6487dbd0 ; * src/treesit.c: Add a prototype so there's no warning ... bf23382f1f2 Read more on each call to treesit's buffer reader 3435464452b Fix the range handling in treesit.c 3fcec09f754 Add debugging function for treesit.c 0fd259d166c Fix elixir-ts-mode's range query 2329b36b1fb ; project-files-relative-names: Update docstring (bug#72701) e55e2e1c6ba Make json-serialize always return a unibyte string (bug#7... 89c99891b2b ; * doc/lispref/os.texi (Suspending Emacs): Fix last change. 4f044d0d3df ; Improve documentation of 'suspend-emacs'
| * ; * src/treesit.c: Minor cleanups of recent changes.Eli Zaretskii2024-09-091-3/+2
| |
| * * src/treesit.c (treesit_debug_print_parser_list): Fix format string.Andrea Corallo2024-09-091-1/+1
| |
| * ; * src/treesit.c (treesit_debug_print_parser_list): Fix formatting.Yuan Fu2024-09-081-2/+5
| |
| * ; * src/treesit.c: Add a prototype so there's no warning about it.Yuan Fu2024-09-081-0/+1
| |
| * Read more on each call to treesit's buffer readerYuan Fu2024-09-081-2/+4
| | | | | | | | | | * src/treesit.c (treesit_read_buffer): Read until the gap or visible end, instead of reading a single char.
| * Fix the range handling in treesit.cYuan Fu2024-09-081-25/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. In treesit_sync_visible_region, reduce the ranges for a parser so it doesn't go beyond the visible range. 2. To avoid possible infinite recursion, add a within_reparse field to parsers. Previously we were using the need_reparse field to avoid infinite recursion, but lisp programs in a parser's after change hook might make some buffer edit which turns need_reparse to true. To avoid that, we now use an explicit field. If a parser's after change function makes a buffer edit, lisp program ends up with a desynced parse tree, but that's better than possible infinite recursion. Also after change function shouldn't edit the buffer. 3. In treesit_make_ranges, use parser's visible_beg instead of buffer's BEGV. I mean technically whenever we make ranges, buffer's BEGV should be equal to parser's visible_beg, but better not take that uncertainty, also makes the code more readable. 4. In Ftreesit_parser_included_ranges, move visible region sync code before the body of the function. * src/treesit.c (treesit_sync_visible_region): Minimally fix ranges so it doesn't exceed parser's visible range. (treesit_call_after_change_functions): Update calling sigature to treesit_make_ranges. (treesit_ensure_parsed, make_treesit_parser): Use the new field within_reparse. (treesit_make_ranges): Use parser's visible_beg instead of buffer's BEGV. (Ftreesit_parser_included_ranges): Move visible region check before function body. * src/treesit.h (Lisp_TS_Parser): Add new field within_reparse.
| * Add debugging function for treesit.cYuan Fu2024-09-081-0/+47
| | | | | | | | * src/treesit.c (treesit_debug_print_parser_list): New function.
* | ; * src/treesit.c (Ftreesit_parse_string): Fix comment and punctuation.Eli Zaretskii2024-08-251-10/+10
| |