diff options
| author | Juri Linkov | 2025-01-25 20:14:15 +0200 |
|---|---|---|
| committer | Juri Linkov | 2025-01-25 20:14:15 +0200 |
| commit | 63df2164903e0cd6819187483a64b892aa7e0219 (patch) | |
| tree | caa5640f74fa1f8e273bc3056f8021e62fdf8a47 /src | |
| parent | 3bc6b88cc71b8ccc96b5e61d895e5208009aa3c0 (diff) | |
| download | emacs-63df2164903e0cd6819187483a64b892aa7e0219.tar.gz emacs-63df2164903e0cd6819187483a64b892aa7e0219.zip | |
Add 'treesit-forward-comment' with 'forward-comment-function'
* lisp/treesit.el (treesit-forward-comment): New function.
(treesit-major-mode-setup): Set 'forward-comment-function' to
'treesit-forward-comment' if the 'comment' thing is defined.
* src/syntax.c (forward-comment-function): New variable.
(Fforward_comment): Call the function from 'forward-comment-function'
when it's non-nil (bug#75609).
Diffstat (limited to 'src')
| -rw-r--r-- | src/syntax.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/syntax.c b/src/syntax.c index 6ffa8a94c7f..e25618ee03d 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -2434,6 +2434,9 @@ between them, return t; otherwise return nil. */) | |||
| 2434 | int dummy2; | 2434 | int dummy2; |
| 2435 | unsigned short int quit_count = 0; | 2435 | unsigned short int quit_count = 0; |
| 2436 | 2436 | ||
| 2437 | if (!NILP (Vforward_comment_function)) | ||
| 2438 | return calln (Vforward_comment_function, count); | ||
| 2439 | |||
| 2437 | CHECK_FIXNUM (count); | 2440 | CHECK_FIXNUM (count); |
| 2438 | count1 = XFIXNUM (count); | 2441 | count1 = XFIXNUM (count); |
| 2439 | stop = count1 > 0 ? ZV : BEGV; | 2442 | stop = count1 > 0 ? ZV : BEGV; |
| @@ -3796,6 +3799,11 @@ In both cases, LIMIT bounds the search. */); | |||
| 3796 | DEFSYM (Qcomment_end_can_be_escaped, "comment-end-can-be-escaped"); | 3799 | DEFSYM (Qcomment_end_can_be_escaped, "comment-end-can-be-escaped"); |
| 3797 | Fmake_variable_buffer_local (Qcomment_end_can_be_escaped); | 3800 | Fmake_variable_buffer_local (Qcomment_end_can_be_escaped); |
| 3798 | 3801 | ||
| 3802 | DEFVAR_LISP ("forward-comment-function", Vforward_comment_function, | ||
| 3803 | doc: /* If non-nil, `forward-comment' delegates to this function. | ||
| 3804 | Should take the same arguments and behave similarly to `forward-comment'. */); | ||
| 3805 | Vforward_comment_function = Qnil; | ||
| 3806 | |||
| 3799 | defsubr (&Ssyntax_table_p); | 3807 | defsubr (&Ssyntax_table_p); |
| 3800 | defsubr (&Ssyntax_table); | 3808 | defsubr (&Ssyntax_table); |
| 3801 | defsubr (&Sstandard_syntax_table); | 3809 | defsubr (&Sstandard_syntax_table); |