From 0bebd0e5f09b6fbed2e54f9b8464e93bdd6ad11e Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 19 Mar 2023 08:09:33 +0200 Subject: ; Remove 'build-module' and 'html-manual' directories from 'admin' These files were temporarily in the repository and are no longer needed, once they fulfilled their job. --- admin/notes/tree-sitter/build-module/README | 17 - admin/notes/tree-sitter/build-module/batch.sh | 27 -- admin/notes/tree-sitter/build-module/build.sh | 86 ---- .../tree-sitter/html-manual/Accessing-Node.html | 205 ---------- .../html-manual/Language-Definitions.html | 401 ------------------ .../html-manual/Multiple-Languages.html | 327 --------------- .../html-manual/Parser_002dbased-Font-Lock.html | 247 ----------- .../html-manual/Parser_002dbased-Indentation.html | 280 ------------- .../html-manual/Parsing-Program-Source.html | 125 ------ .../tree-sitter/html-manual/Pattern-Matching.html | 450 --------------------- .../tree-sitter/html-manual/Retrieving-Node.html | 420 ------------------- .../html-manual/Tree_002dsitter-C-API.html | 211 ---------- .../tree-sitter/html-manual/Using-Parser.html | 230 ----------- .../notes/tree-sitter/html-manual/build-manual.sh | 23 -- admin/notes/tree-sitter/html-manual/manual.css | 374 ----------------- 15 files changed, 3423 deletions(-) delete mode 100644 admin/notes/tree-sitter/build-module/README delete mode 100755 admin/notes/tree-sitter/build-module/batch.sh delete mode 100755 admin/notes/tree-sitter/build-module/build.sh delete mode 100644 admin/notes/tree-sitter/html-manual/Accessing-Node.html delete mode 100644 admin/notes/tree-sitter/html-manual/Language-Definitions.html delete mode 100644 admin/notes/tree-sitter/html-manual/Multiple-Languages.html delete mode 100644 admin/notes/tree-sitter/html-manual/Parser_002dbased-Font-Lock.html delete mode 100644 admin/notes/tree-sitter/html-manual/Parser_002dbased-Indentation.html delete mode 100644 admin/notes/tree-sitter/html-manual/Parsing-Program-Source.html delete mode 100644 admin/notes/tree-sitter/html-manual/Pattern-Matching.html delete mode 100644 admin/notes/tree-sitter/html-manual/Retrieving-Node.html delete mode 100644 admin/notes/tree-sitter/html-manual/Tree_002dsitter-C-API.html delete mode 100644 admin/notes/tree-sitter/html-manual/Using-Parser.html delete mode 100755 admin/notes/tree-sitter/html-manual/build-manual.sh delete mode 100644 admin/notes/tree-sitter/html-manual/manual.css diff --git a/admin/notes/tree-sitter/build-module/README b/admin/notes/tree-sitter/build-module/README deleted file mode 100644 index 2fcb9778dae..00000000000 --- a/admin/notes/tree-sitter/build-module/README +++ /dev/null @@ -1,17 +0,0 @@ -To build the language definition for a particular language, run - - ./build.sh - -eg, - - ./build.sh html - -The dynamic module will be in /dist directory - -To build all modules at once, run - - ./batch.sh - -This gives you C, JSON, Go, HTML, Javascript, CSS, Python, Typescript -(tsx), C# (csharp), C++ (cpp), Rust. More can be added to batch.sh -unless it's directory structure is not standard. \ No newline at end of file diff --git a/admin/notes/tree-sitter/build-module/batch.sh b/admin/notes/tree-sitter/build-module/batch.sh deleted file mode 100755 index 58272c74549..00000000000 --- a/admin/notes/tree-sitter/build-module/batch.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -languages=( - 'bash' - 'c' - 'cmake' - 'cpp' - 'css' - 'c-sharp' - 'dockerfile' - 'go' - 'go-mod' - 'html' - 'javascript' - 'json' - 'python' - 'rust' - 'toml' - 'tsx' - 'typescript' - 'yaml' -) - -for language in "${languages[@]}" -do - ./build.sh $language -done diff --git a/admin/notes/tree-sitter/build-module/build.sh b/admin/notes/tree-sitter/build-module/build.sh deleted file mode 100755 index 9dc674237ca..00000000000 --- a/admin/notes/tree-sitter/build-module/build.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash - -lang=$1 -topdir="$PWD" - -case $(uname) in - "Darwin") - soext="dylib" - ;; - *"MINGW"*) - soext="dll" - ;; - *) - soext="so" - ;; -esac - -echo "Building ${lang}" - -### Retrieve sources - -org="tree-sitter" -repo="tree-sitter-${lang}" -sourcedir="tree-sitter-${lang}/src" -grammardir="tree-sitter-${lang}" - -case "${lang}" in - "dockerfile") - org="camdencheek" - ;; - "cmake") - org="uyha" - ;; - "go-mod") - # The parser is called "gomod". - lang="gomod" - org="camdencheek" - ;; - "typescript") - sourcedir="tree-sitter-typescript/typescript/src" - grammardir="tree-sitter-typescript/typescript" - ;; - "tsx") - repo="tree-sitter-typescript" - sourcedir="tree-sitter-typescript/tsx/src" - grammardir="tree-sitter-typescript/tsx" - ;; - "yaml") - org="ikatyang" - ;; -esac - -git clone "https://github.com/${org}/${repo}.git" \ - --depth 1 --quiet -cp "${grammardir}"/grammar.js "${sourcedir}" -# We have to go into the source directory to compile, because some -# C files refer to files like "../../common/scanner.h". -cd "${sourcedir}" - -### Build - -cc -fPIC -c -I. parser.c -# Compile scanner.c. -if test -f scanner.c -then - cc -fPIC -c -I. scanner.c -fi -# Compile scanner.cc. -if test -f scanner.cc -then - c++ -fPIC -I. -c scanner.cc -fi -# Link. -if test -f scanner.cc -then - c++ -fPIC -shared *.o -o "libtree-sitter-${lang}.${soext}" -else - cc -fPIC -shared *.o -o "libtree-sitter-${lang}.${soext}" -fi - -### Copy out - -mkdir -p "${topdir}/dist" -cp "libtree-sitter-${lang}.${soext}" "${topdir}/dist" -cd "${topdir}" -rm -rf "${repo}" diff --git a/admin/notes/tree-sitter/html-manual/Accessing-Node.html b/admin/notes/tree-sitter/html-manual/Accessing-Node.html deleted file mode 100644 index afbbdaa11b5..00000000000 --- a/admin/notes/tree-sitter/html-manual/Accessing-Node.html +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - -Accessing Node (GNU Emacs Lisp Reference Manual) - - - - - - - - - - - - - - - - - - - - - -
- -
-

37.4 Accessing Node Information

- -

Before going further, make sure you have read the basic conventions -about tree-sitter nodes in the previous node. -

-

Basic information

- -

Every node is associated with a parser, and that parser is associated -with a buffer. The following functions let you retrieve them. -

-
-
Function: treesit-node-parser node
-

This function returns node’s associated parser. -

- -
-
Function: treesit-node-buffer node
-

This function returns node’s parser’s associated buffer. -

- -
-
Function: treesit-node-language node
-

This function returns node’s parser’s associated language. -

- -

Each node represents a piece of text in the buffer. Functions below -finds relevant information about that text. -

-
-
Function: treesit-node-start node
-

Return the start position of node. -

- -
-
Function: treesit-node-end node
-

Return the end position of node. -

- -
-
Function: treesit-node-text node &optional object
-

Returns the buffer text that node represents. (If node is -retrieved from parsing a string, it will be text from that string.) -

- -

Here are some basic checks on tree-sitter nodes. -

-
-
Function: treesit-node-p object
-

Checks if object is a tree-sitter syntax node. -

- -
-
Function: treesit-node-eq node1 node2
-

Checks if node1 and node2 are the same node in a syntax -tree. -

- -

Property information

- -

In general, nodes in a concrete syntax tree fall into two categories: -named nodes and anonymous nodes. Whether a node is named -or anonymous is determined by the language definition -(see named node). -

- -

Apart from being named/anonymous, a node can have other properties. A -node can be “missing”: missing nodes are inserted by the parser in -order to recover from certain kinds of syntax errors, i.e., something -should probably be there according to the grammar, but not there. -

- -

A node can be “extra”: extra nodes represent things like comments, -which can appear anywhere in the text. -

- -

A node “has changes” if the buffer changed since when the node is -retrieved, i.e., outdated. -

- -

A node “has error” if the text it spans contains a syntax error. It -can be the node itself has an error, or one of its -children/grandchildren... has an error. -

-
-
Function: treesit-node-check node property
-

This function checks if node has property. property -can be 'named, 'missing, 'extra, -'has-changes, or 'has-error. -

- - -
-
Function: treesit-node-type node
-

Named nodes have “types” (see node type). -For example, a named node can be a string_literal node, where -string_literal is its type. -

-

This function returns node’s type as a string. -

- -

Information as a child or parent

- -
-
Function: treesit-node-index node &optional named
-

This function returns the index of node as a child node of its -parent. If named is non-nil, it only count named nodes -(see named node). -

- -
-
Function: treesit-node-field-name node
-

A child of a parent node could have a field name (see field name). This function returns the field name -of node as a child of its parent. -

- -
-
Function: treesit-node-field-name-for-child node n
-

This function returns the field name of the n’th child of -node. -

- -
-
Function: treesit-node-child-count node &optional named
-

This function finds the number of children of node. If -named is non-nil, it only counts named child (see named node). -

- -
-
- - - - - - diff --git a/admin/notes/tree-sitter/html-manual/Language-Definitions.html b/admin/notes/tree-sitter/html-manual/Language-Definitions.html deleted file mode 100644 index 9b1e0021272..00000000000 --- a/admin/notes/tree-sitter/html-manual/Language-Definitions.html +++ /dev/null @@ -1,401 +0,0 @@ - - - - - - -Language Definitions (GNU Emacs Lisp Reference Manual) - - - - - - - - - - - - - - - - - - - - -
- -
-

37.1 Tree-sitter Language Definitions

- - -

Loading a language definition

- - - -

Tree-sitter relies on language definitions to parse text in that -language. In Emacs, a language definition is represented by a symbol. -For example, the C language definition is represented as the symbol -c, and c can be passed to tree-sitter functions as the -language argument. -

- - - -

Tree-sitter language definitions are distributed as dynamic libraries. -In order to use a language definition in Emacs, you need to make sure -that the dynamic library is installed on the system. Emacs looks for -language definitions in several places, in the following order: -

-
    -
  • first, in the list of directories specified by the variable -treesit-extra-load-path; -
  • then, in the tree-sitter subdirectory of the directory -specified by user-emacs-directory (see The Init File); -
  • and finally, in the system’s default locations for dynamic libraries. -
- -

In each of these directories, Emacs looks for a file with file-name -extensions specified by the variable dynamic-library-suffixes. -

-

If Emacs cannot find the library or has problems loading it, Emacs -signals the treesit-load-language-error error. The data of -that signal could be one of the following: -

-
-
(not-found error-msg …)
-

This means that Emacs could not find the language definition library. -

-
(symbol-error error-msg)
-

This means that Emacs could not find in the library the expected function -that every language definition library should export. -

-
(version-mismatch error-msg)
-

This means that the version of language definition library is incompatible -with that of the tree-sitter library. -

-
- -

In all of these cases, error-msg might provide additional -details about the failure. -

-
-
Function: treesit-language-available-p language &optional detail
-

This function returns non-nil if the language definitions for -language exist and can be loaded. -

-

If detail is non-nil, return (t . nil) when -language is available, and (nil . data) when it’s -unavailable. data is the signal data of -treesit-load-language-error. -

- - -

By convention, the file name of the dynamic library for language is -libtree-sitter-language.ext, where ext is the -system-specific extension for dynamic libraries. Also by convention, -the function provided by that library is named -tree_sitter_language. If a language definition library -doesn’t follow this convention, you should add an entry -

-
-
(language library-base-name function-name)
-
- -

to the list in the variable treesit-load-name-override-list, where -library-base-name is the basename of the dynamic library’s file name, -(usually, libtree-sitter-language), and -function-name is the function provided by the library -(usually, tree_sitter_language). For example, -

-
-
(cool-lang "libtree-sitter-coool" "tree_sitter_cooool")
-
- -

for a language that considers itself too “cool” to abide by -conventions. -

- -
-
Function: treesit-language-version &optional min-compatible
-

This function returns the version of the language-definition -Application Binary Interface (ABI) supported by the -tree-sitter library. By default, it returns the latest ABI version -supported by the library, but if min-compatible is -non-nil, it returns the oldest ABI version which the library -still can support. Language definition libraries must be built for -ABI versions between the oldest and the latest versions supported by -the tree-sitter library, otherwise the library will be unable to load -them. -

- -

Concrete syntax tree

- - -

A syntax tree is what a parser generates. In a syntax tree, each node -represents a piece of text, and is connected to each other by a -parent-child relationship. For example, if the source text is -

-
-
1 + 2
-
- -

its syntax tree could be -

-
-
                  +--------------+
-                  | root "1 + 2" |
-                  +--------------+
-                         |
-        +--------------------------------+
-        |       expression "1 + 2"       |
-        +--------------------------------+
-           |             |            |
-+------------+   +--------------+   +------------+
-| number "1" |   | operator "+" |   | number "2" |
-+------------+   +--------------+   +------------+
-
- -

We can also represent it as an s-expression: -

-
-
(root (expression (number) (operator) (number)))
-
- -

Node types

- - - - - -

Names like root, expression, number, and -operator specify the type of the nodes. However, not all -nodes in a syntax tree have a type. Nodes that don’t have a type are -known as anonymous nodes, and nodes with a type are named -nodes. Anonymous nodes are tokens with fixed spellings, including -punctuation characters like bracket ‘]’, and keywords like -return. -

-

Field names

- - - -

To make the syntax tree easier to analyze, many language definitions -assign field names to child nodes. For example, a -function_definition node could have a declarator and a -body: -

-
-
(function_definition
- declarator: (declaration)
- body: (compound_statement))
-
- -

Exploring the syntax tree

- - - -

To aid in understanding the syntax of a language and in debugging of -Lisp program that use the syntax tree, Emacs provides an “explore” -mode, which displays the syntax tree of the source in the current -buffer in real time. Emacs also comes with an “inspect mode”, which -displays information of the nodes at point in the mode-line. -

-
-
Command: treesit-explore-mode
-

This mode pops up a window displaying the syntax tree of the source in -the current buffer. Selecting text in the source buffer highlights -the corresponding nodes in the syntax tree display. Clicking -on nodes in the syntax tree highlights the corresponding text in the -source buffer. -

- -
-
Command: treesit-inspect-mode
-

This minor mode displays on the mode-line the node that starts -at point. For example, the mode-line can display -

-
-
parent field: (node (child (…)))
-
- -

where node, child, etc., are nodes which begin at point. -parent is the parent of node. node is displayed in -a bold typeface. field-names are field names of node and -of child, etc. -

-

If no node starts at point, i.e., point is in the middle of a node, -then the mode line displays the earliest node that spans point, and -its immediate parent. -

-

This minor mode doesn’t create parsers on its own. It uses the first -parser in (treesit-parser-list) (see Using Tree-sitter Parser). -

- -

Reading the grammar definition

- - -

Authors of language definitions define the grammar of a -programming language, which determines how a parser constructs a -concrete syntax tree out of the program text. In order to use the -syntax tree effectively, you need to consult the grammar file. -

-

The grammar file is usually grammar.js in a language -definition’s project repository. The link to a language definition’s -home page can be found on -tree-sitter’s -homepage. -

-

The grammar definition is written in JavaScript. For example, the -rule matching a function_definition node looks like -

-
-
function_definition: $ => seq(
-  $.declaration_specifiers,
-  field('declarator', $.declaration),
-  field('body', $.compound_statement)
-)
-
- -

The rules are represented by functions that take a single argument -$, representing the whole grammar. The function itself is -constructed by other functions: the seq function puts together -a sequence of children; the field function annotates a child -with a field name. If we write the above definition in the so-called -Backus-Naur Form (BNF) syntax, it would look like -

-
-
function_definition :=
-  <declaration_specifiers> <declaration> <compound_statement>
-
- -

and the node returned by the parser would look like -

-
-
(function_definition
-  (declaration_specifier)
-  declarator: (declaration)
-  body: (compound_statement))
-
- -

Below is a list of functions that one can see in a grammar definition. -Each function takes other rules as arguments and returns a new rule. -

-
-
seq(rule1, rule2, …)
-

matches each rule one after another. -

-
choice(rule1, rule2, …)
-

matches one of the rules in its arguments. -

-
repeat(rule)
-

matches rule for zero or more times. -This is like the ‘*’ operator in regular expressions. -

-
repeat1(rule)
-

matches rule for one or more times. -This is like the ‘+’ operator in regular expressions. -

-
optional(rule)
-

matches rule for zero or one time. -This is like the ‘?’ operator in regular expressions. -

-
field(name, rule)
-

assigns field name name to the child node matched by rule. -

-
alias(rule, alias)
-

makes nodes matched by rule appear as alias in the syntax -tree generated by the parser. For example, -

-
-
alias(preprocessor_call_exp, call_expression)
-
- -

makes any node matched by preprocessor_call_exp appear as -call_expression. -

-
- -

Below are grammar functions of lesser importance for reading a -language definition. -

-
-
token(rule)
-

marks rule to produce a single leaf node. That is, instead of -generating a parent node with individual child nodes under it, -everything is combined into a single leaf node. See Retrieving Nodes. -

-
token.immediate(rule)
-

Normally, grammar rules ignore preceding whitespace; this -changes rule to match only when there is no preceding -whitespaces. -

-
prec(n, rule)
-

gives rule the level-n precedence. -

-
prec.left([n,] rule)
-

marks rule as left-associative, optionally with level n. -

-
prec.right([n,] rule)
-

marks rule as right-associative, optionally with level n. -

-
prec.dynamic(n, rule)
-

this is like prec, but the precedence is applied at runtime -instead. -

-
- -

The documentation of the tree-sitter project has -more -about writing a grammar. Read especially “The Grammar DSL” -section. -

-
-
- - - - - - diff --git a/admin/notes/tree-sitter/html-manual/Multiple-Languages.html b/admin/notes/tree-sitter/html-manual/Multiple-Languages.html deleted file mode 100644 index 390d9082590..00000000000 --- a/admin/notes/tree-sitter/html-manual/Multiple-Languages.html +++ /dev/null @@ -1,327 +0,0 @@ - - - - - - -Multiple Languages (GNU Emacs Lisp Reference Manual) - - - - - - - - - - - - - - - - - - - - - -
- -
-

37.6 Parsing Text in Multiple Languages

- - -

Sometimes, the source of a programming language could contain snippets -of other languages; HTML + CSS + JavaScript is one -example. In that case, text segments written in different languages -need to be assigned different parsers. Traditionally, this is -achieved by using narrowing. While tree-sitter works with narrowing -(see narrowing), the recommended way is -instead to set regions of buffer text (i.e., ranges) in which a parser -will operate. This section describes functions for setting and -getting ranges for a parser. -

-

Lisp programs should call treesit-update-ranges to make sure -the ranges for each parser are correct before using parsers in a -buffer, and call treesit-language-at to figure out the language -responsible for the text at some position. These two functions don’t -work by themselves, they need major modes to set -treesit-range-settings and -treesit-language-at-point-function, which do the actual work. -These functions and variables are explained in more detail towards the -end of the section. -

-

Getting and setting ranges

- -
-
Function: treesit-parser-set-included-ranges parser ranges
-

This function sets up parser to operate on ranges. The -parser will only read the text of the specified ranges. Each -range in ranges is a list of the form (beg . end). -

-

The ranges in ranges must come in order and must not overlap. -That is, in pseudo code: -

-
-
(cl-loop for idx from 1 to (1- (length ranges))
-         for prev = (nth (1- idx) ranges)
-         for next = (nth idx ranges)
-         should (<= (car prev) (cdr prev)
-                    (car next) (cdr next)))
-
- - -

If ranges violates this constraint, or something else went -wrong, this function signals the treesit-range-invalid error. -The signal data contains a specific error message and the ranges we -are trying to set. -

-

This function can also be used for disabling ranges. If ranges -is nil, the parser is set to parse the whole buffer. -

-

Example: -

-
-
(treesit-parser-set-included-ranges
- parser '((1 . 9) (16 . 24) (24 . 25)))
-
-
- -
-
Function: treesit-parser-included-ranges parser
-

This function returns the ranges set for parser. The return -value is the same as the ranges argument of -treesit-parser-included-ranges: a list of cons cells of the form -(beg . end). If parser doesn’t have any -ranges, the return value is nil. -

-
-
(treesit-parser-included-ranges parser)
-    ⇒ ((1 . 9) (16 . 24) (24 . 25))
-
-
- -
-
Function: treesit-query-range source query &optional beg end
-

This function matches source with query and returns the -ranges of captured nodes. The return value is a list of cons cells of -the form (beg . end), where beg and -end specify the beginning and the end of a region of text. -

-

For convenience, source can be a language symbol, a parser, or a -node. If it’s a language symbol, this function matches in the root -node of the first parser using that language; if a parser, this -function matches in the root node of that parser; if a node, this -function matches in that node. -

-

The argument query is the query used to capture nodes -(see Pattern Matching Tree-sitter Nodes). The capture names don’t matter. The -arguments beg and end, if both non-nil, limit the -range in which this function queries. -

-

Like other query functions, this function raises the -treesit-query-error error if query is malformed. -

- -

Supporting multiple languages in Lisp programs

- -

It should suffice for general Lisp programs to call the following two -functions in order to support program sources that mixes multiple -languages. -

-
-
Function: treesit-update-ranges &optional beg end
-

This function updates ranges for parsers in the buffer. It makes sure -the parsers’ ranges are set correctly between beg and end, -according to treesit-range-settings. If omitted, beg -defaults to the beginning of the buffer, and end defaults to the -end of the buffer. -

-

For example, fontification functions use this function before querying -for nodes in a region. -

- -
-
Function: treesit-language-at pos
-

This function returns the language of the text at buffer position -pos. Under the hood it calls -treesit-language-at-point-function and returns its return -value. If treesit-language-at-point-function is nil, -this function returns the language of the first parser in the returned -value of treesit-parser-list. If there is no parser in the -buffer, it returns nil. -

- -

Supporting multiple languages in major modes

- - - - -

Normally, in a set of languages that can be mixed together, there is a -host language and one or more embedded languages. A Lisp -program usually first parses the whole document with the host -language’s parser, retrieves some information, sets ranges for the -embedded languages with that information, and then parses the embedded -languages. -

-

Take a buffer containing HTML, CSS and JavaScript -as an example. A Lisp program will first parse the whole buffer with -an HTML parser, then query the parser for -style_element and script_element nodes, which -correspond to CSS and JavaScript text, respectively. Then -it sets the range of the CSS and JavaScript parser to the -ranges in which their corresponding nodes span. -

-

Given a simple HTML document: -

-
-
<html>
-  <script>1 + 2</script>
-  <style>body { color: "blue"; }</style>
-</html>
-
- -

a Lisp program will first parse with a HTML parser, then set -ranges for CSS and JavaScript parsers: -

-
-
;; Create parsers.
-(setq html (treesit-parser-create 'html))
-(setq css (treesit-parser-create 'css))
-(setq js (treesit-parser-create 'javascript))
-
-
-
;; Set CSS ranges.
-(setq css-range
-      (treesit-query-range
-       'html
-       "(style_element (raw_text) @capture)"))
-(treesit-parser-set-included-ranges css css-range)
-
-
-
;; Set JavaScript ranges.
-(setq js-range
-      (treesit-query-range
-       'html
-       "(script_element (raw_text) @capture)"))
-(treesit-parser-set-included-ranges js js-range)
-
- -

Emacs automates this process in treesit-update-ranges. A -multi-language major mode should set treesit-range-settings so -that treesit-update-ranges knows how to perform this process -automatically. Major modes should use the helper function -treesit-range-rules to generate a value that can be assigned to -treesit-range-settings. The settings in the following example -directly translate into operations shown above. -

-
-
(setq-local treesit-range-settings
-            (treesit-range-rules
-             :embed 'javascript
-             :host 'html
-             '((script_element (raw_text) @capture))
-
-
-
             :embed 'css
-             :host 'html
-             '((style_element (raw_text) @capture))))
-
- -
-
Function: treesit-range-rules &rest query-specs
-

This function is used to set treesit-range-settings. It -takes care of compiling queries and other post-processing, and outputs -a value that treesit-range-settings can have. -

-

It takes a series of query-specs, where each query-spec is -a query preceded by zero or more keyword/value -pairs. Each query is a tree-sitter query in either the -string, s-expression or compiled form, or a function. -

-

If query is a tree-sitter query, it should be preceded by two -:keyword/value pairs, where the :embed keyword -specifies the embedded language, and the :host keyword -specified the host language. -

-

treesit-update-ranges uses query to figure out how to set -the ranges for parsers for the embedded language. It queries -query in a host language parser, computes the ranges in which -the captured nodes span, and applies these ranges to embedded -language parsers. -

-

If query is a function, it doesn’t need any :keyword and -value pair. It should be a function that takes 2 arguments, -start and end, and sets the ranges for parsers in the -current buffer in the region between start and end. It is -fine for this function to set ranges in a larger region that -encompasses the region between start and end. -

- -
-
Variable: treesit-range-settings
-

This variable helps treesit-update-ranges in updating the -ranges for parsers in the buffer. It is a list of settings -where the exact format of a setting is considered internal. You -should use treesit-range-rules to generate a value that this -variable can have. -

-
- - -
-
Variable: treesit-language-at-point-function
-

This variable’s value should be a function that takes a single -argument, pos, which is a buffer position, and returns the -language of the buffer text at pos. This variable is used by -treesit-language-at. -

- -
-
- - - - - - diff --git a/admin/notes/tree-sitter/html-manual/Parser_002dbased-Font-Lock.html b/admin/notes/tree-sitter/html-manual/Parser_002dbased-Font-Lock.html deleted file mode 100644 index a3fe6622162..00000000000 --- a/admin/notes/tree-sitter/html-manual/Parser_002dbased-Font-Lock.html +++ /dev/null @@ -1,247 +0,0 @@ - - - - - - -Parser-based Font Lock (GNU Emacs Lisp Reference Manual) - - - - - - - - - - - - - - - - - - - - -
- -
-

24.6.10 Parser-based Font Lock

- - - -

Besides simple syntactic font lock and regexp-based font lock, Emacs -also provides complete syntactic font lock with the help of a parser. -Currently, Emacs uses the tree-sitter library (see Parsing Program Source) for this purpose. -

-

Parser-based font lock and other font lock mechanisms are not mutually -exclusive. By default, if enabled, parser-based font lock runs first, -replacing syntactic font lock, then the regexp-based font lock. -

-

Although parser-based font lock doesn’t share the same customization -variables with regexp-based font lock, it uses similar customization -schemes. The tree-sitter counterpart of font-lock-keywords is -treesit-font-lock-settings. -

- - -

In general, tree-sitter fontification works as follows: -

-
    -
  • A Lisp program (usually, part of a major mode) provides a query -consisting of patterns, each pattern associated with a -capture name. - -
  • The tree-sitter library finds the nodes in the parse tree -that match these patterns, tags the nodes with the corresponding -capture names, and returns them to the Lisp program. - -
  • The Lisp program uses the returned nodes to highlight the portions of -buffer text corresponding to each node as appropriate, using the -tagged capture names of the nodes to determine the correct -fontification. For example, a node tagged font-lock-keyword -would be highlighted in font-lock-keyword face. -
- -

For more information about queries, patterns, and capture names, see -Pattern Matching Tree-sitter Nodes. -

-

To setup tree-sitter fontification, a major mode should first set -treesit-font-lock-settings with the output of -treesit-font-lock-rules, then call -treesit-major-mode-setup. -

-
-
Function: treesit-font-lock-rules &rest query-specs
-

This function is used to set treesit-font-lock-settings. It -takes care of compiling queries and other post-processing, and outputs -a value that treesit-font-lock-settings accepts. Here’s an -example: -

-
-
(treesit-font-lock-rules
- :language 'javascript
- :feature 'constant
- :override t
- '((true) @font-lock-constant-face
-   (false) @font-lock-constant-face)
- :language 'html
- :feature 'script
- "(script_element) @font-lock-builtin-face")
-
- -

This function takes a series of query-specs, where each -query-spec is a query preceded by one or more -:keyword/value pairs. Each query is a -tree-sitter query in either the string, s-expression or compiled form. -

-

For each query, the :keyword/value pairs that -precede it add meta information to it. The :language keyword -declares query’s language. The :feature keyword sets the -feature name of query. Users can control which features are -enabled with font-lock-maximum-decoration and -treesit-font-lock-feature-list (described below). These two -keywords are mandatory. -

-

Other keywords are optional: -

- - - - - - - -
KeywordValueDescription
:overridenilIf the region already has a face, discard the new face
tAlways apply the new face
appendAppend the new face to existing ones
prependPrepend the new face to existing ones
keepFill-in regions without an existing face
- -

Lisp programs mark patterns in query with capture names (names -that starts with @), and tree-sitter will return matched nodes -tagged with those same capture names. For the purpose of -fontification, capture names in query should be face names like -font-lock-keyword-face. The captured node will be fontified -with that face. -

- -

Capture names can also be function names, in which case the function -is called with 4 arguments: node and override, start -and end, where node is the node itself, override is -the override property of the rule which captured this node, and -start and end limits the region in which this function -should fontify. (If this function wants to respect the override -argument, it can use treesit-fontify-with-override.) -

-

Beyond the 4 arguments presented, this function should accept more -arguments as optional arguments for future extensibility. -

-

If a capture name is both a face and a function, the face takes -priority. If a capture name is neither a face nor a function, it is -ignored. -

- -
-
Variable: treesit-font-lock-feature-list
-

This is a list of lists of feature symbols. Each element of the list -is a list that represents a decoration level. -font-lock-maximum-decoration controls which levels are -activated. -

-

Each element of the list is a list of the form (feature …), where each feature corresponds to the -:feature value of a query defined in -treesit-font-lock-rules. Removing a feature symbol from this -list disables the corresponding query during font-lock. -

-

Common feature names, for many programming languages, include -definition, type, assignment, builtin, -constant, keyword, string-interpolation, -comment, doc, string, operator, -preprocessor, escape-sequence, and key. Major -modes are free to subdivide or extend these common features. -

-

Some of these features warrant some explanation: definition -highlights whatever is being defined, e.g., the function name in a -function definition, the struct name in a struct definition, the -variable name in a variable definition; assignment highlights -the whatever is being assigned to, e.g., the variable or field in an -assignment statement; key highlights keys in key-value pairs, -e.g., keys in a JSON object, or a Python dictionary; doc -highlights docstrings or doc-comments. -

-

For example, the value of this variable could be: -

-
((comment string doc) ; level 1
- (function-name keyword type builtin constant) ; level 2
- (variable-name string-interpolation key)) ; level 3
-
- -

Major modes should set this variable before calling -treesit-major-mode-setup. -

- -

For this variable to take effect, a Lisp program should call -treesit-font-lock-recompute-features (which resets -treesit-font-lock-settings accordingly), or -treesit-major-mode-setup (which calls -treesit-font-lock-recompute-features). -

- -
-
Variable: treesit-font-lock-settings
-

A list of settings for tree-sitter based font lock. The exact format -of each setting is considered internal. One should always use -treesit-font-lock-rules to set this variable. -

-
- -

Multi-language major modes should provide range functions in -treesit-range-functions, and Emacs will set the ranges -accordingly before fontifing a region (see Parsing Text in Multiple Languages). -

-
-
- - - - - - diff --git a/admin/notes/tree-sitter/html-manual/Parser_002dbased-Indentation.html b/admin/notes/tree-sitter/html-manual/Parser_002dbased-Indentation.html deleted file mode 100644 index cf1257f3102..00000000000 --- a/admin/notes/tree-sitter/html-manual/Parser_002dbased-Indentation.html +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - -Parser-based Indentation (GNU Emacs Lisp Reference Manual) - - - - - - - - - - - - - - - - - - - - -
- -
-

24.7.2 Parser-based Indentation

- - - -

When built with the tree-sitter library (see Parsing Program Source), Emacs is capable of parsing the program source and producing -a syntax tree. This syntax tree can be used for guiding the program -source indentation commands. For maximum flexibility, it is possible -to write a custom indentation function that queries the syntax tree -and indents accordingly for each language, but that is a lot of work. -It is more convenient to use the simple indentation engine described -below: then the major mode needs only to write some indentation rules -and the engine takes care of the rest. -

-

To enable the parser-based indentation engine, either set -treesit-simple-indent-rules and call -treesit-major-mode-setup, or equivalently, set the value of -indent-line-function to treesit-indent. -

-
-
Variable: treesit-indent-function
-

This variable stores the actual function called by -treesit-indent. By default, its value is -treesit-simple-indent. In the future we might add other, -more complex indentation engines. -

- -

Writing indentation rules

- - -
-
Variable: treesit-simple-indent-rules
-

This local variable stores indentation rules for every language. It is -a list of the form: (language . rules), where -language is a language symbol, and rules is a list of the -form (matcher anchor offset). -

-

First, Emacs passes the smallest tree-sitter node at the beginning of -the current line to matcher; if it returns non-nil, this -rule is applicable. Then Emacs passes the node to anchor, which -returns a buffer position. Emacs takes the column number of that -position, adds offset to it, and the result is the indentation -column for the current line. offset can be an integer or a -variable whose value is an integer. -

-

The matcher and anchor are functions, and Emacs provides -convenient defaults for them. -

-

Each matcher or anchor is a function that takes three -arguments: node, parent, and bol. The argument -bol is the buffer position whose indentation is required: the -position of the first non-whitespace character after the beginning of -the line. The argument node is the largest (highest-in-tree) -node that starts at that position; and parent is the parent of -node. However, when that position is in a whitespace or inside -a multi-line string, no node can start at that position, so -node is nil. In that case, parent would be the -smallest node that spans that position. -

-

Emacs finds bol, node and parent and -passes them to each matcher and anchor. matcher -should return non-nil if the rule is applicable, and -anchor should return a buffer position. -

- -
-
Variable: treesit-simple-indent-presets
-

This is a list of defaults for matchers and anchors in -treesit-simple-indent-rules. Each of them represents a function -that takes 3 arguments: node, parent and bol. The -available default functions are: -

-
-
no-node
-

This matcher is a function that is called with 3 arguments: -node, parent, and bol, and returns non-nil, -indicating a match, if node is nil, i.e., there is no -node that starts at bol. This is the case when bol is on -an empty line or inside a multi-line string, etc. -

-
-
parent-is
-

This matcher is a function of one argument, type; it returns a -function that is called with 3 arguments: node, parent, -and bol, and returns non-nil (i.e., a match) if -parent’s type matches regexp type. -

-
-
node-is
-

This matcher is a function of one argument, type; it returns a -function that is called with 3 arguments: node, parent, -and bol, and returns non-nil if node’s type matches -regexp type. -

-
-
query
-

This matcher is a function of one argument, query; it returns a -function that is called with 3 arguments: node, parent, -and bol, and returns non-nil if querying parent -with query captures node (see Pattern Matching Tree-sitter Nodes). -

-
-
match
-

This matcher is a function of 5 arguments: node-type, -parent-type, node-field, node-index-min, and -node-index-max). It returns a function that is called with 3 -arguments: node, parent, and bol, and returns -non-nil if node’s type matches regexp node-type, -parent’s type matches regexp parent-type, node’s -field name in parent matches regexp node-field, and -node’s index among its siblings is between node-index-min -and node-index-max. If the value of an argument is nil, -this matcher doesn’t check that argument. For example, to match the -first child where parent is argument_list, use -

-
-
(match nil "argument_list" nil nil 0 0)
-
- -
-
comment-end
-

This matcher is a function that is called with 3 arguments: -node, parent, and bol, and returns non-nil if -point is before a comment ending token. Comment ending tokens are -defined by regular expression treesit-comment-end -(see treesit-comment-end). -

-
-
first-sibling
-

This anchor is a function that is called with 3 arguments: node, -parent, and bol, and returns the start of the first child -of parent. -

-
-
parent
-

This anchor is a function that is called with 3 arguments: node, -parent, and bol, and returns the start of parent. -

-
-
parent-bol
-

This anchor is a function that is called with 3 arguments: node, -parent, and bol, and returns the first non-space character -on the line of parent. -

-
-
prev-sibling
-

This anchor is a function that is called with 3 arguments: node, -parent, and bol, and returns the start of the previous -sibling of node. -

-
-
no-indent
-

This anchor is a function that is called with 3 arguments: node, -parent, and bol, and returns the start of node. -

-
-
prev-line
-

This anchor is a function that is called with 3 arguments: node, -parent, and bol, and returns the first non-whitespace -character on the previous line. -

-
-
point-min
-

This anchor is a function that is called with 3 arguments: node, -parent, and bol, and returns the beginning of the buffer. -This is useful as the beginning of the buffer is always at column 0. -

-
-
comment-start
-

This anchor is a function that is called with 3 arguments: node, -parent, and bol, and returns the position right after the -comment-start token. Comment-start tokens are defined by regular -expression treesit-comment-start (see treesit-comment-start). This function assumes parent is -the comment node. -

-
-
comment-start-skip
-

This anchor is a function that is called with 3 arguments: node, -parent, and bol, and returns the position after the -comment-start token and any whitespace characters following that -token. Comment-start tokens are defined by regular expression -treesit-comment-start. This function assumes parent is -the comment node. -

-
-
- -

Indentation utilities

- - -

Here are some utility functions that can help writing parser-based -indentation rules. -

-
-
Function: treesit-check-indent mode
-

This function checks the current buffer’s indentation against major -mode mode. It indents the current buffer according to -mode and compares the results with the current indentation. -Then it pops up a buffer showing the differences. Correct -indentation (target) is shown in green color, current indentation is -shown in red color.

- -

It is also helpful to use treesit-inspect-mode (see Tree-sitter Language Definitions) when writing indentation rules. -

-
-
- - - - - - diff --git a/admin/notes/tree-sitter/html-manual/Parsing-Program-Source.html b/admin/notes/tree-sitter/html-manual/Parsing-Program-Source.html deleted file mode 100644 index 58f6b4e9d5a..00000000000 --- a/admin/notes/tree-sitter/html-manual/Parsing-Program-Source.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - -Parsing Program Source (GNU Emacs Lisp Reference Manual) - - - - - - - - - - - - - - - - - - - - - -
- -
-

37 Parsing Program Source

- - -

Emacs provides various ways to parse program source text and produce a -syntax tree. In a syntax tree, text is no longer considered a -one-dimensional stream of characters, but a structured tree of nodes, -where each node representing a piece of text. Thus, a syntax tree can -enable interesting features like precise fontification, indentation, -navigation, structured editing, etc. -

-

Emacs has a simple facility for parsing balanced expressions -(see Parsing Expressions). There is also the SMIE library for -generic navigation and indentation (see Simple Minded Indentation Engine). -

-

In addition to those, Emacs also provides integration with -the tree-sitter -library) if support for it was compiled in. The tree-sitter library -implements an incremental parser and has support from a wide range of -programming languages. -

-
-
Function: treesit-available-p
-

This function returns non-nil if tree-sitter features are -available for the current Emacs session. -

- -

To be able to parse the program source using the tree-sitter library -and access the syntax tree of the program, a Lisp program needs to -load a language definition library, and create a parser for that -language and the current buffer. After that, the Lisp program can -query the parser about specific nodes of the syntax tree. Then, it -can access various kinds of information about each node, and search -for nodes using a powerful pattern-matching syntax. This chapter -explains how to do all this, and also how a Lisp program can work with -source files that mix multiple programming languages. -

- - -
-
- - - - - - diff --git a/admin/notes/tree-sitter/html-manual/Pattern-Matching.html b/admin/notes/tree-sitter/html-manual/Pattern-Matching.html deleted file mode 100644 index 9ef536b79dd..00000000000 --- a/admin/notes/tree-sitter/html-manual/Pattern-Matching.html +++ /dev/null @@ -1,450 +0,0 @@ - - - - - - -Pattern Matching (GNU Emacs Lisp Reference Manual) - - - - - - - - - - - - - - - - - - - - - -
- -
-

37.5 Pattern Matching Tree-sitter Nodes

- - - -

Tree-sitter lets Lisp programs match patterns using a small -declarative language. This pattern matching consists of two steps: -first tree-sitter matches a pattern against nodes in the syntax -tree, then it captures specific nodes that matched the pattern -and returns the captured nodes. -

-

We describe first how to write the most basic query pattern and how to -capture nodes in a pattern, then the pattern-matching function, and -finally the more advanced pattern syntax. -

-

Basic query syntax

- - - - -

A query consists of multiple patterns. Each pattern is an -s-expression that matches a certain node in the syntax node. A -pattern has the form (type (child…)) -

-

For example, a pattern that matches a binary_expression node that -contains number_literal child nodes would look like -

-
-
(binary_expression (number_literal))
-
- -

To capture a node using the query pattern above, append -@capture-name after the node pattern you want to -capture. For example, -

-
-
(binary_expression (number_literal) @number-in-exp)
-
- -

captures number_literal nodes that are inside a -binary_expression node with the capture name -number-in-exp. -

-

We can capture the binary_expression node as well, with, for -example, the capture name biexp: -

-
-
(binary_expression
- (number_literal) @number-in-exp) @biexp
-
- -

Query function

- - -

Now we can introduce the query functions. -

-
-
Function: treesit-query-capture node query &optional beg end node-only
-

This function matches patterns in query within node. -The argument query can be either a string, a s-expression, or a -compiled query object. For now, we focus on the string syntax; -s-expression syntax and compiled query are described at the end of the -section. -

-

The argument node can also be a parser or a language symbol. A -parser means using its root node, a language symbol means find or -create a parser for that language in the current buffer, and use the -root node. -

-

The function returns all the captured nodes in a list of the form -(capture_name . node). If node-only is -non-nil, it returns the list of nodes instead. By default the -entire text of node is searched, but if beg and end -are both non-nil, they specify the region of buffer text where -this function should match nodes. Any matching node whose span -overlaps with the region between beg and end are captured, -it doesn’t have to be completely in the region. -

- - -

This function raises the treesit-query-error error if -query is malformed. The signal data contains a description of -the specific error. You can use treesit-query-validate to -validate and debug the query. -

- -

For example, suppose node’s text is 1 + 2, and -query is -

-
-
(setq query
-      "(binary_expression
-        (number_literal) @number-in-exp) @biexp")
-
- -

Matching that query would return -

-
-
(treesit-query-capture node query)
-    ⇒ ((biexp . <node for "1 + 2">)
-       (number-in-exp . <node for "1">)
-       (number-in-exp . <node for "2">))
-
- -

As mentioned earlier, query could contain multiple patterns. -For example, it could have two top-level patterns: -

-
-
(setq query
-      "(binary_expression) @biexp
-       (number_literal)  @number @biexp")
-
- -
-
Function: treesit-query-string string query language
-

This function parses string with language, matches its -root node with query, and returns the result. -

- -

More query syntax

- -

Besides node type and capture, tree-sitter’s pattern syntax can -express anonymous node, field name, wildcard, quantification, -grouping, alternation, anchor, and predicate. -

-

Anonymous node

- -

An anonymous node is written verbatim, surrounded by quotes. A -pattern matching (and capturing) keyword return would be -

-
-
"return" @keyword
-
- -

Wild card

- -

In a pattern, ‘(_)’ matches any named node, and ‘_’ matches -any named and anonymous node. For example, to capture any named child -of a binary_expression node, the pattern would be -

-
-
(binary_expression (_) @in_biexp)
-
- -

Field name

- -

It is possible to capture child nodes that have specific field names. -In the pattern below, declarator and body are field -names, indicated by the colon following them. -

-
-
(function_definition
-  declarator: (_) @func-declarator
-  body: (_) @func-body)
-
- -

It is also possible to capture a node that doesn’t have a certain -field, say, a function_definition without a body field. -

-
-
(function_definition !body) @func-no-body
-
- -

Quantify node

- - -

Tree-sitter recognizes quantification operators ‘*’, ‘+’ and -‘?’. Their meanings are the same as in regular expressions: -‘*’ matches the preceding pattern zero or more times, ‘+’ -matches one or more times, and ‘?’ matches zero or one time. -

-

For example, the following pattern matches type_declaration -nodes that has zero or more long keyword. -

-
-
(type_declaration "long"*) @long-type
-
- -

The following pattern matches a type declaration that has zero or one -long keyword: -

-
-
(type_declaration "long"?) @long-type
-
- -

Grouping

- -

Similar to groups in regular expression, we can bundle patterns into -groups and apply quantification operators to them. For example, to -express a comma separated list of identifiers, one could write -

-
-
(identifier) ("," (identifier))*
-
- -

Alternation

- -

Again, similar to regular expressions, we can express “match anyone -from this group of patterns” in a pattern. The syntax is a list of -patterns enclosed in square brackets. For example, to capture some -keywords in C, the pattern would be -

-
-
[
-  "return"
-  "break"
-  "if"
-  "else"
-] @keyword
-
- -

Anchor

- -

The anchor operator ‘.’ can be used to enforce juxtaposition, -i.e., to enforce two things to be directly next to each other. The -two “things” can be two nodes, or a child and the end of its parent. -For example, to capture the first child, the last child, or two -adjacent children: -

-
-
;; Anchor the child with the end of its parent.
-(compound_expression (_) @last-child .)
-
-
-
;; Anchor the child with the beginning of its parent.
-(compound_expression . (_) @first-child)
-
-
-
;; Anchor two adjacent children.
-(compound_expression
- (_) @prev-child
- .
- (_) @next-child)
-
- -

Note that the enforcement of juxtaposition ignores any anonymous -nodes. -

-

Predicate

- -

It is possible to add predicate constraints to a pattern. For -example, with the following pattern: -

-
-
(
- (array . (_) @first (_) @last .)
- (#equal @first @last)
-)
-
- -

tree-sitter only matches arrays where the first element equals to -the last element. To attach a predicate to a pattern, we need to -group them together. A predicate always starts with a ‘#’. -Currently there are two predicates, #equal and #match. -

-
-
Predicate: equal arg1 arg2
-

Matches if arg1 equals to arg2. Arguments can be either -strings or capture names. Capture names represent the text that the -captured node spans in the buffer. -

- -
-
Predicate: match regexp capture-name
-

Matches if the text that capture-name’s node spans in the buffer -matches regular expression regexp. Matching is case-sensitive. -

- -

Note that a predicate can only refer to capture names that appear in -the same pattern. Indeed, it makes little sense to refer to capture -names in other patterns. -

-

S-expression patterns

- - - -

Besides strings, Emacs provides a s-expression based syntax for -tree-sitter patterns. It largely resembles the string-based syntax. -For example, the following query -

-
-
(treesit-query-capture
- node "(addition_expression
-        left: (_) @left
-        \"+\" @plus-sign
-        right: (_) @right) @addition
-
-        [\"return\" \"break\"] @keyword")
-
- -

is equivalent to -

-
-
(treesit-query-capture
- node '((addition_expression
-         left: (_) @left
-         "+" @plus-sign
-         right: (_) @right) @addition
-
-         ["return" "break"] @keyword))
-
- -

Most patterns can be written directly as strange but nevertheless -valid s-expressions. Only a few of them needs modification: -

-
    -
  • Anchor ‘.’ is written as :anchor. -
  • ?’ is written as ‘:?’. -
  • *’ is written as ‘:*’. -
  • +’ is written as ‘:+’. -
  • #equal is written as :equal. In general, predicates -change their ‘#’ to ‘:’. -
- -

For example, -

-
-
"(
-  (compound_expression . (_) @first (_)* @rest)
-  (#match \"love\" @first)
-  )"
-
- -

is written in s-expression as -

-
-
'((
-   (compound_expression :anchor (_) @first (_) :* @rest)
-   (:match "love" @first)
-   ))
-
- -

Compiling queries

- - - -

If a query is intended to be used repeatedly, especially in tight -loops, it is important to compile that query, because a compiled query -is much faster than an uncompiled one. A compiled query can be used -anywhere a query is accepted. -

-
-
Function: treesit-query-compile language query
-

This function compiles query for language into a compiled -query object and returns it. -

-

This function raises the treesit-query-error error if -query is malformed. The signal data contains a description of -the specific error. You can use treesit-query-validate to -validate and debug the query. -

- -
-
Function: treesit-query-language query
-

This function return the language of query. -

- -
-
Function: treesit-query-expand query
-

This function converts the s-expression query into the string -format. -

- -
-
Function: treesit-pattern-expand pattern
-

This function converts the s-expression pattern into the string -format. -

- -

For more details, read the tree-sitter project’s documentation about -pattern-matching, which can be found at -https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries. -

-
-
- - - - - - diff --git a/admin/notes/tree-sitter/html-manual/Retrieving-Node.html b/admin/notes/tree-sitter/html-manual/Retrieving-Node.html deleted file mode 100644 index 16eeb0b1091..00000000000 --- a/admin/notes/tree-sitter/html-manual/Retrieving-Node.html +++ /dev/null @@ -1,420 +0,0 @@ - - - - - - -Retrieving Node (GNU Emacs Lisp Reference Manual) - - - - - - - - - - - - - - - - - - - - - -
- -
-

37.3 Retrieving Node

- - - - - -

Here’s some terminology and conventions we use when documenting -tree-sitter functions. -

-

We talk about a node being “smaller” or “larger”, and “lower” or -“higher”. A smaller and lower node is lower in the syntax tree and -therefore spans a smaller portion of buffer text; a larger and higher -node is higher up in the syntax tree, it contains many smaller nodes -as its children, and therefore spans a larger portion of text. -

-

When a function cannot find a node, it returns nil. For -convenience, all functions that take a node as argument and return -a node, also accept the node argument of nil and in that case -just return nil. -

- -

Nodes are not automatically updated when the associated buffer is -modified, and there is no way to update a node once it is retrieved. -Using an outdated node signals the treesit-node-outdated error. -

-

Retrieving node from syntax tree

- - - -
-
Function: treesit-node-at pos &optional parser-or-lang named
-

This function returns the smallest node that starts at or after -the buffer position pos. In other words, the start of the node -is greater or equal to pos. -

-

When parser-or-lang is nil or omitted, this function uses -the first parser in (treesit-parser-list) of the current -buffer. If parser-or-lang is a parser object, it uses that -parser; if parser-or-lang is a language, it finds the first -parser using that language in (treesit-parser-list), and uses -that. -

-

If named is non-nil, this function looks for a named node -only (see named node). -

-

When pos is after all the text in the buffer, technically there -is no node after pos. But for convenience, this function will -return the last leaf node in the parse tree. If strict is -non-nil, this function will strictly comply to the semantics and -return nil. -

-

Example: -

-
-
;; Find the node at point in a C parser's syntax tree.
-(treesit-node-at (point) 'c)
-  ⇒ #<treesit-node (primitive_type) in 23-27>
-
-
- -
-
Function: treesit-node-on beg end &optional parser-or-lang named
-

This function returns the smallest node that covers the region -of buffer text between beg and end. In other words, the -start of the node is before or at beg, and the end of the node -is at or after end. -

-

Beware: calling this function on an empty line that is not -inside any top-level construct (function definition, etc.) most -probably will give you the root node, because the root node is the -smallest node that covers that empty line. Most of the time, you want -to use treesit-node-at, described above, instead. -

-

When parser-or-lang is nil, this function uses the first -parser in (treesit-parser-list) of the current buffer. If -parser-or-lang is a parser object, it uses that parser; if -parser-or-lang is a language, it finds the first parser using -that language in (treesit-parser-list), and uses that. -

-

If named is non-nil, this function looks for a named node -only (see named node). -

- -
-
Function: treesit-parser-root-node parser
-

This function returns the root node of the syntax tree generated by -parser. -

- -
-
Function: treesit-buffer-root-node &optional language
-

This function finds the first parser that uses language in -(treesit-parser-list) of the current buffer, and returns the -root node generated by that parser. If it cannot find an appropriate -parser, it returns nil. -

- -

Given a node, a Lisp program can retrieve other nodes starting from -it, or query for information about this node. -

-

Retrieving node from other nodes

- - -

By kinship

- - - - -
-
Function: treesit-node-parent node
-

This function returns the immediate parent of node. -

- -
-
Function: treesit-node-child node n &optional named
-

This function returns the n’th child of node. If -named is non-nil, it counts only named nodes -(see named node). -

-

For example, in a node that represents a string "text", there -are three children nodes: the opening quote ", the string text -text, and the closing quote ". Among these nodes, the -first child is the opening quote ", and the first named child -is the string text. -

-

This function returns nil if there is no n’th child. -n could be negative, e.g., -1 represents the last child. -

- -
-
Function: treesit-node-children node &optional named
-

This function returns all of node’s children as a list. If -named is non-nil, it retrieves only named nodes. -

- -
-
Function: treesit-node-next-sibling node &optional named
-

This function finds the next sibling of node. If named is -non-nil, it finds the next named sibling. -

- -
-
Function: treesit-node-prev-sibling node &optional named
-

This function finds the previous sibling of node. If -named is non-nil, it finds the previous named sibling. -

- -

By field name

- - - -

To make the syntax tree easier to analyze, many language definitions -assign field names to child nodes (see field name). For example, a function_definition node -could have a declarator node and a body node. -

-
-
Function: treesit-node-child-by-field-name node field-name
-

This function finds the child of node whose field name is -field-name, a string. -

-
-
;; Get the child that has "body" as its field name.
-(treesit-node-child-by-field-name node "body")
-  ⇒ #<treesit-node (compound_statement) in 45-89>
-
-
- -

By position

- - - -
-
Function: treesit-node-first-child-for-pos node pos &optional named
-

This function finds the first child of node that extends beyond -buffer position pos. “Extends beyond” means the end of the -child node is greater or equal to pos. This function only looks -for immediate children of node, and doesn’t look in its -grandchildren. If named is non-nil, it looks for the -first named child (see named node). -

- -
-
Function: treesit-node-descendant-for-range node beg end &optional named
-

This function finds the smallest descendant node of node -that spans the region of text between positions beg and -end. It is similar to treesit-node-at. If named -is non-nil, it looks for smallest named child. -

- -

Searching for node

- -
-
Function: treesit-search-subtree node predicate &optional backward all limit
-

This function traverses the subtree of node (including -node itself), looking for a node for which predicate -returns non-nil. predicate is a regexp that is matched -against each node’s type, or a predicate function that takes a node -and returns non-nil if the node matches. The function returns -the first node that matches, or nil if none does. -

-

By default, this function only traverses named nodes, but if all -is non-nil, it traverses all the nodes. If backward is -non-nil, it traverses backwards (i.e., it visits the last child first -when traversing down the tree). If limit is non-nil, it -must be a number that limits the tree traversal to that many levels -down the tree. -

- -
-
Function: treesit-search-forward start predicate &optional backward all
-

Like treesit-search-subtree, this function also traverses the -parse tree and matches each node with predicate (except for -start), where predicate can be a regexp or a function. -For a tree like the below where start is marked S, this function -traverses as numbered from 1 to 12: -

-
-
              12
-              |
-     S--------3----------11
-     |        |          |
-o--o-+--o  1--+--2    6--+-----10
-|  |                  |        |
-o  o                +-+-+   +--+--+
-                    |   |   |  |  |
-                    4   5   7  8  9
-
- -

Note that this function doesn’t traverse the subtree of start, -and it always traverse leaf nodes first, then upwards. -

-

Like treesit-search-subtree, this function only searches for -named nodes by default, but if all is non-nil, it -searches for all nodes. If backward is non-nil, it -searches backwards. -

-

While treesit-search-subtree traverses the subtree of a node, -this function starts with node start and traverses every node -that comes after it in the buffer position order, i.e., nodes with -start positions greater than the end position of start. -

-

In the tree shown above, treesit-search-subtree traverses node -S (start) and nodes marked with o, where this function -traverses the nodes marked with numbers. This function is useful for -answering questions like “what is the first node after start in -the buffer that satisfies some condition?” -

- -
-
Function: treesit-search-forward-goto node predicate &optional start backward all
-

This function moves point to the start or end of the next node after -node in the buffer that matches predicate. If start -is non-nil, stop at the beginning rather than the end of a node. -

-

This function guarantees that the matched node it returns makes -progress in terms of buffer position: the start/end position of the -returned node is always greater than that of node. -

-

Arguments predicate, backward and all are the same -as in treesit-search-forward. -

- -
-
Function: treesit-induce-sparse-tree root predicate &optional process-fn limit
-

This function creates a sparse tree from root’s subtree. -

-

It takes the subtree under root, and combs it so only the nodes -that match predicate are left. Like previous functions, the -predicate can be a regexp string that matches against each -node’s type, or a function that takes a node and return non-nil -if it matches. -

-

For example, for a subtree on the left that consist of both numbers -and letters, if predicate is “letter only”, the returned tree -is the one on the right. -

-
-
    a                 a              a
-    |                 |              |
-+---+---+         +---+---+      +---+---+
-|   |   |         |   |   |      |   |   |
-b   1   2         b   |   |      b   c   d
-    |   |     =>      |   |  =>      |
-    c   +--+          c   +          e
-    |   |  |          |   |
- +--+   d  4       +--+   d
- |  |              |
- e  5              e
-
- -

If process-fn is non-nil, instead of returning the matched -nodes, this function passes each node to process-fn and uses the -returned value instead. If non-nil, limit is the number of -levels to go down from root. -

-

Each node in the returned tree looks like -(tree-sitter-node . (child …)). The -tree-sitter-node of the root of this tree will be nil if -root doesn’t match predicate. If no node matches -predicate, the function returns nil. -

- -

More convenience functions

- -
-
Function: treesit-filter-child node predicate &optional named
-

This function finds immediate children of node that satisfy -predicate. -

-

The predicate function takes a node as the argument and should -return non-nil to indicate that the node should be kept. If -named is non-nil, this function only examines the named -nodes. -

- -
-
Function: treesit-parent-until node predicate
-

This function repeatedly finds the parents of node, and returns -the parent that satisfies predicate, a function that takes a -node as the argument. If no parent satisfies predicate, this -function returns nil. -

- -
-
Function: treesit-parent-while node predicate
-

This function repeatedly finds the parent of node, and keeps -doing so as long as the nodes satisfy predicate, a function that -takes a node as the argument. That is, this function returns the -farthest parent that still satisfies predicate. -

- -
-
Function: treesit-node-top-level node &optional type
-

This function returns the highest parent of node that has the -same type as node. If no such parent exists, it returns -nil. Therefore this function is also useful for testing -whether node is top-level. -

-

If type is non-nil, this function matches each parent’s -type with type as a regexp, rather than using node’s type. -

- -
-
- - - - - - diff --git a/admin/notes/tree-sitter/html-manual/Tree_002dsitter-C-API.html b/admin/notes/tree-sitter/html-manual/Tree_002dsitter-C-API.html deleted file mode 100644 index 1d992b828ea..00000000000 --- a/admin/notes/tree-sitter/html-manual/Tree_002dsitter-C-API.html +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - -Tree-sitter C API (GNU Emacs Lisp Reference Manual) - - - - - - - - - - - - - - - - - - - - -
- -
-

37.8 Tree-sitter C API Correspondence

- -

Emacs’ tree-sitter integration doesn’t expose every feature -provided by tree-sitter’s C API. Missing features include: -

-
    -
  • Creating a tree cursor and navigating the syntax tree with it. -
  • Setting timeout and cancellation flag for a parser. -
  • Setting the logger for a parser. -
  • Printing a DOT graph of the syntax tree to a file. -
  • Copying and modifying a syntax tree. (Emacs doesn’t expose a tree -object.) -
  • Using (row, column) coordinates as position. -
  • Updating a node with changes. (In Emacs, retrieve a new node instead -of updating the existing one.) -
  • Querying statics of a language definition. -
- -

In addition, Emacs makes some changes to the C API to make the API more -convenient and idiomatic: -

-
    -
  • Instead of using byte positions, the Emacs Lisp API uses character -positions. -
  • Null nodes are converted to nil. -
- -

Below is the correspondence between all C API functions and their -ELisp counterparts. Sometimes one ELisp function corresponds to -multiple C functions, and many C functions don’t have an ELisp -counterpart. -

-
-
ts_parser_new                           treesit-parser-create
-ts_parser_delete
-ts_parser_set_language
-ts_parser_language                      treesit-parser-language
-ts_parser_set_included_ranges           treesit-parser-set-included-ranges
-ts_parser_included_ranges               treesit-parser-included-ranges
-ts_parser_parse
-ts_parser_parse_string                  treesit-parse-string
-ts_parser_parse_string_encoding
-ts_parser_reset
-ts_parser_set_timeout_micros
-ts_parser_timeout_micros
-ts_parser_set_cancellation_flag
-ts_parser_cancellation_flag
-ts_parser_set_logger
-ts_parser_logger
-ts_parser_print_dot_graphs
-ts_tree_copy
-ts_tree_delete
-ts_tree_root_node
-ts_tree_language
-ts_tree_edit
-ts_tree_get_changed_ranges
-ts_tree_print_dot_graph
-ts_node_type                            treesit-node-type
-ts_node_symbol
-ts_node_start_byte                      treesit-node-start
-ts_node_start_point
-ts_node_end_byte                        treesit-node-end
-ts_node_end_point
-ts_node_string                          treesit-node-string
-ts_node_is_null
-ts_node_is_named                        treesit-node-check
-ts_node_is_missing                      treesit-node-check
-ts_node_is_extra                        treesit-node-check
-ts_node_has_changes
-ts_node_has_error                       treesit-node-check
-ts_node_parent                          treesit-node-parent
-ts_node_child                           treesit-node-child
-ts_node_field_name_for_child            treesit-node-field-name-for-child
-ts_node_child_count                     treesit-node-child-count
-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-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
-ts_node_named_descendant_for_point_range
-ts_node_edit
-ts_node_eq                              treesit-node-eq
-ts_tree_cursor_new
-ts_tree_cursor_delete
-ts_tree_cursor_reset
-ts_tree_cursor_current_node
-ts_tree_cursor_current_field_name
-ts_tree_cursor_current_field_id
-ts_tree_cursor_goto_parent
-ts_tree_cursor_goto_next_sibling
-ts_tree_cursor_goto_first_child
-ts_tree_cursor_goto_first_child_for_byte
-ts_tree_cursor_goto_first_child_for_point
-ts_tree_cursor_copy
-ts_query_new
-ts_query_delete
-ts_query_pattern_count
-ts_query_capture_count
-ts_query_string_count
-ts_query_start_byte_for_pattern
-ts_query_predicates_for_pattern
-ts_query_step_is_definite
-ts_query_capture_name_for_id
-ts_query_string_value_for_id
-ts_query_disable_capture
-ts_query_disable_pattern
-ts_query_cursor_new
-ts_query_cursor_delete
-ts_query_cursor_exec                    treesit-query-capture
-ts_query_cursor_did_exceed_match_limit
-ts_query_cursor_match_limit
-ts_query_cursor_set_match_limit
-ts_query_cursor_set_byte_range
-ts_query_cursor_set_point_range
-ts_query_cursor_next_match
-ts_query_cursor_remove_match
-ts_query_cursor_next_capture
-ts_language_symbol_count
-ts_language_symbol_name
-ts_language_symbol_for_name
-ts_language_field_count
-ts_language_field_name_for_id
-ts_language_field_id_for_name
-ts_language_symbol_type
-ts_language_version
-
-
-
- - - - - - diff --git a/admin/notes/tree-sitter/html-manual/Using-Parser.html b/admin/notes/tree-sitter/html-manual/Using-Parser.html deleted file mode 100644 index fd8fc482f46..00000000000 --- a/admin/notes/tree-sitter/html-manual/Using-Parser.html +++ /dev/null @@ -1,230 +0,0 @@ - - - - - - -Using Parser (GNU Emacs Lisp Reference Manual) - - - - - - - - - - - - - - - - - - - - - -
- -
-

37.2 Using Tree-sitter Parser

- - -

This section describes how to create and configure a tree-sitter -parser. In Emacs, each tree-sitter parser is associated with a -buffer. As the user edits the buffer, the associated parser and -syntax tree are automatically kept up-to-date. -

-
-
Variable: treesit-max-buffer-size
-

This variable contains the maximum size of buffers in which -tree-sitter can be activated. Major modes should check this value -when deciding whether to enable tree-sitter features. -

- -
-
Function: treesit-can-enable-p
-

This function checks whether the current buffer is suitable for -activating tree-sitter features. It basically checks -treesit-available-p and treesit-max-buffer-size. -

- - - -
-
Function: treesit-parser-create language &optional buffer no-reuse
-

Create a parser for the specified buffer and language -(see Tree-sitter Language Definitions). If buffer is omitted or -nil, it stands for the current buffer. -

-

By default, this function reuses a parser if one already exists for -language in buffer, but if no-reuse is -non-nil, this function always creates a new parser. -

- -

Given a parser, we can query information about it. -

-
-
Function: treesit-parser-buffer parser
-

This function returns the buffer associated with parser. -

- -
-
Function: treesit-parser-language parser
-

This function returns the language used by parser. -

- -
-
Function: treesit-parser-p object
-

This function checks if object is a tree-sitter parser, and -returns non-nil if it is, and nil otherwise. -

- -

There is no need to explicitly parse a buffer, because parsing is done -automatically and lazily. A parser only parses when a Lisp program -queries for a node in its syntax tree. Therefore, when a parser is -first created, it doesn’t parse the buffer; it waits until the Lisp -program queries for a node for the first time. Similarly, when some -change is made in the buffer, a parser doesn’t re-parse immediately. -

- -

When a parser does parse, it checks for the size of the buffer. -Tree-sitter can only handle buffer no larger than about 4GB. If the -size exceeds that, Emacs signals the treesit-buffer-too-large -error with signal data being the buffer size. -

-

Once a parser is created, Emacs automatically adds it to the -internal parser list. Every time a change is made to the buffer, -Emacs updates parsers in this list so they can update their syntax -tree incrementally. -

-
-
Function: treesit-parser-list &optional buffer
-

This function returns the parser list of buffer. If -buffer is nil or omitted, it defaults to the current -buffer. -

- -
-
Function: treesit-parser-delete parser
-

This function deletes parser. -

- - -

Normally, a parser “sees” the whole buffer, but when the buffer is -narrowed (see Narrowing), the parser will only see the accessible -portion of the buffer. As far as the parser can tell, the hidden -region was deleted. When the buffer is later widened, the parser -thinks text is inserted at the beginning and at the end. Although -parsers respect narrowing, modes should not use narrowing as a means -to handle a multi-language buffer; instead, set the ranges in which the -parser should operate. See Parsing Text in Multiple Languages. -

-

Because a parser parses lazily, when the user or a Lisp program -narrows the buffer, the parser is not affected immediately; as long as -the mode doesn’t query for a node while the buffer is narrowed, the -parser is oblivious of the narrowing. -

- - -

Besides creating a parser for a buffer, a Lisp program can also parse a -string. Unlike a buffer, parsing a string is a one-off operation, and -there is no way to update the result. -

-
-
Function: treesit-parse-string string language
-

This function parses string using language, and returns -the root node of the generated syntax tree. -

- -

Be notified by changes to the parse tree

- - - - - -

A Lisp program might want to be notified of text affected by -incremental parsing. For example, inserting a comment-closing token -converts text before that token into a comment. Even -though the text is not directly edited, it is deemed to be “changed” -nevertheless. -

-

Emacs lets a Lisp program to register callback functions -(a.k.a. notifiers) for this kind of changes. A notifier -function takes two arguments: ranges and parser. -ranges is a list of cons cells of the form (start . end), where start and end mark the start and the -end positions of a range. parser is the parser issuing the -notification. -

-

Every time a parser reparses a buffer, it compares the old and new -parse-tree, computes the ranges in which nodes have changed, and -passes the ranges to notifier functions. -

-
-
Function: treesit-parser-add-notifier parser function
-

This function adds function to parser’s list of -after-change notifier functions. function must be a function -symbol, not a lambda function (see Anonymous Functions). -

- -
-
Function: treesit-parser-remove-notifier parser function
-

This function removes function from the list of parser’s -after-change notifier functions. function must be a function -symbol, rather than a lambda function. -

- -
-
Function: treesit-parser-notifiers parser
-

This function returns the list of parser’s notifier functions. -

- -
-
- - - - - - diff --git a/admin/notes/tree-sitter/html-manual/build-manual.sh b/admin/notes/tree-sitter/html-manual/build-manual.sh deleted file mode 100755 index 8d931b143b2..00000000000 --- a/admin/notes/tree-sitter/html-manual/build-manual.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -MANUAL_DIR="../../../../doc/lispref" -THIS_DIR=$(pwd) - -echo "Build manual" -cd "${MANUAL_DIR}" -make elisp.html HTML_OPTS="--html --css-ref=./manual.css" - -cd "${THIS_DIR}" - -echo "Copy manual" -cp -f "${MANUAL_DIR}/elisp.html/Parsing-Program-Source.html" . -cp -f "${MANUAL_DIR}/elisp.html/Language-Definitions.html" . -cp -f "${MANUAL_DIR}/elisp.html/Using-Parser.html" . -cp -f "${MANUAL_DIR}/elisp.html/Retrieving-Node.html" . -cp -f "${MANUAL_DIR}/elisp.html/Accessing-Node.html" . -cp -f "${MANUAL_DIR}/elisp.html/Pattern-Matching.html" . -cp -f "${MANUAL_DIR}/elisp.html/Multiple-Languages.html" . -cp -f "${MANUAL_DIR}/elisp.html/Tree_002dsitter-C-API.html" . - -cp -f "${MANUAL_DIR}/elisp.html/Parser_002dbased-Font-Lock.html" . -cp -f "${MANUAL_DIR}/elisp.html/Parser_002dbased-Indentation.html" . diff --git a/admin/notes/tree-sitter/html-manual/manual.css b/admin/notes/tree-sitter/html-manual/manual.css deleted file mode 100644 index c03e0d37009..00000000000 --- a/admin/notes/tree-sitter/html-manual/manual.css +++ /dev/null @@ -1,374 +0,0 @@ -/* Style-sheet to use for Emacs manuals */ - -/* Copyright (C) 2013-2014, 2023 Free Software Foundation, Inc. - -Copying and distribution of this file, with or without modification, -are permitted in any medium without royalty provided the copyright -notice and this notice are preserved. This file is offered as-is, -without any warranty. -*/ - -/* style.css begins here */ - -/* This stylesheet is used by manuals and a few older resources. */ - -/* reset.css begins here */ - -/* -Software License Agreement (BSD License) - -Copyright (c) 2006, Yahoo! Inc. -All rights reserved. - -Redistribution and use of this software in source and -binary forms, with or without modification, arepermitted -provided that the following conditions are met: - -* Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -* Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -* Neither the name of Yahoo! Inc. nor the names of its -contributors may be used to endorse or promote products -derived from this software without specific prior -written permission of Yahoo! Inc. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE. -*/ - -html { - color: #000; - background: #FFF; -} - -body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, -h5, h6, pre, code, form, fieldset, legend, input, -button, textarea, p, blockquote, th, td { - margin: 0; - padding: 0; -} - -table { - border-collapse: collapse; - border-spacing: 0; -} - -fieldset, img { - border: 0; -} - -address, caption, cite, code, dfn, em, strong, -th, var, optgroup { - font-style: inherit; - font-weight: inherit; -} - -del, ins { - text-decoration: none; -} - -li { - list-style:none; -} - -caption, th { - text-align: left; -} - -h1, h2, h3, h4, h5, h6 { - font-size: 100%; - font-weight: normal; -} - -q:before, q:after { - content:''; -} - -abbr, acronym { - border: 0; - font-variant: normal; -} - -sup { - vertical-align: baseline; -} -sub { - vertical-align: baseline; -} - -legend { - color: #000; -} - -input, button, textarea, select, optgroup, option { - font-family: inherit; - font-size: inherit; - font-style: inherit; - font-weight: inherit; -} - -input, button, textarea, select { - *font-size: 100%; -} - - -/* reset.css ends here */ - -/*** PAGE LAYOUT ***/ - -html, body { - font-size: 1em; - text-align: left; - text-decoration: none; -} -html { background-color: #e7e7e7; } - -body { - max-width: 74.92em; - margin: 0 auto; - padding: .5em 1em 1em 1em; - background-color: white; - border: .1em solid #c0c0c0; -} - - -/*** BASIC ELEMENTS ***/ - -/* Size and positioning */ - -p, pre, li, dt, dd, table, code, address { line-height: 1.3em; } - -h1 { font-size: 2em; margin: 1em 0 } -h2 { font-size: 1.50em; margin: 1.0em 0 0.87em 0; } -h3 { font-size: 1.30em; margin: 1.0em 0 0.87em 0; } -h4 { font-size: 1.13em; margin: 1.0em 0 0.88em 0; } -h5 { font-size: 1.00em; margin: 1.0em 0 1.00em 0; } - -p, pre { margin: 1em 0; } -pre { overflow: auto; padding-bottom: .3em; } - -ul, ol, blockquote { margin-left: 1.5%; margin-right: 1.5%; } -hr { margin: 1em 0; } -/* Lists of underlined links are difficult to read. The top margin - gives a little more spacing between entries. */ -ul li { margin: .5em 1em; } -ol li { margin: 1em; } -ol ul li { margin: .5em 1em; } -ul li p, ul ul li { margin-top: .3em; margin-bottom: .3em; } -ul ul, ol ul { margin-top: 0; margin-bottom: 0; } - -/* Separate description lists from preceding text */ -dl { margin: 1em 0 0 0; } -/* separate the "term" from subsequent "description" */ -dt { margin: .5em 0; } -/* separate the "description" from subsequent list item - when the final
child is an anonymous box */ -dd { margin: .5em 3% 1em 3%; } -/* separate anonymous box (used to be the first element in
) - from subsequent

*/ -dd p { margin: .5em 0; } - -table { - display: block; overflow: auto; - margin-top: 1.5em; margin-bottom: 1.5em; -} -th { padding: .3em .5em; text-align: center; } -td { padding: .2em .5em; } - -address { margin-bottom: 1em; } -caption { margin-bottom: .5em; text-align: center; } -sup { vertical-align: super; } -sub { vertical-align: sub; } - -/* Style */ - -h1, h2, h3, h4, h5, h6, strong, dt, th { font-weight: bold; } - -/* The default color (black) is too dark for large text in - bold font. */ -h1, h2, h3, h4 { color: #333; } -h5, h6, dt { color: #222; } - -a[href] { color: #005090; } -a[href]:visited { color: #100070; } -a[href]:active, a[href]:hover { - color: #100070; - text-decoration: none; -} - -h1 a[href]:visited, h2 a[href]:visited, h3 a[href]:visited, -h4 a[href]:visited { color: #005090; } -h1 a[href]:hover, h2 a[href]:hover, h3 a[href]:hover, -h4 a[href]:hover { color: #100070; } - -ol { list-style: decimal outside;} -ul { list-style: square outside; } -ul ul, ol ul { list-style: circle; } -li { list-style: inherit; } - -hr { background-color: #ede6d5; } -table { border: 0; } - -abbr,acronym { - border-bottom:1px dotted #000; - text-decoration: none; - cursor:help; -} -del { text-decoration: line-through; } -em { font-style: italic; } -small { font-size: .9em; } - -img { max-width: 100%} - - -/*** SIMPLE CLASSES ***/ - -.center, .c { text-align: center; } -.nocenter{ text-align: left; } - -.underline { text-decoration: underline; } -.nounderline { text-decoration: none; } - -.no-bullet { list-style: none; } -.inline-list li { display: inline } - -.netscape4, .no-display { display: none; } - - -/*** MANUAL PAGES ***/ - -/* This makes the very long tables of contents in Gnulib and other - manuals easier to read. */ -.contents ul, .shortcontents ul { font-weight: bold; } -.contents ul ul, .shortcontents ul ul { font-weight: normal; } -.contents ul { list-style: none; } - -/* For colored navigation bars (Emacs manual): make the bar extend - across the whole width of the page and give it a decent height. */ -.header, .node { margin: 0 -1em; padding: 0 1em; } -.header p, .node p { line-height: 2em; } - -/* For navigation links */ -.node a, .header a { display: inline-block; line-height: 2em; } -.node a:hover, .header a:hover { background: #f2efe4; } - -/* Inserts */ -table.cartouche td { padding: 1.5em; } - -div.display, div.lisp, div.smalldisplay, -div.smallexample, div.smalllisp { margin-left: 3%; } - -div.example { padding: .8em 1.2em .4em; } -pre.example { padding: .8em 1.2em; } -div.example, pre.example { - margin: 1em 0 1em 3% ; - -webkit-border-radius: .3em; - -moz-border-radius: .3em; - border-radius: .3em; - border: 1px solid #d4cbb6; - background-color: #f2efe4; -} -div.example > pre.example { - padding: 0 0 .4em; - margin: 0; - border: none; -} - -pre.menu-comment { padding-top: 1.3em; margin: 0; } - - -/*** FOR WIDE SCREENS ***/ - -@media (min-width: 40em) { - body { padding: .5em 3em 1em 3em; } - div.header, div.node { margin: 0 -3em; padding: 0 3em; } -} - -/* style.css ends here */ - -/* makeinfo convert @deffn and similar functions to something inside -

. style.css uses italic for blockquote. This looks poor - in the Emacs manuals, which make extensive use of @defun (etc). - In particular, references to function arguments appear as - inside
. Since is also italic, it makes it - impossible to distinguish variables. We could change to - e.g. bold-italic, or normal, or a different color, but that does - not look as good IMO. So we just override blockquote to be non-italic. - */ -blockquote { font-style: normal; } - -var { font-style: italic; } - -div.header { - background-color: #DDDDFF; - padding-top: 0.2em; -} - - -/*** Customization ***/ - -body { - font-family: Charter, serif; - font-size: 14pt; - line-height: 1.4; - background-color: #fefefc; - color: #202010; -} - -pre.menu-comment { - font-family: Charter, serif; - font-size: 14pt; -} - -body > *, body > div.display, body > div.lisp, body > div.smalldisplay, -body > div.example, body > div.smallexample, body > div.smalllisp { - width: 700px; - margin-left: auto; - margin-right: auto; -} - -div.header { - width: 100%; - min-height: 3em; - font-size: 13pt; -} - -/* Documentation block for functions and variables. Make then - narrower*/ -dd { - margin: .5em 6% 1em 6% -} - -code, pre, kbd, samp, tt { - font-size: 12pt; - font-family: monospace; -} - -/* In each node we have index table to all sub-nodes. Make more space - for the first column, which is the name to each sub-node. */ -table.menu tbody tr td:nth-child(1) { - white-space: nowrap; -} - -div.header p { - text-align: center; - margin: 0.5em auto 0.5em auto; -} -- cgit v1.2.3