diff options
| author | Yuan Fu | 2022-06-16 17:55:07 -0700 |
|---|---|---|
| committer | Yuan Fu | 2022-06-16 17:55:07 -0700 |
| commit | 246dbb540a32fd5e68ae0665527717943ebb69b1 (patch) | |
| tree | 7a2520f82c4775edc9da948630d4db11d5868f68 /src/buffer.c | |
| parent | 33f7e10a29dad475f7872d6af87ecefaccdb55fc (diff) | |
| download | emacs-246dbb540a32fd5e68ae0665527717943ebb69b1.tar.gz emacs-246dbb540a32fd5e68ae0665527717943ebb69b1.zip | |
Change treesit-parser-list from variable to function
Effectively making the list internal. Now Emacs user cannot shoot
themselves in the foot by removing a parser from the list, make
chaanges to buffer and add that parser back to the list.
* doc/lispref/parsing.texi (Language Definitions, Using Parser)
(Retrieving Node, Multiple Languages): Change variable to function.
* lisp/treesit.el (treesit-language-at, treesit-node-on)
(treesit-buffer-root-node, treesit-indent, treesit-check-indent)
(treesit-search-forward, treesit-search-beginning)
(treesit-end-of-defun, treesit-inspect-mode): Change variable to
function.
* src/buffer.c (bset_ts_parser_list, reset_buffer, init_buffer_once):
Add ts_parser_list.
* src/buffer.h (struct buffer): Add ts_parser_list.
* src/treesit.c (ts_record_change, Ftreesit_parser_create): Use the
buffer field instead of the old buffer local variable.
(Ftreesit_parser_delete, Ftreesit_parser_list): New functions.
(syms_of_treesit): Remove treesit-parser-list.
* test/src/treesit-tests.el (treesit-basic-parsing): Use the new
function.
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/buffer.c b/src/buffer.c index a0761f5b59a..97e9e227386 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -231,6 +231,13 @@ bset_extra_line_spacing (struct buffer *b, Lisp_Object val) | |||
| 231 | { | 231 | { |
| 232 | b->extra_line_spacing_ = val; | 232 | b->extra_line_spacing_ = val; |
| 233 | } | 233 | } |
| 234 | #ifdef HAVE_TREE_SITTER | ||
| 235 | static void | ||
| 236 | bset_ts_parser_list (struct buffer *b, Lisp_Object val) | ||
| 237 | { | ||
| 238 | b->ts_parser_list_ = val; | ||
| 239 | } | ||
| 240 | #endif | ||
| 234 | static void | 241 | static void |
| 235 | bset_file_format (struct buffer *b, Lisp_Object val) | 242 | bset_file_format (struct buffer *b, Lisp_Object val) |
| 236 | { | 243 | { |
| @@ -1004,6 +1011,9 @@ reset_buffer (register struct buffer *b) | |||
| 1004 | (b, BVAR (&buffer_defaults, enable_multibyte_characters)); | 1011 | (b, BVAR (&buffer_defaults, enable_multibyte_characters)); |
| 1005 | bset_cursor_type (b, BVAR (&buffer_defaults, cursor_type)); | 1012 | bset_cursor_type (b, BVAR (&buffer_defaults, cursor_type)); |
| 1006 | bset_extra_line_spacing (b, BVAR (&buffer_defaults, extra_line_spacing)); | 1013 | bset_extra_line_spacing (b, BVAR (&buffer_defaults, extra_line_spacing)); |
| 1014 | #ifdef HAVE_TREE_SITTER | ||
| 1015 | bset_ts_parser_list (b, Qnil); | ||
| 1016 | #endif | ||
| 1007 | 1017 | ||
| 1008 | b->display_error_modiff = 0; | 1018 | b->display_error_modiff = 0; |
| 1009 | } | 1019 | } |
| @@ -5273,6 +5283,9 @@ init_buffer_once (void) | |||
| 5273 | XSETFASTINT (BVAR (&buffer_local_flags, tab_line_format), idx); ++idx; | 5283 | XSETFASTINT (BVAR (&buffer_local_flags, tab_line_format), idx); ++idx; |
| 5274 | XSETFASTINT (BVAR (&buffer_local_flags, cursor_type), idx); ++idx; | 5284 | XSETFASTINT (BVAR (&buffer_local_flags, cursor_type), idx); ++idx; |
| 5275 | XSETFASTINT (BVAR (&buffer_local_flags, extra_line_spacing), idx); ++idx; | 5285 | XSETFASTINT (BVAR (&buffer_local_flags, extra_line_spacing), idx); ++idx; |
| 5286 | #ifdef HAVE_TREE_SITTER | ||
| 5287 | XSETFASTINT (BVAR (&buffer_local_flags, ts_parser_list), idx); ++idx; | ||
| 5288 | #endif | ||
| 5276 | XSETFASTINT (BVAR (&buffer_local_flags, cursor_in_non_selected_windows), idx); ++idx; | 5289 | XSETFASTINT (BVAR (&buffer_local_flags, cursor_in_non_selected_windows), idx); ++idx; |
| 5277 | 5290 | ||
| 5278 | /* buffer_local_flags contains no pointers, so it's safe to treat it | 5291 | /* buffer_local_flags contains no pointers, so it's safe to treat it |
| @@ -5343,6 +5356,9 @@ init_buffer_once (void) | |||
| 5343 | bset_bidi_paragraph_separate_re (&buffer_defaults, Qnil); | 5356 | bset_bidi_paragraph_separate_re (&buffer_defaults, Qnil); |
| 5344 | bset_cursor_type (&buffer_defaults, Qt); | 5357 | bset_cursor_type (&buffer_defaults, Qt); |
| 5345 | bset_extra_line_spacing (&buffer_defaults, Qnil); | 5358 | bset_extra_line_spacing (&buffer_defaults, Qnil); |
| 5359 | #ifdef HAVE_TREE_SITTER | ||
| 5360 | bset_ts_parser_list (&buffer_defaults, Qnil); | ||
| 5361 | #endif | ||
| 5346 | bset_cursor_in_non_selected_windows (&buffer_defaults, Qt); | 5362 | bset_cursor_in_non_selected_windows (&buffer_defaults, Qt); |
| 5347 | 5363 | ||
| 5348 | bset_enable_multibyte_characters (&buffer_defaults, Qt); | 5364 | bset_enable_multibyte_characters (&buffer_defaults, Qt); |