Commit graph

429 commits

Author SHA1 Message Date
Yuan Fu
df5ac0daf0
Fix the call to treesit-thing-defined-p
* lisp/treesit.el (treesit-defun-at-point): Add the necessary
2nd argument.
2024-10-30 18:17:59 -07:00
Stefan Kangas
67a27ff53b ; Fix typos 2024-10-27 07:49:32 +01:00
Yuan Fu
0834106a62
Fix treesit--merge-ranges (bug#73324)
* lisp/treesit.el (treesit--merge-ranges): Make sure that old
ranges that intersects with START-END are actually discarded.
* test/src/treesit-tests.el (treesit-range-merge): New test.
2024-09-20 20:54:23 -07:00
Eli Zaretskii
57d93d0259 ; * lisp/treesit.el (treesit-major-mode-setup): Doc fix. 2024-09-14 12:02:56 +03:00
Yuan Fu
2f243fb91d
; Minor doc fix in treesit.el
* lisp/treesit.el (treesit-outline-search): Mention parameters.
(treesit-major-mode-setup): Mention outline setup.
2024-09-14 00:28:23 -07:00
Yuan Fu
c70bd0e3fe
Fix tree-sitter indent preset prev-adaptive-prefix
* lisp/treesit.el (treesit-simple-indent-presets): Use looking-at so the
call to match-string has the match data to work with.
2024-09-14 00:28:22 -07:00
Yuan Fu
3a4839d142
More consistent treesit-forward-sexp around comments (bug#72525)
* lisp/treesit.el (treesit-forward-sexp): Check if point is strictly
inside a comment or string, only then use the default forward-sexp
function; otherwise use tree-sitter's forward-sexp routine.
2024-08-26 19:45:33 -07:00
Yuan Fu
b8c05d73a1
Fix tree-sitter local parser overlay cleanup routine
Sorry for sneaking in a sizable commit so late.  But I just found out
about this bug and it has to be fixed.  Before this change, we weren't
properly cleaning up overlays that store local parsers.  And in the case
of doxygen local parser in C files, the doxygen local parser overlay
sometimes bleeds out of comments and into other code, and interferes
with font-lock and indentation.

This commit adds a cleanup function that'll cleanup any overlays that
aren't being used.  I tested with doxygen in C files and everything
works smoothly now, including tricky tests like removing the ending "*/"
of a doxygen comment and adding it back.

The idea is simple, at the end of each call to (treesit-update-ranges
BEG END), we remove any overlay within BEG and END that wasn't touched
by the range setting code.

* lisp/treesit.el (treesit--cleanup-local-range-overlays): New function.
(treesit--update-ranges-local): Remove code for cleaning up zero-length
overlays since we have the cleanup function now.
(treesit-update-ranges): Wrap the function body inside a let form, which
defines modified-tick; and add a call to
treesit--cleanup-local-range-overlays at the very end.
2024-08-25 18:15:06 -07:00
Eli Zaretskii
c64d653836 ; * lisp/treesit.el (treesit-ready-p): Fix typo (bug#72411). 2024-08-01 18:25:15 +03:00
Stefan Kangas
9889774c62 Checkdoc fixes in treesit.el
* lisp/treesit.el (treesit-add-font-lock-rules)
(treesit--font-lock-mark-ranges-to-fontify): Checkdoc fixes.
2024-07-18 09:43:55 +02:00
Yuan Fu
fe0d9dfb3b ; * lisp/treesit.el (treesit--syntax-propertize-start): Fix doc.
(cherry picked from commit 2ba39a30bf)
(Bug#71753)
2024-06-25 15:33:04 +03:00
Eli Zaretskii
35e65a84eb Merge from origin/emacs-29
53e9caa23e ; * doc/emacs/help.texi (Help, Apropos): Improve text and...
00360258ca Fix treesit-parse-string crash (bug#71012)
20af58d3a1 Check for buffer liveness when accessing tree-sitter node...
2024-06-08 07:34:20 -04:00
Paul Eggert
3dcac22dd4 Spelling fixes 2024-06-04 22:16:28 -07:00
Yuan Fu
760b54de08
Use parser notifier to set parser ranges
This is a continuation from an earlier commit where I added
treesit-parser-changed-ranges and friends.  Dmitry raised an concern
about the edge case where the parser re-parses multiple times before
treesit--pre-redisplay has a chance to run and process changed ranges.

Instead of making treesit-parser-changed-ranges DTRT and become more
complicated, it's agreed that using parser notifier is a better
solution (and treesit-parser-changed-ranges can probably be removed).

So, I took out the code that does the work from treesit--pre-redisplay
and put them into treesit--font-lock-mark-ranges-to-fontify.  This
function will be called on each parser re-parse.  And in
treesit--pre-redisplay, to ensure that treesit--f-l-m-r-to-f gets
called, we force the primary parser to re-parse.

I also added a new variable that major modes need to set,
treesit-primary-parser.  I also added code that makes Emacs guess the
primary parser if that variable isn't set.

Documentation fot treesit-primary-parser will come later.

For futher reference, the message id for the message that prompted
this change is <dc94733b-df75-446c-980e-1c8ea65826cf@gutov.dev>

* lisp/treesit.el (treesit-primary-parser): New variable.
(treesit--font-lock-mark-ranges-to-fontify): New function.
(treesit--guess-primary-parser): New function.
(treesit--pre-redisplay): Extract out.
(treesit--pre-syntax-ppss): Add comments.
(treesit-major-mode-setup): Guess and set treesit-primary-parser; add
treesit--font-lock-mark-ranges-to-fontify as a notifier to the primary
parser.
2024-06-02 22:33:54 -07:00
Yuan Fu
00360258ca
Fix treesit-parse-string crash (bug#71012)
Parsing a large file with treesit-parse-string and then printing the
returned node crashes Emacs, because with-temp-buffer kills the temp
buffer when treesit-parse-string returns, and print.c tries to access
the node's position in the killed buffer.

* lisp/treesit.el (treesit-parse-string): Don't use with-temp-buffer.
2024-06-01 10:33:18 -07:00
Yuan Fu
e153093f0a
Improve treesit-major-mode-setup indentation setup (bug#71086)
* lisp/treesit.el (treesit-major-mode-setup): Setup indentation when
treesit-indent-function is set.
* doc/lispref/modes.texi (Parser-based Indentation): Fix manual.
2024-05-21 23:15:00 -07:00
Juri Linkov
9b7dd30807 * lisp/treesit.el (treesit-outline-search): Handle bobp specially.
At the beginning of the buffer call 'treesit-outline-search'
recursively with the `looking-at' argument set to t, since
`treesit-navigate-thing' can't find a thing at bobp (bug#70789).
2024-05-09 09:28:50 +03:00
Yuan Fu
bf5755aa91
Add treesit-add-font-lock-rules
This function should help users customize font-lock rules.

* lisp/treesit.el (treesit-add-font-lock-rules): New function.
2024-04-21 16:26:54 -07:00
Eli Zaretskii
12cd8d2615 ; * lisp/treesit.el (treesit-parser-changed-ranges): Declare. 2024-04-20 14:30:50 +03:00
Yuan Fu
f62c1b4cd0
Tree-sitter: only update range and reparse for changed ranges
In the very beginning, there's bug#66732, to solve that bug, we added
treesit--pre-redisplay and treesit--syntax-propertize-notifier.
However, to fix bug#66732, we were updating ranges for the whole
buffer which makes Emacs extremely slow when there are a lot of local
parsers in a large buffer.  Then to solve that we introduced a
workaround where we only update ranges in a fixed range around point.

This change fixes the original problem (bug#66732) without using that
workaround.

* lisp/treesit.el (treesit--font-lock-notifier):
(treesit--syntax-propertize-notifier): Remove functions
(treesit--pre-redisplay): Use the new function
treesit-parser-changed-ranges to get the changed ranges of the primary
parser, and only update ranges for those ranges.  Plus do the work of
the removed function.
(treesit-major-mode-setup): Remove setup for the removed functions.
2024-04-19 19:05:16 -07:00
Juri Linkov
ada429c375 * lisp/emacs-lisp/lisp.el (forward-sexp-function): Set back to nil.
(forward-sexp): Revert back to checking 'forward-sexp-function'
for nil (bug#70426).
2024-04-17 09:53:02 +03:00
Juri Linkov
568c174135 Add 'forward-sexp-default-function' to be used by 'treesit-forward-sexp'
* lisp/emacs-lisp/lisp.el (forward-sexp-default-function):
New function with body from 'forward-sexp' (bug#68993).
(forward-sexp-function): Change the default value from nil to
'forward-sexp-default-function'.
(forward-sexp): Use either 'forward-sexp-function' or
'forward-sexp-default-function'.

* lisp/treesit.el (treesit-forward-sexp): In nodes of type 'text'
fall back to 'forward-sexp-default-function'.  Improve docstring.

* doc/lispref/positions.texi (List Motion): Fix pxref.
2024-04-14 19:22:01 +03:00
Yuan Fu
64854869ae
Make tree-sitter thing feature public and remove obsolete functions
* lisp/treesit.el (treesit--things-around): Remove function.
(treesit-forward-sexp):
(treesit-beginning-of-thing):
(treesit-end-of-thing):
(treesit-navigate-thing):
(treesit-thing-at-point):
(treesit-outline-search): Use public version of thing-functions.
(treesit--thing-prev):
(treesit--thing-next):
(treesit--thing-at):
(treesit--navigate-thing): Make public.

* test/src/treesit-tests.el (treesit--ert-test-defun-navigation): Use
public version of thing-functions.
2024-04-07 22:20:31 -07:00
Eli Zaretskii
5769a10530 ; Fix doc strings of some treesit-related functions
* lisp/treesit.el (treesit-defun-tactic)
(treesit-defun-name-function, treesit-thing-at-point)
(treesit-defun-at-point):
* lisp/progmodes/c-ts-common.el (c-ts-common-statement-offset):
* lisp/progmodes/c-ts-mode.el (c-ts-mode-toggle-comment-style)
(c-ts-mode-indent-style, c-ts-mode-emacs-sources-support)
(c-ts-mode--syntax-propertize, c-ts-mode--anchor-prev-sibling)
(c-ts-mode--standalone-parent-skip-preproc)
(c-ts-mode--standalone-grandparent, c-ts-mode--else-heuristic)
(c-ts-mode--declarator-identifier)
(c-ts-mode--fontify-declarator, c-ts-mode--fontify-variable)
(c-ts-mode--defun-valid-p)
(c-ts-mode--defun-for-class-in-imenu-p)
(c-ts-mode--defun-skipper, c-ts-mode--emacs-defun-p)
(c-ts-mode--emacs-defun-at-point)
(c-ts-mode--emacs-current-defun-name, c-ts-mode--reverse-ranges)
(c-ts-mode, c++-ts-mode, c-or-c++-ts-mode): Doc fixes.
2024-03-23 11:50:55 +02:00
Yuan Fu
8f260bb93f
Don't update ranges for the whole buffer in treesit--pre-redisplay
* lisp/treesit.el (treesit--pre-redisplay): Only update two
screen-full of text around point.
2024-02-18 21:43:47 -08:00
Juri Linkov
d61145cc8c More changes for treesitter support of outline-minor-mode (bug#68824)
* lisp/treesit.el (treesit-outline-level): Set NAMED arg of
'treesit-node-at' to t.  Don't set IGNORE-MISSING arg of
'treesit-node-match-p' to t.

* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode):
Add "singleton_method" to 'treesit-thing-settings'.
Set 'treesit-outline-predicate'.  Kill local variables
'outline-regexp' and 'outline-level'.
2024-02-13 19:02:21 +02:00
Juri Linkov
3b90e5052c Tree-sitter support for outline-minor-mode (bug#68824)
* doc/emacs/text.texi (Outline Format): Add 'outline-search-function'.

* doc/lispref/elisp.texi (Top): Add new menu item "Outline Minor Mode"
after "Imenu".

* doc/lispref/modes.texi (Modes): Add new menu item "Outline Minor Mode"
after "Imenu".
(Major Mode Conventions): Mention "Outline Minor Mode" with @pxref.
(Outline Minor Mode): New node.

* doc/lispref/parsing.texi (Tree-sitter Major Modes): Mention
'treesit-outline-predicate' with @pxref.

* lisp/treesit.el (treesit-outline-predicate): New buffer-local variable.
(treesit-outline-predicate--from-imenu): New internal function.
(treesit-outline-search, treesit-outline-level): New functions.
(treesit-major-mode-setup): Set up treesit-outline-predicate,
outline-search-function and outline-level.

* lisp/progmodes/c-ts-mode.el (c-ts-mode--outline-predicate):
New internal function.
(c-ts-base-mode): Set 'treesit-outline-predicate' to
'c-ts-mode--outline-predicate'.

* lisp/progmodes/heex-ts-mode.el (heex-ts-mode): Kill inherited
local variables 'outline-heading-end-regexp', 'outline-regexp',
'outline-level'.

* lisp/progmodes/lua-ts-mode.el (lua-ts-mode): Remove 'outline-regexp'.
Suggested by john muhl <jm@pub.pink>.

* lisp/textmodes/html-ts-mode.el (html-ts-mode): Kill inherited
local variables 'outline-heading-end-regexp', 'outline-regexp',
'outline-level'.
2024-02-12 20:18:24 +02:00
Yuan Fu
cebd26b2e1
Use treesit-node-match-p in treesit-parent-while
The previous commit should've done this, but I missed it.

* lisp/treesit.el (treesit-parent-while): Use treesit-node-match-p.
2024-02-05 23:15:26 -08:00
Yuan Fu
be6de56906
Use treesit-node-match-p in treesit-parent-until/while
* lisp/treesit.el (treesit-parent-until): Use treesit-node-match-p.
(treesit-parent-while): Update docstring.
* doc/lispref/parsing.texi (Retrieving Nodes): Update docstring.
2024-02-04 20:13:59 -08:00
Yuan Fu
9dbbf93a4a
Improve treesit-forward-sexp behavior for leaf nodes (bug#68899)
treesit-forward-sexp uses treesit--navigate-thing with 'restricted'
tactic.  In this tactic we don't move over the parent thing.  However,
this makes forward-sexp useless for symbols when point is in the
symbol rather than at the beginning of it: in that case, the symbol is
considered parent and treesit-forward-sexp won't move to the end of
it.

To solve that, we allow to move across the parent even in 'restricted'
mode if the parent is a leaf thing.

Here, "leaf thing" is defined as "doesn't have any child 'thing'
inside it".

* lisp/treesit.el (treesit--navigate-thing): Move over parent in
'restricted' tactic if the parent is a leaf thing.
2024-02-04 16:48:59 -08:00
Yuan Fu
f63bcf2dfe
Fix treesit--indent-1 regarding local parsers
Take this code as an example:

1 class Foo
2 {
3     /**
4      * Block comment
5      */
6     function foo($c) {
7     }
8 }

Suppose the block comment is covered by a local parser.  When we
indent line 3, treesit--indent-1 will try to get the local parser at
the BOL, and it'll get the local parser.  But it shouldn't use the
local parser to indent this line, it should use the host parser of
that local parser instead.

So now, if treesit--indent-1 gets a local parser, but the local
parser's root node's start coincides with BOL, treesit--indent-1 will
use the host parser to indent this line.

We also need to make treesit--update-ranges-local to save the host
parser along with the local parser, and make
treesit-local-parsers-at/on extract and return the host parser.

I also switch the two cases in the cond form in treesit--indent-1:
(null (treesit-parser-list)) and (car local-parsers), (car
local-parsers) now takes precedence.

* lisp/treesit.el (treesit-local-parsers-at):
(treesit-local-parsers-on): Add WITH-HOST parameter.
(treesit--update-ranges-local): Save the host parser to the local
overlay.
(treesit--indent-1): If the root node of the local parser is at BOL,
use the host parser instead.
2024-01-30 22:28:47 -08:00
Yuan Fu
236317e5d2
Fix treesit-range-rules
* lisp/treesit.el (treesit-range-rules): Reset :local like other
keywords.  The other chunk is indentation fix.
2024-01-27 22:04:30 -08:00
Konstantin Kharlamov
54c6588952 Support a local repo as URL in 'treesit-language-source-alist'
Sometimes people may need to bisect to find specific revision
in a grammar library's repo.  In this case they'd want to point
the URL to the local repo to avoid cloning it on every rebuild.
So add support for a directory instead of URL in
'treesit-language-source-alist'.
* lisp/treesit.el (treesit--install-language-grammar-1): Test
if URL is a local directory.  Then if it is, avoid cloning the
repo and removing the path on success.
(treesit--git-clone-repo): Factor out the code for cloning to
a separate function.
(treesit--git-checkout-branch): A helper to checkout the
revision for cases where we didn't clone the repo but want it
to point the revision.  (Bug#68579)
2024-01-27 21:18:27 +02:00
Eli Zaretskii
1b31a784bf Merge from origin/emacs-29
5bb5590dec Fix blunder in labeled_narrow_to_region
78ddb32fad Fix documentation of icon-elements
725a3f32f8 ; Fix typos in symbol names
6653ee66ca Improve two docstrings in ox-latex
7d869a0402 Doc fix in auth-source-read-char-choice
f149de223b Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/...
1f97a87879 Fix info-xref-tests
51f391998b Add @kindex in manuals for existing keybindings on 'C-x x...
2024-01-20 06:25:59 -05:00
Stefan Kangas
725a3f32f8 ; Fix typos in symbol names 2024-01-14 15:16:54 +01:00
Eli Zaretskii
5256b8dd4e Merge from origin/emacs-29
bf7034048c ; * doc/emacs/custom.texi (Changing a Variable): Update e...
466d1c98a9 Fix icons.el when icon does not exist as a file
2a861124e8 ; Improve documentation of 'buffer-match-p'
dc9d02f8a0 * lisp/isearch.el (isearch-search-and-update): Let-bind '...
9308d9a74a * src/comp.c (Fcomp__compile_ctxt_to_file): Fix hash tabl...
a2a6619b28 Provide decent documentation for 'help-quick'
ab66b749a2 ; * src/window.c (Fset_window_margins): Doc fix.
1a677d1429 treesit--pre-syntax-ppss: Fix args-out-of-range in intern...
2024-01-06 08:20:19 -05:00
Dmitry Gutov
1a677d1429 treesit--pre-syntax-ppss: Fix args-out-of-range in internal--syntax-propertize
* lisp/treesit.el (treesit--pre-syntax-ppss): Make sure the lower
bound is still within the current restriction (bug#67977).
2024-01-02 15:32:03 +02:00
Po Lu
ecf08f0621 Merge from savannah/emacs-29
dc4e6b1329 ; Update copyright years in more files
64b3777631 ; Run set-copyright from admin.el
8e1c56ae46 ; Add 2024 to copyright years

# Conflicts:
#	doc/misc/modus-themes.org
#	doc/misc/texinfo.tex
#	etc/NEWS
#	etc/refcards/ru-refcard.tex
#	etc/themes/modus-operandi-theme.el
#	etc/themes/modus-themes.el
#	etc/themes/modus-vivendi-theme.el
#	lib/alloca.in.h
#	lib/binary-io.h
#	lib/c-ctype.h
#	lib/c-strcasecmp.c
#	lib/c-strncasecmp.c
#	lib/careadlinkat.c
#	lib/cloexec.c
#	lib/close-stream.c
#	lib/diffseq.h
#	lib/dup2.c
#	lib/filemode.h
#	lib/fpending.c
#	lib/fpending.h
#	lib/fsusage.c
#	lib/getgroups.c
#	lib/getloadavg.c
#	lib/gettext.h
#	lib/gettime.c
#	lib/gettimeofday.c
#	lib/group-member.c
#	lib/malloc.c
#	lib/md5-stream.c
#	lib/md5.c
#	lib/md5.h
#	lib/memmem.c
#	lib/memrchr.c
#	lib/nanosleep.c
#	lib/save-cwd.h
#	lib/sha1.c
#	lib/sig2str.c
#	lib/stdlib.in.h
#	lib/strtoimax.c
#	lib/strtol.c
#	lib/strtoll.c
#	lib/time_r.c
#	lib/xalloc-oversized.h
#	lisp/auth-source-pass.el
#	lisp/emacs-lisp/lisp-mnt.el
#	lisp/emacs-lisp/timer.el
#	lisp/info-look.el
#	lisp/jit-lock.el
#	lisp/loadhist.el
#	lisp/mail/rmail.el
#	lisp/net/ntlm.el
#	lisp/net/webjump.el
#	lisp/progmodes/asm-mode.el
#	lisp/progmodes/project.el
#	lisp/progmodes/sh-script.el
#	lisp/textmodes/flyspell.el
#	lisp/textmodes/reftex-toc.el
#	lisp/textmodes/reftex.el
#	lisp/textmodes/tex-mode.el
#	lisp/url/url-gw.el
#	m4/alloca.m4
#	m4/clock_time.m4
#	m4/d-type.m4
#	m4/dirent_h.m4
#	m4/dup2.m4
#	m4/euidaccess.m4
#	m4/fchmodat.m4
#	m4/filemode.m4
#	m4/fsusage.m4
#	m4/getgroups.m4
#	m4/getloadavg.m4
#	m4/getrandom.m4
#	m4/gettime.m4
#	m4/gettimeofday.m4
#	m4/gnulib-common.m4
#	m4/group-member.m4
#	m4/inttypes.m4
#	m4/malloc.m4
#	m4/manywarnings.m4
#	m4/mempcpy.m4
#	m4/memrchr.m4
#	m4/mkostemp.m4
#	m4/mktime.m4
#	m4/nproc.m4
#	m4/nstrftime.m4
#	m4/pathmax.m4
#	m4/pipe2.m4
#	m4/pselect.m4
#	m4/pthread_sigmask.m4
#	m4/readlink.m4
#	m4/realloc.m4
#	m4/sig2str.m4
#	m4/ssize_t.m4
#	m4/stat-time.m4
#	m4/stddef_h.m4
#	m4/stdint.m4
#	m4/stdio_h.m4
#	m4/stdlib_h.m4
#	m4/stpcpy.m4
#	m4/strnlen.m4
#	m4/strtoimax.m4
#	m4/strtoll.m4
#	m4/time_h.m4
#	m4/timegm.m4
#	m4/timer_time.m4
#	m4/timespec.m4
#	m4/unistd_h.m4
#	m4/warnings.m4
#	nt/configure.bat
#	nt/preprep.c
#	test/lisp/register-tests.el
2024-01-02 10:28:14 +08:00
Po Lu
8e1c56ae46 ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
Eli Zaretskii
3b7198dc47 Merge from origin/emacs-29
5303152872 Revert "Fix treesit-node-field-name and friends (bug#66674)"
fa0bb88302 ; * src/buffer.c (syms_of_buffer) <default-directory>: Do...
44517037ae ; Fix typo
ccf46acefd ; Fix last change.
c86b039dff ; * etc/DEBUG: Improve advice for debugging native-compil...
9afba605bb Explain status "r" in `epa-list-keys`
6271422196 ; * lisp/dired.el (dired--make-directory-clickable): Refo...
fcbb004489 Fix mouse clicks on directory line in Dired
be8a7155b4 Fix 'split-root-window-right' and 'split-root-window-below'
eb19984c4d Mark icalendar.el as maintained by emacs-devel
03dc914fd3 ; Fix footnotes in ELisp Intro manual
ceacf75395 Fix usage of `setq-default' and offer more suggestions
2701da0eee Fix python-ts-mode triple quote syntax (bug#67262)
683c7c9687 Increment parser timestamp when narrowing changes (bug#67...
8ae42c825e ruby-ts-mode: Fix indentation for string_array closer
9cfa498e0a treesit-major-mode-setup: Use 'treesit--syntax-propertize...
da2e440462 ruby-ts-mode: Fix an out-of-bounds error with heredoc at eob
6ea507296a Correctly refontify changed region in tree-sitter modes (...
2023-12-30 04:51:17 -05:00
Yuan Fu
5303152872
Revert "Fix treesit-node-field-name and friends (bug#66674)"
This reverts commit 9874561f39.

See bug#67990.  Basically our original code is correct, the error is
in libtree-sitter, which only manifests in certain cases.

https://github.com/tree-sitter/tree-sitter/pull/2104
2023-12-29 19:52:07 -08:00
Dmitry Gutov
9cfa498e0a treesit-major-mode-setup: Use 'treesit--syntax-propertize-notifier'
* lisp/treesit.el (treesit-major-mode-setup): Make sure
'treesit--syntax-propertize-notifier' is used (bug#66732)
2023-12-24 04:07:15 +02:00
Yuan Fu
6ea507296a
Correctly refontify changed region in tree-sitter modes (bug#66732)
We already have treesit--font-lock-notifier that should mark changed
regions to be refontified, but it's called too late in the redsiplay &
fontification pipeline.  Here we add treesit--pre-redisplay that
forces reparse and calls notifier functions in
pre-redisplay-functions, which is early enough for the marking to take
effect.

Similarly, we force reparse in
syntax-propertize-extend-region-functions so syntax-ppss will have the
up-to-date syntax information when it scans the buffer text.  We also
record the lowest start position of the affected regions, and make
sure next syntex-propertize starts from that position.

* lisp/treesit.el (treesit--pre-redisplay-tick):
(treesit--syntax-propertize-start): New variable.
(treesit--syntax-propertize-notifier):
(treesit--pre-redisplay):
(treesit--pre-syntax-ppss): New functions.
(treesit-major-mode-setup): Add hooks.

* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode): Remove notifier.
(ruby-ts--parser-after-change): Remove notifier function.
2023-12-23 15:03:26 -08:00
Eli Zaretskii
a1d3862c62 Merge from origin/emacs-29
bf4ccb0be0 ; * lisp/term.el (term--xterm-paste): Fix last change.
0d9e2e448d ; * doc/lispref/functions.texi (Function Documentation): ...
791cc5065d Fix shaping of Sinhala text
efcbf0b5ab Add use cases of (fn) documentation facility.
c3331cb365 Fix pasting into terminal-mode on term.el
5be94e2bce Fix opening directory trees from Filesets menu
6b6e770a1f Eglot: Add ruff-lsp as an alternative Python server
ed8a8a5ba1 Fix symbol name in Multisession Variables examples
400ef15bdc js-ts-mode: Fix font-lock rules conflict
c165247c30 Add indentation rules for bracketless statements in js-ts...
7f1bd69cd1 Fix c-ts-mode bracketless indentation for BSD style (bug#...
e23068cb9a Add missing indent rules in c-ts-mode (bug#66152)
d2c4b926ac Fix treesit-default-defun-skipper (bug#66711)
9874561f39 Fix treesit-node-field-name and friends (bug#66674)
eace9e1122 python-ts-mode: Highlight default parameters
23c06c7c30 Update to Org 9.6.13
2023-12-16 09:17:51 -05:00
Yuan Fu
d2c4b926ac
Fix treesit-default-defun-skipper (bug#66711)
* lisp/treesit.el:
(treesit-default-defun-skipper): Add bol to the rx pattern.
2023-12-10 17:40:39 -08:00
Yuan Fu
9874561f39
Fix treesit-node-field-name and friends (bug#66674)
So turns out ts_node_field_name_for_child takes a named node index,
but we were passing it normal index that counts both named and
anonymous nodes.  That's what makes the field name all wrong in
treesit explorer.

* doc/lispref/parsing.texi:
(Accessing Node Information): Update docstring.
* lisp/treesit.el (treesit-node-index): Add some unrelated comment.
(treesit-node-field-name): Get named node index rather than all node
index.
* src/treesit.c (Ftreesit_node_field_name_for_child): Update
docstring, use ts_node_named_child_count.
2023-12-10 16:28:21 -08:00
Stefan Kangas
06a12b0ccc ; Fix typos 2023-12-10 13:22:04 +01:00
Eli Zaretskii
e32c57ed4d ; Fix make-obsolete warnings in treesit.el
* lisp/treesit.el (treesit-text-type-regexp)
(treesit-sentence-type-regexp, treesit--things-around)
(treesit-sexp-type-regexp): Fix obsolescence warnings.
2023-11-19 11:37:45 +02:00
Eli Zaretskii
c9d7740574 Merge from origin/emacs-29
ce0ebb91f2 Improve documentation of read syntax and printed represen...
81f84b00a5 ; * doc/lispref/modes.texi (Other Font Lock Variables): A...
434592b074 ; * lisp/dired.el (dired-use-ls-dired): Doc fix (bug#67053).
fe000236cf Improve documentation of signaling errors in batch mode
103ca678ac Fix treesit-simple-indent-presets docstring (bug#67007)
b7871cefe7 Prevent an infinite loop in todo-mode (bug#66994)
fa8cc4c9ee Fix cmake-ts-mode indentation (Bug#66845)
5bdc61bc0e Update to Org 9.6.11
18e2de1bec ; * lisp/bindings.el (right-word, left-word): Doc fix.
4f0fc3bfda ; Document core input events problems with XInput2
2023-11-11 05:31:52 -05:00
Yuan Fu
5dc3c9f4ec
Mark treesit--things-around obsolete
* lisp/treesit.el (treesit--things-around): Mark obsolete.
2023-11-09 21:20:26 -08:00