forked from Github/emacs
Merge from origin/emacs-29
92f753dc19; * etc/NEWS: Fix wording in last change.cef875f6c5; * etc/NEWS: Instructions for builds without tree-sitter...8d530ca654; Fix documentation of y-or-n-p/yes-or-no-pc18878ee0aFix bug in Tramp multi-hop7eed8e050a* lisp/files.el (find-sibling-rules): Fix docstring.6b5831c696Tree-sitter doc fixes (bug#60524)651927ac39; Fix function reference in comment in c-ts-mode.el (bug#...c786afcbb9Fontify C++ function definitions in c-ts-mode (bug#60529) # Conflicts: # etc/NEWS
This commit is contained in:
commit
e1b2446b2e
15 changed files with 67 additions and 51 deletions
|
|
@ -187,7 +187,7 @@
|
|||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dchild_002dcount"><span class="category">Function: </span><span><strong>treesit-child-count</strong> <em>node &optional named</em><a href='#index-treesit_002dchild_002dcount' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dt id="index-treesit_002dchild_002dcount"><span class="category">Function: </span><span><strong>treesit-node-child-count</strong> <em>node &optional named</em><a href='#index-treesit_002dchild_002dcount' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function finds the number of children of <var>node</var>. If
|
||||
<var>named</var> is non-nil, it only counts named child (see <a href="Language-Definitions.html#tree_002dsitter-named-node">named node</a>).
|
||||
</p></dd></dl>
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@
|
|||
</li></ul>
|
||||
|
||||
<p>In each of these directories, Emacs looks for a file with file-name
|
||||
extensions specified by the variable <code>treesit-load-suffixes</code>.
|
||||
extensions specified by the variable <code>dynamic-library-suffixes</code>.
|
||||
</p>
|
||||
<p>If Emacs cannot find the library or has problems loading it, Emacs
|
||||
signals the <code>treesit-load-language-error</code> error. The data of
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@
|
|||
tree-sitter query in either the string, s-expression or compiled form.
|
||||
</p>
|
||||
<p>For each <var>query</var>, the <var>:keyword</var>/<var>value</var> pairs that
|
||||
precede it add meta information to it. The <code>:lang</code> keyword
|
||||
precede it add meta information to it. The <code>:language</code> keyword
|
||||
declares <var>query</var>’s language. The <code>:feature</code> keyword sets the
|
||||
feature name of <var>query</var>. Users can control which features are
|
||||
enabled with <code>font-lock-maximum-decoration</code> and
|
||||
|
|
|
|||
|
|
@ -201,13 +201,13 @@
|
|||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnext_002dsibling"><span class="category">Function: </span><span><strong>treesit-next-sibling</strong> <em>node &optional named</em><a href='#index-treesit_002dnext_002dsibling' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dt id="index-treesit_002dnext_002dsibling"><span class="category">Function: </span><span><strong>treesit-node-next-sibling</strong> <em>node &optional named</em><a href='#index-treesit_002dnext_002dsibling' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function finds the next sibling of <var>node</var>. If <var>named</var> is
|
||||
non-<code>nil</code>, it finds the next named sibling.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dprev_002dsibling"><span class="category">Function: </span><span><strong>treesit-prev-sibling</strong> <em>node &optional named</em><a href='#index-treesit_002dprev_002dsibling' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dt id="index-treesit_002dprev_002dsibling"><span class="category">Function: </span><span><strong>treesit-node-prev-sibling</strong> <em>node &optional named</em><a href='#index-treesit_002dprev_002dsibling' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function finds the previous sibling of <var>node</var>. If
|
||||
<var>named</var> is non-<code>nil</code>, it finds the previous named sibling.
|
||||
</p></dd></dl>
|
||||
|
|
@ -221,13 +221,13 @@
|
|||
could have a <code>declarator</code> node and a <code>body</code> node.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dchild_002dby_002dfield_002dname"><span class="category">Function: </span><span><strong>treesit-child-by-field-name</strong> <em>node field-name</em><a href='#index-treesit_002dchild_002dby_002dfield_002dname' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dt id="index-treesit_002dchild_002dby_002dfield_002dname"><span class="category">Function: </span><span><strong>treesit-node-child-by-field-name</strong> <em>node field-name</em><a href='#index-treesit_002dchild_002dby_002dfield_002dname' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function finds the child of <var>node</var> whose field name is
|
||||
<var>field-name</var>, a string.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">;; Get the child that has "body" as its field name.
|
||||
(treesit-child-by-field-name node "body")
|
||||
(treesit-node-child-by-field-name node "body")
|
||||
⇒ #<treesit-node (compound_statement) in 45-89>
|
||||
</pre></div>
|
||||
</dd></dl>
|
||||
|
|
@ -237,7 +237,7 @@
|
|||
<span id="index-syntax-tree-nodes_002c-by-position"></span>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dfirst_002dchild_002dfor_002dpos"><span class="category">Function: </span><span><strong>treesit-first-child-for-pos</strong> <em>node pos &optional named</em><a href='#index-treesit_002dfirst_002dchild_002dfor_002dpos' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dt id="index-treesit_002dfirst_002dchild_002dfor_002dpos"><span class="category">Function: </span><span><strong>treesit-node-first-child-for-pos</strong> <em>node pos &optional named</em><a href='#index-treesit_002dfirst_002dchild_002dfor_002dpos' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function finds the first child of <var>node</var> that extends beyond
|
||||
buffer position <var>pos</var>. “Extends beyond” means the end of the
|
||||
child node is greater or equal to <var>pos</var>. This function only looks
|
||||
|
|
|
|||
|
|
@ -142,12 +142,12 @@
|
|||
ts_node_named_child_count treesit-node-child-count
|
||||
ts_node_child_by_field_name treesit-node-by-field-name
|
||||
ts_node_child_by_field_id
|
||||
ts_node_next_sibling treesit-next-sibling
|
||||
ts_node_prev_sibling treesit-prev-sibling
|
||||
ts_node_next_named_sibling treesit-next-sibling
|
||||
ts_node_prev_named_sibling treesit-prev-sibling
|
||||
ts_node_first_child_for_byte treesit-first-child-for-pos
|
||||
ts_node_first_named_child_for_byte treesit-first-child-for-pos
|
||||
ts_node_next_sibling treesit-node-next-sibling
|
||||
ts_node_prev_sibling treesit-node-prev-sibling
|
||||
ts_node_next_named_sibling treesit-node-next-sibling
|
||||
ts_node_prev_named_sibling treesit-node-prev-sibling
|
||||
ts_node_first_child_for_byte treesit-node-first-child-for-pos
|
||||
ts_node_first_named_child_for_byte treesit-node-first-child-for-pos
|
||||
ts_node_descendant_for_byte_range treesit-descendant-for-range
|
||||
ts_node_descendant_for_point_range
|
||||
ts_node_named_descendant_for_byte_range treesit-descendant-for-range
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ Concretely, something like this:
|
|||
...
|
||||
(cond
|
||||
;; Tree-sitter.
|
||||
((treesit-ready-p 'python-mode 'python)
|
||||
((treesit-ready-p 'python)
|
||||
(treesit-parser-create 'python)
|
||||
(setq-local treesit-font-lock-settings python--treesit-settings)
|
||||
(setq-local treesit-font-lock-feature-list
|
||||
|
|
|
|||
|
|
@ -4054,7 +4054,7 @@ tree-sitter query in either the string, s-expression or compiled form.
|
|||
|
||||
@c FIXME: Cross-ref treesit-font-lock-level to user manual.
|
||||
For each @var{query}, the @var{:keyword}/@var{value} pairs that
|
||||
precede it add meta information to it. The @code{:lang} keyword
|
||||
precede it add meta information to it. The @code{:language} keyword
|
||||
declares @var{query}'s language. The @code{:feature} keyword sets the
|
||||
feature name of @var{query}. Users can control which features are
|
||||
enabled with @code{treesit-font-lock-level} and
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ For example, the C language grammar is represented as the symbol
|
|||
|
||||
@vindex treesit-extra-load-path
|
||||
@vindex treesit-load-language-error
|
||||
@vindex treesit-load-suffixes
|
||||
Tree-sitter language grammar are distributed as dynamic libraries.
|
||||
In order to use a language grammar in Emacs, you need to make sure
|
||||
that the dynamic library is installed on the system. Emacs looks for
|
||||
|
|
@ -83,7 +82,7 @@ and finally, in the system's default locations for dynamic libraries.
|
|||
@end itemize
|
||||
|
||||
In each of these directories, Emacs looks for a file with file-name
|
||||
extensions specified by the variable @code{treesit-load-suffixes}.
|
||||
extensions specified by the variable @code{dynamic-library-suffixes}.
|
||||
|
||||
If Emacs cannot find the library or has problems loading it, Emacs
|
||||
signals the @code{treesit-load-language-error} error. The data of
|
||||
|
|
@ -677,12 +676,12 @@ This function returns all of @var{node}'s children as a list. If
|
|||
@var{named} is non-@code{nil}, it retrieves only named nodes.
|
||||
@end defun
|
||||
|
||||
@defun treesit-next-sibling node &optional named
|
||||
@defun treesit-node-next-sibling node &optional named
|
||||
This function finds the next sibling of @var{node}. If @var{named} is
|
||||
non-@code{nil}, it finds the next named sibling.
|
||||
@end defun
|
||||
|
||||
@defun treesit-prev-sibling node &optional named
|
||||
@defun treesit-node-prev-sibling node &optional named
|
||||
This function finds the previous sibling of @var{node}. If
|
||||
@var{named} is non-@code{nil}, it finds the previous named sibling.
|
||||
@end defun
|
||||
|
|
@ -696,14 +695,14 @@ assign @dfn{field names} to child nodes (@pxref{tree-sitter node field
|
|||
name, field name}). For example, a @code{function_definition} node
|
||||
could have a @code{declarator} node and a @code{body} node.
|
||||
|
||||
@defun treesit-child-by-field-name node field-name
|
||||
@defun treesit-node-child-by-field-name node field-name
|
||||
This function finds the child of @var{node} whose field name is
|
||||
@var{field-name}, a string.
|
||||
|
||||
@example
|
||||
@group
|
||||
;; Get the child that has "body" as its field name.
|
||||
(treesit-child-by-field-name node "body")
|
||||
(treesit-node-child-by-field-name node "body")
|
||||
@result{} #<treesit-node (compound_statement) in 45-89>
|
||||
@end group
|
||||
@end example
|
||||
|
|
@ -713,7 +712,7 @@ This function finds the child of @var{node} whose field name is
|
|||
@cindex nodes, by position
|
||||
@cindex syntax tree nodes, by position
|
||||
|
||||
@defun treesit-first-child-for-pos node pos &optional named
|
||||
@defun treesit-node-first-child-for-pos node pos &optional named
|
||||
This function finds the first child of @var{node} that extends beyond
|
||||
buffer position @var{pos}. ``Extends beyond'' means the end of the
|
||||
child node is greater or equal to @var{pos}. This function only looks
|
||||
|
|
@ -1002,7 +1001,7 @@ Note that @var{n} counts both named and anonymous child. And @var{n}
|
|||
could be negative, e.g., @code{-1} represents the last child.
|
||||
@end defun
|
||||
|
||||
@defun treesit-child-count node &optional named
|
||||
@defun treesit-node-child-count node &optional named
|
||||
This function finds the number of children of @var{node}. If
|
||||
@var{named} is non-@code{nil}, it only counts named children
|
||||
(@pxref{tree-sitter named node, named node}).
|
||||
|
|
@ -1694,7 +1693,7 @@ this pattern:
|
|||
...
|
||||
(cond
|
||||
;; Tree-sitter setup.
|
||||
((treesit-ready-p 'woomy-mode 'woomy)
|
||||
((treesit-ready-p 'woomy)
|
||||
(setq-local treesit-variables ...)
|
||||
(treesit-major-mode-setup))
|
||||
;; Non-tree-sitter setup.
|
||||
|
|
@ -1706,7 +1705,7 @@ this pattern:
|
|||
First, the major mode should use @code{treesit-ready-p} to determine
|
||||
whether tree-sitter can be activated in this mode.
|
||||
|
||||
@defun treesit-ready-p mode language &optional quiet
|
||||
@defun treesit-ready-p language &optional quiet
|
||||
This function checks for conditions for activating tree-sitter. It
|
||||
checks whether Emacs was built with tree-sitter, whether the buffer's
|
||||
size is not too large for tree-sitter to handle it, and whether the
|
||||
|
|
@ -1734,7 +1733,7 @@ If @code{treesit-font-lock-settings} (@pxref{Parser-based Font Lock})
|
|||
is non-@code{nil}, it sets up fontification.
|
||||
|
||||
@item
|
||||
If @code{treesit-simple-indent-rules} (@pxref{Parser-based Font Lock})
|
||||
If @code{treesit-simple-indent-rules} (@pxref{Parser-based Indentation})
|
||||
is non-@code{nil}, it sets up indentation.
|
||||
|
||||
@item
|
||||
|
|
@ -1897,12 +1896,12 @@ ts_node_named_child treesit-node-child
|
|||
ts_node_named_child_count treesit-node-child-count
|
||||
ts_node_child_by_field_name treesit-node-by-field-name
|
||||
ts_node_child_by_field_id
|
||||
ts_node_next_sibling treesit-next-sibling
|
||||
ts_node_prev_sibling treesit-prev-sibling
|
||||
ts_node_next_named_sibling treesit-next-sibling
|
||||
ts_node_prev_named_sibling treesit-prev-sibling
|
||||
ts_node_first_child_for_byte treesit-first-child-for-pos
|
||||
ts_node_first_named_child_for_byte treesit-first-child-for-pos
|
||||
ts_node_next_sibling treesit-node-next-sibling
|
||||
ts_node_prev_sibling treesit-node-prev-sibling
|
||||
ts_node_next_named_sibling treesit-node-next-sibling
|
||||
ts_node_prev_named_sibling treesit-node-prev-sibling
|
||||
ts_node_first_child_for_byte treesit-node-first-child-for-pos
|
||||
ts_node_first_named_child_for_byte treesit-node-first-child-for-pos
|
||||
ts_node_descendant_for_byte_range treesit-descendant-for-range
|
||||
ts_node_descendant_for_point_range
|
||||
ts_node_named_descendant_for_byte_range treesit-descendant-for-range
|
||||
|
|
|
|||
|
|
@ -3157,6 +3157,15 @@ files, the new modes based on tree-sitter are for now entirely
|
|||
optional, and you must turn them on manually, or customize
|
||||
'auto-mode-alist' to turn them on automatically.
|
||||
|
||||
Where no major modes previously existed in Emacs for editing the kinds
|
||||
of files for which Emacs now provides a tree-sitter based mode, Emacs
|
||||
will now try to enable these new modes automatically when you visit
|
||||
such files, and will display a warning if the tree-sitter library or
|
||||
the parser grammar library is not available. To prevent the warnings,
|
||||
either build Emacs with tree-sitter and install the grammar libraries,
|
||||
or customize 'auto-mode-alist' to specify some other major mode (or
|
||||
even Fundamental mode) for those kinds of files.
|
||||
|
||||
Each major mode based on tree-sitter needs a language grammar library,
|
||||
usually named "libtree-sitter-LANG.so" ("libtree-sitter-LANG.dll" on
|
||||
MS-Windows), where LANG is the corresponding language name. Emacs
|
||||
|
|
|
|||
|
|
@ -7414,9 +7414,9 @@ files, you could say something like:
|
|||
|
||||
(\"src/emacs/[^/]+/\\\\(.*\\\\)\\\\\\='\" \"src/emacs/.*/\\\\1\\\\\\='\")
|
||||
|
||||
In this example, if you're in src/emacs/emacs-27/lisp/abbrev.el,
|
||||
and you an src/emacs/emacs-28/lisp/abbrev.el file exists, it's
|
||||
now defined as a sibling."
|
||||
In this example, if you're in \"src/emacs/emacs-27/lisp/abbrev.el\",
|
||||
and a \"src/emacs/emacs-28/lisp/abbrev.el\" file exists, it's now
|
||||
defined as a sibling."
|
||||
:type 'sexp
|
||||
:version "29.1")
|
||||
|
||||
|
|
|
|||
|
|
@ -4715,7 +4715,8 @@ Do not set it manually, it is used buffer-local in `tramp-get-lock-pid'.")
|
|||
(or
|
||||
;; The host name is used for the remote shell command.
|
||||
(member
|
||||
'("%h") (tramp-get-method-parameter item 'tramp-login-args))
|
||||
"%h" (tramp-compat-flatten-tree
|
||||
(tramp-get-method-parameter item 'tramp-login-args)))
|
||||
;; The host name must match previous hop.
|
||||
(string-match-p previous-host host))
|
||||
(setq tramp-default-proxies-alist saved-tdpa)
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ MODE is either `c' or `cpp'."
|
|||
:language mode
|
||||
:feature 'assignment
|
||||
;; TODO: Recursively highlight identifiers in parenthesized
|
||||
;; expressions, see `c-ts-mode--fontify-struct-declarator' for
|
||||
;; expressions, see `c-ts-mode--fontify-declarator' for
|
||||
;; inspiration.
|
||||
'((assignment_expression
|
||||
left: (identifier) @font-lock-variable-name-face)
|
||||
|
|
@ -430,6 +430,9 @@ MODE is either `c' or `cpp'."
|
|||
((or "function_declarator" "array_declarator" "init_declarator")
|
||||
(c-ts-mode--declarator-identifier
|
||||
(treesit-node-child-by-field-name node "declarator")))
|
||||
("qualified_identifier"
|
||||
(c-ts-mode--declarator-identifier
|
||||
(treesit-node-child-by-field-name node "name")))
|
||||
;; Terminal case.
|
||||
((or "identifier" "field_identifier")
|
||||
node)))
|
||||
|
|
@ -439,7 +442,14 @@ MODE is either `c' or `cpp'."
|
|||
For NODE, OVERRIDE, START, END, and ARGS, see
|
||||
`treesit-font-lock-rules'."
|
||||
(let* ((identifier (c-ts-mode--declarator-identifier node))
|
||||
(face (pcase (treesit-node-type (treesit-node-parent identifier))
|
||||
(qualified-root
|
||||
(treesit-parent-while (treesit-node-parent identifier)
|
||||
(lambda (node)
|
||||
(equal (treesit-node-type node)
|
||||
"qualified_identifier"))))
|
||||
(face (pcase (treesit-node-type (treesit-node-parent
|
||||
(or qualified-root
|
||||
identifier)))
|
||||
("function_declarator" 'font-lock-function-name-face)
|
||||
(_ 'font-lock-variable-name-face))))
|
||||
(treesit-fontify-with-override
|
||||
|
|
|
|||
|
|
@ -3557,8 +3557,7 @@ character. This is not possible when using `read-key', but using
|
|||
Return t if answer is \"y\" and nil if it is \"n\".
|
||||
|
||||
PROMPT is the string to display to ask the question; `y-or-n-p'
|
||||
adds \" (y or n) \" to it. It does not need to end in space, but
|
||||
if it does up to one space will be removed.
|
||||
adds \"(y or n) \" to it.
|
||||
|
||||
If you bind the variable `help-form' to a non-nil value
|
||||
while calling this function, then pressing `help-char'
|
||||
|
|
|
|||
|
|
@ -1288,8 +1288,7 @@ the function."
|
|||
(cdr exp))))
|
||||
;; Presets override functions, so this condition comes before
|
||||
;; `functionp'.
|
||||
((alist-get exp treesit-simple-indent-presets)
|
||||
(alist-get exp treesit-simple-indent-presets))
|
||||
((alist-get exp treesit-simple-indent-presets))
|
||||
((functionp exp) exp)
|
||||
((symbolp exp)
|
||||
(if (null exp)
|
||||
|
|
@ -2952,8 +2951,8 @@ function signals an error."
|
|||
:eg-result-string "#<treesit-node (init_declarator) in 5-10>")
|
||||
|
||||
|
||||
(treesit-first-child-for-pos
|
||||
:no-eval (treesit-first-child-for-pos node 1)
|
||||
(treesit-node-first-child-for-pos
|
||||
:no-eval (treesit-node-first-child-for-pos node 1)
|
||||
:eg-result-string "#<treesit-node (primitive_type) in 1-4>")
|
||||
(treesit-node-descendant-for-range
|
||||
:no-eval (treesit-node-descendant-for-range node 2 3)
|
||||
|
|
@ -3027,11 +3026,11 @@ function signals an error."
|
|||
:eg-result t)
|
||||
|
||||
|
||||
(treesit-field-name-for-child
|
||||
:no-eval (treesit-field-name-for-child node)
|
||||
(treesit-node-field-name-for-child
|
||||
:no-eval (treesit-node-field-name-for-child node)
|
||||
:eg-result "body")
|
||||
(treesit-child-count
|
||||
:no-eval (treesit-child-count node)
|
||||
(treesit-node-child-count
|
||||
:no-eval (treesit-node-child-count node)
|
||||
:eg-result 3)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3173,8 +3173,7 @@ DEFUN ("yes-or-no-p", Fyes_or_no_p, Syes_or_no_p, 1, 1, 0,
|
|||
Return t if answer is yes, and nil if the answer is no.
|
||||
|
||||
PROMPT is the string to display to ask the question; `yes-or-no-p'
|
||||
adds \"(yes or no) \" to it. It does not need to end in space, but if
|
||||
it does up to one space will be removed.
|
||||
adds \"(yes or no) \" to it.
|
||||
|
||||
The user must confirm the answer with RET, and can edit it until it
|
||||
has been confirmed.
|
||||
|
|
|
|||
Loading…
Reference in a new issue