aboutsummaryrefslogtreecommitdiffstats
path: root/src/treesit.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* ; Fix last change in treesit.cEli Zaretskii2026-02-181-0/+10
| | | | | | | * src/treesit.c (ts_tree_cursor_copy) [WINDOWSNT]: Define and load from the DLL if 'ts_tree_cursor_goto_previous_sibling' is not available. This fixes the MS-Windows build broken by the last change here. (Bug#80108)
* Change back tree-sitter version requirement (bug#80108)Yuan Fu2026-02-171-0/+56
| | | | | | | | | | | | | Now we use treesit_traverse_sibling_helper when it exists, and use the old code otherwise. So we still support older tree-sitter versions. * configure.ac (LIBSYSTEMD_CFLAGS): Add back old config checking for the malloc function. Add another check for ts_tree_cursor_goto_previous_sibling. * src/treesit.c: (treesit_traverse_sibling_helper): Add back the old code that doesn't require ts_tree_cursor_goto_previous_sibling.
* ; Fix MS-Windows build broken by recent treesit.c changesEli Zaretskii2026-01-281-4/+4
| | | | | | * src/treesit.c (ts_tree_cursor_copy) [WINDOWSNT]: Remove, as it is no longer used. (ts_tree_cursor_goto_previous_sibling) [WINDOWSNT]: Add. (Bug#80108)
* Fix tree-sitter traversal slowness (bug#80108)Yuan Fu2026-01-281-42/+6
| | | | | | | | * configure.ac (LIBSYSTEMD_CFLAGS): Increase minimal required tree-sitter version to 0.20.10. * src/treesit.c (treesit_traverse_sibling_helper): When traversing forward, use the new function ts_tree_cursor_goto_previous_sibling.
* ; Fix documentation of recent treesit changesEli Zaretskii2026-01-021-2/+2
| | | | | | | * etc/NEWS: * src/treesit.c (Ftreesit_query_eagerly_compiled_p): * doc/lispref/parsing.texi (Pattern Matching): Fix documentation of the recent treesit-related changes. (Bug#80108)
* Compile queries in treesit-f-l-recompute-features (bug#80108)Yuan Fu2026-01-011-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The direct cause of the problem in the bug report is that when user runs treesit-font-lock-recompute-features to add the emacs-devel feature in c-ts-mode's mode hook, the added query for emacs-devel aren't compiled. This change consists of two parts: 1. The immediate fix: validate and compile queries in treesit-font-lock-recompute-features. 2. To make it more fool-proof, change treesit-font-lock-rules back to compile the queries and make treesit--compile-query-with-cache support compiled queries. This way, as long as the query goes through treesit-font-lock-rules, it'll be compiled eventually and not cause slow-down. I had to add some c-level functions, but they're kind of overdue anyway, so I don't have any problem adding them to the API. * lisp/treesit.el (treesit--compile-query-with-cache): Support compiled queries. (treesit-font-lock-rules): Compile the queries (but not eagerly). (treesit-font-lock-recompute-features): Validate and compile queries. (treesit-major-mode-setup): Remove call to treesit-validate-and-compile-font-lock-rules since it's now called in treesit-font-lock-recompute-features. * src/treesit.c (Ftreesit_query_eagerly_compiled_p): (Ftreesit_query_source): New functions. * doc/lispref/parsing.texi (Pattern Matching): Add manual entries for the new functions.
* ; Add 2026 to copyright years.Sean Whitton2026-01-011-1/+1
|
* December 2025 spelling fixesPaul Eggert2025-12-261-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix some C symbol extern visibilityPaul Eggert2025-12-081-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Use treesit-extra-load-path for more values of treesit-auto-install-grammarJuri Linkov2025-11-301-1/+2
| | | | | | | | * lisp/treesit.el (treesit-auto-install-grammar): Use the first writable directory from 'treesit-extra-load-path' for values 'always', 'ask', 'ask-dir' (bug#79862). * src/treesit.c (syms_of_treesit): Extend docstring.
* * lisp/cus-start.el: Make 'treesit-extra-load-path' customizable.Juri Linkov2025-11-281-1/+3
| | | | | | | | | | | * lisp/treesit.el (treesit-auto-install-grammar): Add the value 'ask-dir'. (treesit-ensure-installed): When 'treesit-auto-install-grammar' is 'ask' or 'ask-dir', ask for the directory to install the grammar library using the first writable directory of 'treesit-extra-load-path' as default. Also add the provided directory to 'treesit-extra-load-path' afterwards. * src/treesit.c (treesit-extra-load-path): In the docstring mention the fact that the first directory is special (bug#79862).
* Change tree-sitter query predicate names (bug#79687)Yuan Fu2025-11-021-44/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Latest tree-sitter library throws a syntax error if the predicate names in a query don't end with question mark. So we made the following change: :equal changed to :eq? :match changed to :match? :pred changed to :pred? Old names are transparently converted to new names when expanding patterns. :match predicate can now take the regexp and the node in any order: it'll figure out which is which automatically. This way it works with current Emacs convention (regexp first), as well as tree-sitter's match convention (regexp second). * doc/lispref/parsing.texi (Pattern Matching): Update manuel to use new predicate names. * src/treesit.c: (Ftreesit_pattern_expand): (Ftreesit_query_expand): (treesit_predicate_match): (treesit_eval_predicates): (syms_of_treesit): Use new predicate names. * test/src/treesit-tests.el (treesit-query-api): Update test.
* Support Tree-sitter version 0.26 and laterEli Zaretskii2025-10-171-2/+34
| | | | | | | | | | | | | * src/treesit.c (init_treesit_functions) [TREE_SITTER_LANGUAGE_VERSION >= 15]: Define prototype for, and load 'ts_language_abi_version' instead of the deprecated (and removed in tree-sitter 0.26) 'ts_language_version'. (ts_language_abi_version) [TREE_SITTER_LANGUAGE_VERSION >= 15]: Define on WINDOWSNT, instead of 'ts_language_version'. (treesit_language_abi_version): New compatibility function. (treesit_load_language, Ftreesit_language_abi_version): Use 'treesit_language_abi_version' instead of 'ts_language_version'. (Bug#79627)
* New user option 'treesit-enabled-modes' (bug#79180)Juri Linkov2025-08-141-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/treesit.el (treesit-enabled-modes): New user option. * src/treesit.c (treesit-major-mode-remap-alist): New variable. * lisp/progmodes/c-ts-mode.el: * lisp/progmodes/csharp-mode.el: * lisp/progmodes/java-ts-mode.el: * lisp/progmodes/js.el: * lisp/progmodes/json-ts-mode.el: * lisp/progmodes/ruby-ts-mode.el: * lisp/progmodes/sh-script.el: * lisp/textmodes/css-mode.el: * lisp/textmodes/mhtml-ts-mode.el: * lisp/textmodes/toml-ts-mode.el: Add ts-mode mapping to 'treesit-major-mode-remap-alist' for ts-modes that already have the corresponding non-ts mode association in 'auto-mode-alist'. * lisp/progmodes/cmake-ts-mode.el (cmake-ts-mode-maybe): * lisp/progmodes/dockerfile-ts-mode.el (dockerfile-ts-mode-maybe): * lisp/progmodes/elixir-ts-mode.el (elixir-ts-mode-maybe): * lisp/progmodes/go-ts-mode.el (go-ts-mode-maybe) (go-mod-ts-mode-maybe, go-work-ts-mode-maybe): * lisp/progmodes/heex-ts-mode.el (heex-ts-mode-maybe): * lisp/progmodes/lua-ts-mode.el (lua-ts-mode-maybe): * lisp/progmodes/php-ts-mode.el (php-ts-mode-maybe): * lisp/progmodes/rust-ts-mode.el (rust-ts-mode-maybe): * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode-maybe) (tsx-ts-mode-maybe): * lisp/textmodes/markdown-ts-mode.el (markdown-ts-mode-maybe): * lisp/textmodes/yaml-ts-mode.el (yaml-ts-mode-maybe): Add a wrapper function to 'auto-mode-alist' for ts-modes that have no corresponding non-ts mode. Also add a mapping to 'treesit-major-mode-remap-alist' for the case when a non-ts mode is installed from an external source to be able to customize it with 'treesit-enabled-modes'.
* Add a synchronous way to get parser change ranges (bug#78402)Yuan Fu2025-07-081-10/+36
| | | | | | | | | | | | | | This commit only adds the new function, the fix for the bug is in the next commit. * doc/lispref/parsing.texi (Using Parser): Add docs. * lisp/treesit.el (treesit): Add shortdoc. * src/treesit.c (treesit_get_affected_ranges): New function extracted from treesit_call_after_change_functions. (treesit_call_after_change_functions): Extract out. (treesit_ensure_parsed): Return affected regions. (Ftreesit_parser_changed_regions): New function that returns the affected regions.
* Merge from origin/emacs-30Eli Zaretskii2025-07-051-1/+15
|\ | | | | | | | | | | | | | | | | | | 3f7787c9794 ; * lisp/replace.el (query-replace-help): Fix help text (... b10596a6303 ; * lisp/emacs-lisp/warnings.el (warning-display-at-botto... 060f964906b Handle ts_node_type return NULL (bug#78938) 5bdacbe460a Improve documentation of 'warning-display-at-bottom' 30dae2ad239 Handle the case when ts_node_type returns NULL (bug#78938) 985ad1da76d ; * lisp/emacs-lisp/bytecomp.el (compilation-safety): Doc... de18407f513 ; * doc/lispref/functions.texi (Mapping Functions): Fix w...
| * Handle ts_node_type return NULL (bug#78938)Yuan Fu2025-07-041-1/+11
| | | | | | | | | | | | * src/treesit.c (treesit_traverse_match_predicate): Handle the case when ts_node_type returns NULL. (Ftreesit_node_type): Add some comment.
| * Handle the case when ts_node_type returns NULL (bug#78938)Yuan Fu2025-07-031-1/+5
| | | | | | | | * src/treesit.c (Ftreesit_node_type): Handle NULL.
* | Merge from origin/emacs-30Eli Zaretskii2025-06-141-2/+17
|\ \ | |/ | | | | | | | | | | | | | | | | df3fb94f091 Insert missing step to make use of directory tracking OSC... 1bed2949583 * lisp/keymap.el (keymap-set): Refer to 'key-description'... 941158fc133 Support new tree-sitter grammar filename format (bug#78754) 888f846d377 Fix crash when evaluating "(signal nil 5)" (bug#78738) 51b9e92ab8e Merge branch 'emacs-30' of git.savannah.gnu.org:/srv/git/... c0a913ea4f3 ; * doc/lispref/modes.texi (Font Lock Basics): Remove old... 37de076017a Adapt emba integration (don't merge)
| * Support new tree-sitter grammar filename format (bug#78754)Yuan Fu2025-06-101-2/+17
| | | | | | | | | | | | | | | | | | | | Previously Emacs only looks for filenames like libtree-sitter-json.so.0.0. Now Emacs also look for filenames like libtree-sitter-json.so.15.0. * src/treesit.c: (treesit_load_language_push_for_each_suffix): Add versioned candidate to candidate list too.
| * Fix treesit-parser-create behavior regarding indirect buffersYuan Fu2025-03-131-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous fix fixed the problem that treesit-parser-create always use the current buffer, but that introduce another subtle problem: if an indirect buffer creates a parser, the parser saves the base buffer rather than the indirect buffer. In Emacs 29, if you create a parser in an indirect buffer, the parser saves the indirect buffer. This change of behavior breaks some existing use-cases for people using indirect buffer with tree-sitter. In Emacs 31, indirect buffers and base buffer get their own parser list, so this problem doesn't exist anymore. The fix is only for Emacs 30. * src/treesit.c (Ftreesit_parser_create): Use the buffer that's given to treesit-parser-create, even if it's an indirect buffer.
* | ; Fix warnings in MinGW buildsEli Zaretskii2025-06-141-1/+1
| | | | | | | | | | | | | | | | * src/w32fns.c (msh_mousewheel): Declare. * src/treesit.c (treesit_debug_print_linecol): Fix format specifiers. * lib-src/pop.c (pfn_getaddrinfo, pfn_freeaddrinfo): Now static.
* | 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.