forked from Github/emacs
Compare commits
11 commits
master
...
feature/as
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8043ba186d | ||
|
|
b9495c3713 | ||
|
|
7f8aa9db63 | ||
|
|
aa9ca2c149 | ||
|
|
772650fb9f | ||
|
|
f254029f65 | ||
|
|
5b12778507 | ||
|
|
5fa567d79c | ||
|
|
af296b19ef | ||
|
|
1b4a112c46 | ||
|
|
5c653d3ec9 |
3405 changed files with 38619 additions and 196146 deletions
|
|
@ -21,9 +21,6 @@
|
|||
(electric-quote-comment . nil)
|
||||
(electric-quote-string . nil)
|
||||
(mode . bug-reference-prog)))
|
||||
(c-ts-mode . ((c-ts-mode-indent-style . gnu)
|
||||
(indent-tabs-mode . t)
|
||||
(mode . bug-reference-prog)))
|
||||
(log-edit-mode . ((log-edit-font-lock-gnu-style . t)
|
||||
(log-edit-setup-add-author . t)
|
||||
(vc-git-log-edit-summary-target-len . 50)))
|
||||
|
|
|
|||
2
.gitattributes
vendored
2
.gitattributes
vendored
|
|
@ -1,6 +1,6 @@
|
|||
# Attributes of Emacs files in the Git repository.
|
||||
|
||||
# Copyright 2015-2023 Free Software Foundation, Inc.
|
||||
# Copyright 2015-2022 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -1,6 +1,6 @@
|
|||
# Files that Git should ignore in the Emacs source directory.
|
||||
|
||||
# Copyright 2009-2023 Free Software Foundation, Inc.
|
||||
# Copyright 2009-2022 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU Emacs.
|
||||
|
||||
|
|
@ -334,7 +334,3 @@ lib-src/seccomp-filter-exec.pfc
|
|||
# Ignore a directory used by dap-mode.
|
||||
.vscode
|
||||
/test/gmp.h
|
||||
|
||||
# GDB history
|
||||
.gdb_history
|
||||
_gdb_history
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (C) 2021-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2021-2022 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of GNU Emacs.
|
||||
#
|
||||
|
|
|
|||
17
CONTRIBUTE
17
CONTRIBUTE
|
|
@ -1,6 +1,3 @@
|
|||
Copyright (C) 2006-2023 Free Software Foundation, Inc.
|
||||
See the end of the file for license conditions.
|
||||
|
||||
* How developers contribute to GNU Emacs
|
||||
|
||||
Here is how software developers can contribute to Emacs. (Non-developers: see
|
||||
|
|
@ -18,7 +15,7 @@ To configure Git for Emacs development, you can run the following:
|
|||
|
||||
The following shell commands then build and run Emacs from scratch:
|
||||
|
||||
git clone https://git.savannah.gnu.org/git/emacs.git
|
||||
git clone git://git.sv.gnu.org/emacs.git
|
||||
cd emacs
|
||||
./autogen.sh
|
||||
./configure
|
||||
|
|
@ -110,7 +107,7 @@ admin/notes/bug-triage.
|
|||
|
||||
Any change that matters to end-users should have an entry in etc/NEWS.
|
||||
Try to start each NEWS entry with a sentence that summarizes the entry
|
||||
and takes just one line -- this will allow reading NEWS in Outline
|
||||
and takes just one line -- this will allow to read NEWS in Outline
|
||||
mode after hiding the body of each entry.
|
||||
|
||||
Doc-strings should be updated together with the code.
|
||||
|
|
@ -123,7 +120,7 @@ Think about whether your change requires updating the manuals. If you
|
|||
know it does not, mark the NEWS entry with "---". If you know
|
||||
that *all* the necessary documentation updates have been made as part
|
||||
of your changes or those by others, mark the entry with "+++".
|
||||
Otherwise, do not mark it.
|
||||
Otherwise do not mark it.
|
||||
|
||||
If your change requires updating the manuals to document new
|
||||
functions/commands/variables/faces, then use the proper Texinfo
|
||||
|
|
@ -321,7 +318,7 @@ them right the first time, so here are guidelines for formatting them:
|
|||
** Committing your changes.
|
||||
|
||||
When you commit changes, Git invokes several scripts that test the
|
||||
commit for validity, and may abort the commit if some of the tests
|
||||
commit for validity, and may abort the commit of some of the tests
|
||||
fail. These scripts live in the '.git/hooks/' subdirectory of the
|
||||
top-level directory of the repository, and they perform the following
|
||||
tests:
|
||||
|
|
@ -400,7 +397,7 @@ the commit to master, by starting the commit message with "Backport:".
|
|||
The gitmerge function excludes these commits from the merge to the master.
|
||||
|
||||
Some changes should not be merged to master at all, for whatever
|
||||
reason. These should be marked by including something like "Do not
|
||||
reasons. These should be marked by including something like "Do not
|
||||
merge to master" or anything that matches gitmerge-skip-regexp (see
|
||||
admin/gitmerge.el) in the commit message.
|
||||
|
||||
|
|
@ -449,8 +446,8 @@ files intended for use only with Emacs version 24.5 and later.
|
|||
|
||||
*** Useful files in the admin/ directory
|
||||
|
||||
See all the files in 'admin/notes/*'. In particular, see
|
||||
'admin/notes/newfile' and 'admin/notes/repo'.
|
||||
See all the files in admin/notes/* . In particular, see
|
||||
admin/notes/newfile, see admin/notes/repo.
|
||||
|
||||
The file admin/MAINTAINERS records the areas of interest of frequent
|
||||
Emacs contributors. If you are making changes in one of the files
|
||||
|
|
|
|||
|
|
@ -4302,7 +4302,7 @@
|
|||
(install-arch-indep): Don't install-etc for self-contained ns builds.
|
||||
|
||||
* configure.in (GCC_TEST_OPTIONS, NON_GCC_TEST_OPTIONS) <darwin>:
|
||||
No longer unconditionally add /sw directories. (Bug#2280)
|
||||
No longer unconditonally add /sw directories. (Bug#2280)
|
||||
|
||||
* Makefile.in (install-arch-dep): Depend on install-arch-indep.
|
||||
(install-arch-indep): Depend on install-leim.
|
||||
|
|
@ -14700,7 +14700,7 @@
|
|||
;; coding: utf-8
|
||||
;; End:
|
||||
|
||||
Copyright (C) 1993-1999, 2001-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993-1999, 2001-2022 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
2017-03-21 Noam Postavsky <npostavs@gmail.com>
|
||||
|
||||
Narrow scope of modification hook re-enabling in org-src fontification
|
||||
Narrow scope of modification hook renabling in org-src fontification
|
||||
|
||||
Modification hooks should be enabled while modifying text in the
|
||||
org-src temp buffer, but in 2017-01-29 "Call modification hooks in
|
||||
|
|
@ -11843,7 +11843,7 @@
|
|||
|
||||
2016-01-05 Alan Mackenzie <acm@muc.de>
|
||||
|
||||
Make C++ buffers writable when writing their initial text properties.
|
||||
Make C++ buffers writeable when writing their initial text properties.
|
||||
|
||||
This is a correction to yesterday's CC Mode patch.
|
||||
|
||||
|
|
@ -28676,7 +28676,7 @@
|
|||
* lisp/faces.el (set-face-attribute): Don't be fooled too easily
|
||||
by a hyphen in a font's name.
|
||||
|
||||
Fix value of posn-at-point in R2L lines
|
||||
Fix value of posn-at-pont in R2L lines
|
||||
* src/keyboard.c (Fposn_at_x_y, Fposn_at_point): Allow X pixel
|
||||
coordinate of -1, for a newline in a right-to-left line that
|
||||
overflowed into the left fringe.
|
||||
|
|
@ -35787,7 +35787,7 @@ See ChangeLog.1 for earlier changes.
|
|||
;; coding: utf-8
|
||||
;; End:
|
||||
|
||||
Copyright (C) 2015-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2015-2022 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
518
ChangeLog.3
518
ChangeLog.3
|
|
@ -1,431 +1,3 @@
|
|||
2022-02-18 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
* Version 28.3 released.
|
||||
|
||||
2023-02-17 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Update HISTORY for Emacs 28.3
|
||||
|
||||
2023-02-17 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Bump Emacs version to 28.3
|
||||
|
||||
* README:
|
||||
* configure.ac:
|
||||
* msdos/sed2v2.inp:
|
||||
* nt/README.W32: Bump Emacs version to 28.3.
|
||||
|
||||
2023-02-17 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Update NEWS for Emacs 28.3
|
||||
|
||||
* etc/NEWS: Update for Emacs 28.3.
|
||||
|
||||
2023-02-17 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Update ChangeLog and AUTHORS for Emacs 28.3
|
||||
|
||||
* ChangeLog.3:
|
||||
* etc/AUTHORS: Update for Emacs 28.3.
|
||||
|
||||
2023-02-17 Xi Lu <lx@shellcodes.org>
|
||||
|
||||
Fix etags local command injection vulnerability
|
||||
|
||||
* lib-src/etags.c: (escape_shell_arg_string): New function.
|
||||
(process_file_name): Use it to quote file names passed to the
|
||||
shell. (Bug#59817)
|
||||
|
||||
(cherry picked from commit 01a4035c869b91c153af9a9132c87adb7669ea1c)
|
||||
|
||||
2023-02-17 Xi Lu <lx@shellcodes.org>
|
||||
|
||||
Fixed ctags local command execute vulnerability
|
||||
|
||||
* lib-src/etags.c:
|
||||
|
||||
(clean_matched_file_tag): New function
|
||||
(do_move_file): New function
|
||||
(readline_internal):
|
||||
Add `leave_cr` parameter, if true, include the \r character
|
||||
|
||||
* test/manual/etags/CTAGS.good_crlf: New file
|
||||
* test/manual/etags/CTAGS.good_update: New file
|
||||
* test/manual/etags/crlf: New file
|
||||
* test/manual/etags/Makefile: Add `ctags -u` test cases
|
||||
|
||||
(cherry picked from commit d48bb4874bc6cd3e69c7a15fc3c91cc141025c51)
|
||||
|
||||
2023-02-17 Xi Lu <lx@shellcodes.org>
|
||||
|
||||
Fix ruby-mode.el local command injection vulnerability (bug#60268)
|
||||
|
||||
* lisp/progmodes/ruby-mode.el
|
||||
(ruby-find-library-file): Fix local command injection vulnerability.
|
||||
|
||||
(cherry picked from commit 9a3b08061feea14d6f37685ca1ab8801758bfd1c)
|
||||
|
||||
2023-02-17 Xi Lu <lx@shellcodes.org>
|
||||
|
||||
Fix htmlfontify.el command injection vulnerability.
|
||||
|
||||
* lisp/htmlfontify.el (hfy-text-p): Fix command injection
|
||||
vulnerability. (Bug#60295)
|
||||
|
||||
(cherry picked from commit 1b4dc4691c1f87fc970fbe568b43869a15ad0d4c)
|
||||
|
||||
2022-12-19 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
Fix storing email into nnmail by Gnus
|
||||
|
||||
Backporting suggested by Florian Weimer, since this is
|
||||
a denial-of-service issue.
|
||||
* lisp/gnus/nnml.el (nnml--encode-headers): Wrap
|
||||
'rfc2047-encode-string' calls with 'ignore-errors', to avoid
|
||||
disrupting email workflows due to possibly-invalid headers.
|
||||
Reported by Florian Weimer <fweimer@redhat.com>.
|
||||
|
||||
(cherry picked from commit 23f7c9c2a92e4619b7c4d2286d4249f812cd695d)
|
||||
|
||||
2022-11-14 Robert Pluim <rpluim@gmail.com>
|
||||
|
||||
Explain how to bind keys to non-ASCII sequences
|
||||
|
||||
* doc/emacs/custom.texi (Init Rebinding): Explain how to use `kbd'
|
||||
when binding keys to non-ASCII sequences.
|
||||
|
||||
2022-11-12 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
Document that 'transient-mark-mode' is off in batch mode
|
||||
|
||||
* doc/emacs/mark.texi (Mark, Disabled Transient Mark): Document,
|
||||
belatedly, that 'transient-mark-mode' is turned on by default only
|
||||
in interactive sessions. (Bug#59201)
|
||||
|
||||
2022-10-14 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
Document how to control where the *.eln files are written
|
||||
|
||||
* doc/lispref/compile.texi (Native Compilation): Document the
|
||||
trick of pointing $HOME to a non-existent directory.
|
||||
(Native-Compilation Variables): Document the role of
|
||||
'native-comp-eln-load-path' in determining where *.eln files are
|
||||
written.
|
||||
|
||||
2022-10-14 Robert Pluim <rpluim@gmail.com>
|
||||
|
||||
Add cross-reference to alternative syntaxes for Unicode
|
||||
|
||||
These alternative syntaxes allow you to specify Unicode codepoints
|
||||
using only ASCII, which helps avoid decoding issues.
|
||||
|
||||
* doc/emacs/custom.texi (Init Non-ASCII): Add cross reference to
|
||||
"General Escape Syntax" in the Emacs Lisp Reference Manual.
|
||||
|
||||
2022-10-07 Lars Ingebrigtsen <larsi@gnus.org>
|
||||
|
||||
Update name of hs-mouse-toggle-hiding in Emacs manual
|
||||
|
||||
* doc/emacs/programs.texi (Hideshow): Update the name of
|
||||
hs-mouse-toggle-hiding (bug#58331).
|
||||
|
||||
2022-10-06 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Fix typo in `(emacs) Lisp Doc'
|
||||
|
||||
* doc/emacs/programs.texi (Lisp Doc): Fix reference to
|
||||
'eldoc-echo-area-display-truncation-message'. (Bug#58324)
|
||||
|
||||
2022-10-06 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Fix references to 'default-indent-new-line'
|
||||
|
||||
* doc/emacs/programs.texi (Comment Commands)
|
||||
(Multi-Line Comments): Fix references to
|
||||
'default-indent-new-line'. (Bug#58325)
|
||||
|
||||
2022-10-04 Andreas Schwab <schwab@linux-m68k.org>
|
||||
|
||||
* src/emacs.c (load_pdump): Propery handle case when executable
|
||||
wasn't found.
|
||||
|
||||
2022-10-04 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
Avoid assertion violations in STRING_CHAR
|
||||
|
||||
* src/xdisp.c (handle_composition_prop):
|
||||
* src/editfns.c (styled_format): Don't call 'STRING_CHAR' on
|
||||
unibyte strings. This avoids assertion violation in
|
||||
'string_char_and_length'.
|
||||
|
||||
(cherry picked from commit d52d6e1e106117eb4bba81a65e256e2e793037b6)
|
||||
|
||||
2022-10-03 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Fix documentation of 'TAB' in cc-mode
|
||||
|
||||
* doc/emacs/programs.texi (C Indent): Fix documentation of 'TAB'
|
||||
in cc-mode. (Bug#58258)
|
||||
|
||||
2022-10-03 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Fix 'org-export-dispatch' command name in manual
|
||||
|
||||
* doc/emacs/text.texi (Org Authoring): Fix 'org-export-dispatch'
|
||||
command name. (Bug#58260)
|
||||
|
||||
2022-10-02 Andreas Schwab <schwab@linux-m68k.org>
|
||||
|
||||
* src/emacs.c (load_pdump): Fix use of xpalloc.
|
||||
|
||||
2022-10-02 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
Avoid assertion violation in 'xpalloc'
|
||||
|
||||
* src/emacs.c (load_pdump): Ensure the 3rd argument of xpalloc is
|
||||
always positive. (Bug#58232)
|
||||
|
||||
2022-09-30 Michael Albinus <michael.albinus@gmx.de>
|
||||
|
||||
Fix connection property incompatibility in Tramp
|
||||
|
||||
* lisp/net/tramp.el (tramp-get-remote-tmpdir): Remove obsolete
|
||||
connection property "tmpdir". (Bug#57800)
|
||||
|
||||
2022-09-29 Lars Ingebrigtsen <larsi@gnus.org>
|
||||
|
||||
Update some Gnus documentation in the Emacs manual
|
||||
|
||||
* doc/emacs/misc.texi (Gnus Group Buffer, Gnus Summary Buffer):
|
||||
Update documentation (bug#58145).
|
||||
|
||||
2022-09-28 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
Clarify image file search
|
||||
|
||||
* doc/lispref/display.texi (Defining Images, Image Descriptors):
|
||||
* lisp/image.el (create-image): Clarify that non-absolute image
|
||||
files are searched along 'image-load-path'. (Bug#52931)
|
||||
|
||||
2022-09-28 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
.mailcap: Some additional fixes.
|
||||
|
||||
2022-09-28 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
Avoid assertion violations in 'pop_it'
|
||||
|
||||
* src/xdisp.c (pop_it): Avoid assertion violations when handling
|
||||
lists or vectors of display properties. (Bug#58122)
|
||||
|
||||
2022-09-28 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Add .mailmap for proper git log output
|
||||
|
||||
This file is used to fix a few misspelled names in various git
|
||||
listings (e.g., "git log"). This can be used to fix incorrect
|
||||
attribution, poor display, or names showing up more than once.
|
||||
It also allows updating an old email addresses to a new one.
|
||||
See "man git-shortlog" for more information on the format.
|
||||
|
||||
* .mailmap: New file.
|
||||
|
||||
2022-09-27 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
* doc/emacs/ack.texi (Acknowledgments): Update maintainers.
|
||||
|
||||
2022-09-24 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
* lisp/progmodes/hideshow.el (hs-toggle-hiding): Fix `interactive` form
|
||||
|
||||
This fixes the first part of bug#52092, which is a regression
|
||||
introduced by commit d0e9113de97.
|
||||
|
||||
2022-09-23 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
|
||||
|
||||
Fix shaping with bitmap-only fonts on HarfBuzz 5.2.0 (Bug#57976)
|
||||
|
||||
* src/ftcrfont.c (ftcrhbfont_begin_hb_font): Undo last change for
|
||||
HarfBuzz 5.2.0.
|
||||
|
||||
2022-09-20 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
* lisp/text-modes/tex-mode.el (tex-mode): Fix AUCTeX regression
|
||||
|
||||
As discussed in
|
||||
https://lists.gnu.org/r/auctex/2022-08/msg00004.html
|
||||
AUCTeX installs its own advice to redefine `tex-mode`, and that
|
||||
advice used to take precedence before commit 6075a7c5ae3fa456cd.
|
||||
|
||||
2022-09-20 Robert Pluim <rpluim@gmail.com>
|
||||
|
||||
Add vc-annotate-switches to manual
|
||||
|
||||
* doc/emacs/maintaining.texi (Old Revisions): Add description of
|
||||
`vc-annotate-switches' and `vc-BACKEND-annotate-switches'.
|
||||
|
||||
2022-09-20 Robert Pluim <rpluim@gmail.com>
|
||||
|
||||
Remove mention of non-existent `annotate-switches'
|
||||
|
||||
* lisp/vc/vc.el (vc-annotate-switches): Remove mention of
|
||||
`annotate-switches'. As far as I can tell this has never existed in
|
||||
Emacs.
|
||||
|
||||
2022-09-20 Robert Pluim <rpluim@gmail.com>
|
||||
|
||||
Mention that src/macuvs.h sometimes needs committing
|
||||
|
||||
* admin/notes/unicode: src/macuvs.h is generated, but needs to be
|
||||
committed sometimes.
|
||||
|
||||
2022-09-19 Gerd Möllmann <gerd@gnu.org>
|
||||
|
||||
MacOS ld warning from native compilation (bug#57849)
|
||||
|
||||
* lisp/emacs-lisp/comp.el (native-comp-driver-options): Add "-Wl,-w"
|
||||
on Darwin systems.
|
||||
* etc/NEWS: Describe change.
|
||||
|
||||
2022-09-18 Michael Albinus <michael.albinus@gmx.de>
|
||||
|
||||
Fix Tramp error with eshell integration
|
||||
|
||||
* lisp/net/tramp-integration.el (tramp-eshell-directory-change):
|
||||
Respect local `default-directory'. (Bug#57556)
|
||||
|
||||
2022-09-17 Michael Albinus <michael.albinus@gmx.de>
|
||||
|
||||
Sync with Tramp 2.5.3.2. Don't merge with master
|
||||
|
||||
* doc/misc/tramp.texi (Android shell setup): Rework.
|
||||
(Frequently Asked Questions): Improve recommendations for speeding up.
|
||||
|
||||
* doc/misc/trampver.texi:
|
||||
* lisp/net/trampver.el: Change version to "2.5.4-pre".
|
||||
|
||||
* lisp/net/tramp-adb.el (tramp-methods): Use "%d".
|
||||
(tramp-adb-handle-directory-files-and-attributes): Fix "." and
|
||||
".." in listing.
|
||||
(tramp-adb-handle-file-attributes)
|
||||
(tramp-adb-handle-directory-files-and-attributes)
|
||||
(tramp-adb-handle-file-name-all-completions): Pipe "ls" output
|
||||
through "cat", in order to avoid quoting special characters.
|
||||
(tramp-adb-maybe-open-connection): Compute args from `tramp-login-args'.
|
||||
|
||||
* lisp/net/tramp-compat.el (tramp-compat-replace-regexp-in-region):
|
||||
New defalias.
|
||||
|
||||
* lisp/net/tramp-gvfs.el (tramp-gvfs-do-copy-or-rename-file):
|
||||
Adapt check for proper remote command.
|
||||
|
||||
* lisp/net/tramp.el (tramp-methods): Adapt docstring.
|
||||
(tramp-handle-make-process): Check for adb device if indicated.
|
||||
(tramp-get-remote-tmpdir): Cache result in temporary connection
|
||||
property.
|
||||
|
||||
* test/lisp/net/tramp-tests.el (tramp-test17-insert-directory)
|
||||
(tramp-test22-file-times, tramp--test-utf8): Adapt tests.
|
||||
(tramp--test-shell-file-name): Do not depend on `tramp--test-adb-p'.
|
||||
(tramp-test46-unload): Ignore autoload functions in
|
||||
`tramp-file-name' structure tests, since `tramp-file-name-handler'
|
||||
is also autoloaded in Emacs 29.
|
||||
|
||||
2022-09-17 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Simplify regexp in make-news-html-file
|
||||
|
||||
* admin/admin.el (make-news-html-file): Simplify regexp.
|
||||
Suggested by Mattias Engdegård <mattiase@acm.org>.
|
||||
|
||||
2022-09-16 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
* admin/admin.el (make-news-html-file): Set id on correct tag.
|
||||
|
||||
2022-09-16 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Add version headlines to HTML NEWS export
|
||||
|
||||
This allows linking to, e.g. "NEWS.28.html#28.1" to go directly to
|
||||
those release notes.
|
||||
* admin/admin.el (admin--org-export-headers-format)
|
||||
(make-news-html-file): Add XX.Y version headlines with an HTML anchor.
|
||||
|
||||
2022-09-16 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Improve HTML export of NEWS file
|
||||
|
||||
* admin/admin.el (admin--org-export-headers-format)
|
||||
(admin--org-html-postamble): New variables.
|
||||
(admin--require-external-package): New function.
|
||||
(make-news-html-file): Improve HTML export.
|
||||
|
||||
2022-09-16 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Delete "etc/NEWS*.html" from .gitignore
|
||||
|
||||
We actually do want to see it when preparing a release, so that we
|
||||
don't include it in a tarball by mistake.
|
||||
* .gitignore: Don't ignore "etc/NEWS*.html".
|
||||
|
||||
2022-09-16 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Recommend NonGNU ELPA over MELPA
|
||||
|
||||
* doc/misc/org.org (Using CDLaTeX to enter math, Footnotes): Recommend
|
||||
NonGNU ELPA over MELPA.
|
||||
|
||||
2022-09-16 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Minor doc fixes in picture.el
|
||||
|
||||
* lisp/textmodes/picture.el: Improve Commentary.
|
||||
(picture-forward-column, picture-backward-column)
|
||||
(picture-move-down, picture-move-up, picture-movement-nw)
|
||||
(picture-movement-ne, picture-movement-sw, picture-movement-se)
|
||||
(picture-set-motion, picture-clear-line, picture-newline)
|
||||
(picture-tab, picture-yank-rectangle)
|
||||
(picture-yank-rectangle-from-register, picture-insert-rectangle)
|
||||
(picture-draw-rectangle): Minor doc fixes.
|
||||
|
||||
2022-09-16 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
* lisp/textmodes/page-ext.el: Improve Commentary.
|
||||
|
||||
2022-09-14 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Automate exporting etc/NEWS to HTML
|
||||
|
||||
* admin/admin.el (make-news-html-file): New function.
|
||||
* .gitignore: Ignore generated "etc/NEWS*.html" file.
|
||||
|
||||
2022-09-14 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
* Makefile.in (uninstall): Remove the *.eln files. (Bug#57771)
|
||||
|
||||
2022-09-12 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Update HISTORY for Emacs 28.2
|
||||
|
||||
* etc/HISTORY: Update for the Emacs 28.2 release.
|
||||
|
||||
2022-09-07 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Bump Emacs version to 28.2
|
||||
|
||||
* README:
|
||||
* configure.ac:
|
||||
* msdos/sed2v2.inp:
|
||||
* nt/README.W32: Bump Emacs version to 28.2.
|
||||
|
||||
2022-09-07 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Update ChangeLog and AUTHORS for Emacs 28.2
|
||||
|
||||
* ChangeLog.3:
|
||||
* etc/AUTHORS:
|
||||
* etc/NEWS: Update for Emacs 28.2.
|
||||
|
||||
2022-09-06 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
* doc/misc/idlwave.texi (Troubleshooting): Don't say "Emacsen".
|
||||
|
|
@ -2082,7 +1654,7 @@
|
|||
This reverts commit 78f76fe16e2737b40694f82af28d17a90a21ed7b.
|
||||
|
||||
The commit made calls to cl-concatenate bug out, since
|
||||
autoloading defaliases doesn't work very well (bug#54901).
|
||||
autoloading defalises doesn't work very well (bug#54901).
|
||||
|
||||
2022-04-12 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
|
|
@ -4356,7 +3928,7 @@
|
|||
|
||||
* lisp/follow.el (follow-scroll-down): Do away with the optimization of doing
|
||||
vertical-motion over only one window. Instead move over all windows, to
|
||||
check for being close to point-min, and setting point accordingly.
|
||||
checck for being close to point-min, and setting point accordingly.
|
||||
|
||||
2021-11-13 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
|
|
@ -11161,7 +10733,7 @@
|
|||
|
||||
Bump lisp/progmodes/project.el version to 0.7.1
|
||||
|
||||
Among other things exposes the new project-buffers generic function to
|
||||
Amont other things exposes the new project-buffers generic function to
|
||||
ELPA users.
|
||||
|
||||
* lisp/progmodes/project.el (Version): Bump to 0.7.1
|
||||
|
|
@ -15152,7 +14724,7 @@
|
|||
|
||||
* lisp/icomplete.el (icomplete-vertical-mode):
|
||||
(fido-vertical-mode): Tweak docstring. Turn on
|
||||
icomplete-mode. and fido-mode
|
||||
icomplete-mode. and fido-mdoe
|
||||
|
||||
2021-08-16 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
|
|
@ -21082,7 +20654,7 @@
|
|||
* lisp/progmodes/cc-engine.el (c-clear-<-pair-props, c-clear->-pair-props)
|
||||
(c-clear-<-pair-props-if-match-after, c-clear->-pair-props-if-match-before)
|
||||
(c-forward-<>-arglist-recur):
|
||||
Invalidate caches with c-truncate-lit-pos-cache.
|
||||
Invalidate caches with c-trunctate-lit-pos-cache.
|
||||
(c-forward-<>-arglist-recur): If in a matching <...> expression, the < has a
|
||||
syntax-table property, but the > not, remove that property.
|
||||
|
||||
|
|
@ -25646,7 +25218,7 @@
|
|||
|
||||
2021-05-12 Richard Stallman <rms@gnu.org>
|
||||
|
||||
Little improvements in rmail.el. Recognize encrypted override headers.
|
||||
Little improvements in rmail.el. Recognize encryped override headers.
|
||||
|
||||
* lisp/mail/rmail.el (rmail-simplified-subject): Delete `[External] :'.
|
||||
(rmail-reply): In encrypted message, search for other header fields
|
||||
|
|
@ -27761,7 +27333,7 @@
|
|||
|
||||
2021-04-24 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
Simplify top-level Makefile since admin is always included
|
||||
Simlify top-level Makefile since admin is always included
|
||||
|
||||
* Makefile.in (clean_dirs, distclean_dirs, maintainer_clean_dirs):
|
||||
Add admin directories.
|
||||
|
|
@ -28096,7 +27668,7 @@
|
|||
* lisp/international/mule-cmds.el (ucs-names):
|
||||
* lisp/progmodes/ebrowse.el (ebrowse-read):
|
||||
* test/src/coding-tests.el (benchmark-decoder): Avoid lowering
|
||||
gc-cons-threshold.
|
||||
gc-cons-treshold.
|
||||
|
||||
2021-04-22 Stefan Kangas <stefan@marxist.se>
|
||||
|
||||
|
|
@ -28725,7 +28297,7 @@
|
|||
|
||||
2021-04-17 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
* src/emacs.c (load_pdump): Fix compilation on picky-compiler platforms.
|
||||
* src/emacs.c (load_pdump): Fix compilation on picky-complier platforms.
|
||||
|
||||
2021-04-17 Daniel Martín <mardani29@yahoo.es>
|
||||
|
||||
|
|
@ -29790,7 +29362,7 @@
|
|||
Make the function correctly recognize a brace block preceded by an
|
||||
introductory line without a parameter list.
|
||||
|
||||
* lisp/progmodes/cc-cmds.el (c-where-wrt-brace-construct): Reintroduce the use
|
||||
* lisp/progmodes/cc-cmds.el (c-where-wrt-brace-contruct): Reintroduce the use
|
||||
of c-beginning-of-decl-1, which was removed some weeks ago, in place of a
|
||||
c-syntactic-skip-backward. Reformulate the code generally.
|
||||
|
||||
|
|
@ -31479,7 +31051,7 @@
|
|||
|
||||
2021-03-28 Lars Ingebrigtsen <larsi@gnus.org>
|
||||
|
||||
Clarify the doc string of plist-member and plist-put
|
||||
Clarify the doc string of plist-memeber and plist-put
|
||||
|
||||
* src/fns.c (Fplist_member):
|
||||
(Fplist_put): Clarify what comparison function is used for PROP
|
||||
|
|
@ -35664,7 +35236,7 @@
|
|||
|
||||
2021-03-04 Andrea Corallo <akrl@sdf.org>
|
||||
|
||||
* src/comp.c (hash_native_abi): Account for `system-configuration-options'.
|
||||
* src/comp.c (hash_native_abi): Account for `system-configuraton-options'.
|
||||
|
||||
2021-03-04 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
|
|
@ -46919,7 +46491,7 @@
|
|||
|
||||
Fix Quit button in dictionary buffer
|
||||
|
||||
* lisp/net/dictionary.el (dictionary-close): Changing the arity of the
|
||||
* lisp/net/dictionary.el (dictionay-close): Changing the arity of the
|
||||
function in cc5f2803785c5dc785f09a292313cf799e8d29bb was a mistake.
|
||||
Restore it, but mark the argument as unused to avoid a
|
||||
wrong-number-of-arguments error when using the Quit button.
|
||||
|
|
@ -46997,7 +46569,7 @@
|
|||
Fix syntax of symbol and punctuation characters
|
||||
|
||||
* lisp/international/characters.el: Adjust syntax of punctuation
|
||||
and symbol characters to follow that of Unicode properties.
|
||||
and symbol charcaters to follow that of Unicode properties.
|
||||
(Bug#44974)
|
||||
|
||||
2021-01-02 Andrea Corallo <akrl@sdf.org>
|
||||
|
|
@ -51060,7 +50632,7 @@
|
|||
|
||||
Allow for adding constraints targeting blocks with multiple predecessors
|
||||
|
||||
This commit remove the limitation we had not being able to add
|
||||
This commit remove the limitaiton we had not being able to add
|
||||
constraints derived from conditional branches to basic blocks with
|
||||
multiple predecessors. When this condition is verified we add a new
|
||||
dedicated basic block to hold the constraints.
|
||||
|
|
@ -63885,9 +63457,9 @@
|
|||
|
||||
2020-09-30 Lars Ingebrigtsen <larsi@gnus.org>
|
||||
|
||||
Fix isearch-group-* colors on low-color displays
|
||||
Fix isearch-group-* colors on low-colour displays
|
||||
|
||||
* lisp/isearch.el (isearch-group-1): On low-color displays, just
|
||||
* lisp/isearch.el (isearch-group-1): On low-colour displays, just
|
||||
use the normal isearch color (bug#43702).
|
||||
(isearch-group-2 etc): Ditto.
|
||||
|
||||
|
|
@ -75874,7 +75446,7 @@
|
|||
According to RFC 3986 it should be percent-encoded and thus should not
|
||||
contain spaces. However, there are HTTP server implementation (notably
|
||||
nginx) that do not do that. This makes Emacs url-http.el behave like
|
||||
most other HTTP client implementations. Also remove the stripping of
|
||||
most other HTTP client implementatios. Also remove the stripping of
|
||||
angle bracket quotes as they are not valid according to the RFCs.
|
||||
|
||||
2020-07-19 Satoshi Nakagawa <ghnacker@gmail.com> (tiny change)
|
||||
|
|
@ -81056,7 +80628,7 @@
|
|||
|
||||
2020-05-17 Andrea Corallo <akrl@sdf.org>
|
||||
|
||||
Fix Garbage Collector for missing callee-saved regs content (Bug#41357)
|
||||
Fix Garbage Collector for missing calle-saved regs content (Bug#41357)
|
||||
|
||||
* src/alloc.c (SET_STACK_TOP_ADDRESS): Do not call
|
||||
__builtin_unwind_init.
|
||||
|
|
@ -88047,7 +87619,7 @@
|
|||
itself and reevaluates it in each stop to yield an address.
|
||||
We also add a warning (a red bold exclamation mark) on the header line
|
||||
when the content of the page doesn't represent the memory location
|
||||
user requested for. That happens when some error occurs in
|
||||
user requested for. That happends when some error occurs in
|
||||
evaluating the address, and we display the last successfully displayed
|
||||
memory page.
|
||||
* lisp/progmodes/gdb-mi.el (gdb-memory-address-expression)
|
||||
|
|
@ -89426,7 +88998,7 @@
|
|||
|
||||
2020-01-19 Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
Make arguments to dired-change-marks non-optional
|
||||
Make arguments to dired-chage-marks non-optional
|
||||
|
||||
* lisp/dired.el (dired-change-marks): Make arguments
|
||||
non-optional. (Bug#29842)
|
||||
|
|
@ -104163,7 +103735,7 @@
|
|||
|
||||
Fixes bug#38131.
|
||||
|
||||
This is not the best way to have fido-mode emulate that particular bit
|
||||
This is not the best way to have fido-mdoe emulate that particular bit
|
||||
of ido-mode.
|
||||
|
||||
This reverts commit 5761a1a3939e23d8e8c725241dd9398a12f191b0.
|
||||
|
|
@ -105655,7 +105227,7 @@
|
|||
Sometimes, when finding files with icomplete-mode, backward-deleting
|
||||
the previous word or sexp (to move up a directory) doesn't actually
|
||||
refresh the file list of the new directory. Forcing redisplay in
|
||||
icomplete-exhibit mysteriously fixes the problem.
|
||||
icomplete-exhibit misteriously fixes the problem.
|
||||
|
||||
* lisp/icomplete.el (icomplete-exhibit): Add call to redisplay.
|
||||
|
||||
|
|
@ -114089,7 +113661,7 @@
|
|||
|
||||
2019-09-04 Lars Ingebrigtsen <larsi@gnus.org>
|
||||
|
||||
Make the NSM not pop up an X dialog on non-mouse actions
|
||||
Make the NSM not pop up an X dialogue on non-mouse actions
|
||||
|
||||
* lisp/emacs-lisp/rmc.el (read-multiple-choice): Don't pop up X
|
||||
dialogs on (url-retrieve "https://expired.badssl.com/" #'ignore)
|
||||
|
|
@ -118873,7 +118445,7 @@
|
|||
internal variable...
|
||||
(browse-url-browser-function, browse-url-external-browser): Used
|
||||
by these two; the latter of which is a new variable.
|
||||
(browse-url-button-regexp): New variable.
|
||||
(browse-url-botton-regexp): New variable.
|
||||
(browse-url-button-map): New keymap.
|
||||
(browse-url-button): New face.
|
||||
(browse-url-add-buttons): New function to add clickable browse-url
|
||||
|
|
@ -124256,7 +123828,7 @@
|
|||
|
||||
* doc/lispref/text.texi (Special Properties): For the hook property
|
||||
modification-hooks, state that inhibit-modification-hooks is NOT bound to
|
||||
non-nil when calling its functions. For the hooks insert-in-front-hooks and
|
||||
non-nil when calling its functions. For the hooks insert-in-fron-hooks and
|
||||
insert-behind-hooks, state that that variable does get bound to non-nil.
|
||||
|
||||
2019-06-24 Hong Xu <hong@topbug.net>
|
||||
|
|
@ -124516,7 +124088,7 @@
|
|||
This is fine when the GPG key is cached and each entry can be
|
||||
decrypted without user interaction. However, for security some people
|
||||
have their GPG on a hardware token like a Yubikey setup so that they
|
||||
have to touch a sensor on the token for every cryptographic operation,
|
||||
have to touch a sensor on the toke for every cryptographic operation,
|
||||
in which case it becomes inconvenient as each attempt to find an entry
|
||||
requires a variable number of touches of the hardware token.
|
||||
|
||||
|
|
@ -130153,7 +129725,7 @@
|
|||
* lisp/delim-col.el: Use lexical-binding.
|
||||
|
||||
* test/lisp/delim-col-tests.el: New file.
|
||||
(delim-col-tests-delimit-columns-before-after)
|
||||
(delim-col-tests-delimit-colummns-before-after)
|
||||
(delim-col-tests-delimit-columns)
|
||||
(delim-col-tests-delimit-columns-format/nil)
|
||||
(delim-col-tests-delimit-columns-format/padding)
|
||||
|
|
@ -139451,7 +139023,7 @@
|
|||
Add 'breakpoint' to builtins for Python
|
||||
|
||||
* lisp/progmodes/python.el (python-font-lock-keywords-level-2)
|
||||
(python-font-lock-keywords-maximum-decoration): Add 'breakpoint'
|
||||
(python-font-lock-keywords-maxiumum-decoration): Add 'breakpoint'
|
||||
to the list of builtins, it's new as of Python 3.7.
|
||||
|
||||
2019-03-01 Eli Zaretskii <eliz@gnu.org>
|
||||
|
|
@ -143483,7 +143055,7 @@
|
|||
|
||||
2019-01-05 João Távora <joaotavora@gmail.com>
|
||||
|
||||
New flymake-suppress-zero-counters defcustom
|
||||
New flymake-supress-zero-counters defcustom
|
||||
|
||||
A feature suggested by Yuri Khan <yurivkhan@gmail.com>.
|
||||
|
||||
|
|
@ -155042,7 +154614,7 @@
|
|||
Fixes: Bug#31951
|
||||
|
||||
* lisp/server.el (server-save-buffers-kill-terminal): Only pass
|
||||
PRED=t to save-some-buffers if ARG in non-nil.
|
||||
PRED=t to save-some-bufers if ARG in non-nil.
|
||||
|
||||
2018-06-27 Vincent Belaïche <vincentb1@users.sourceforge.net>
|
||||
|
||||
|
|
@ -156973,7 +156545,7 @@
|
|||
Obsolete Flymake's flymake-diagnostic-types-alist
|
||||
|
||||
That variable was an association between symbols and properties,
|
||||
effectively duplicating symbol's property lists. It is simpler to just
|
||||
effecively duplicating symbol's property lists. It is simpler to just
|
||||
put properties on symbols. Backward compatibility to the old variable
|
||||
has been kept.
|
||||
|
||||
|
|
@ -186289,7 +185861,7 @@
|
|||
(flymake-start-syntax-check-on-find-file): Obsolete alias for
|
||||
flymake-start-on-flymake-mode.
|
||||
(flymake-start): Redesign. Affect the global post-command-hook
|
||||
and local window-configuration-change-hook.
|
||||
and local window-configuraiton-change-hook.
|
||||
(flymake--schedule-timer-maybe)
|
||||
(flymake-after-change-function, flymake-after-save-hook): Pass
|
||||
t to flymake-start.
|
||||
|
|
@ -191121,7 +190693,7 @@
|
|||
Support multi-lingual detection of SEE ALSO man sections
|
||||
|
||||
* lisp/man.el (Man-see-also-regexp): Add support for SEE ALSO
|
||||
section detection in several languages: French, German, Spanish,
|
||||
section detection in several langages: French, German, Spanish,
|
||||
Portuguese, Italian, Polish, Turkish, Japanese, Chinese. (Bug#28142)
|
||||
|
||||
2017-08-26 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
|
@ -191331,7 +190903,7 @@
|
|||
(initFrameFromEmacs) [NS_IMPL_COCOA]: Handle ns-appearance and
|
||||
ns-transparent-titlebar frame parameters.
|
||||
* doc/lispref/frames.texi (Window Management Parameters): Document
|
||||
ns-appearance and ns-transparent-titlebar.
|
||||
ns-apperance and ns-transparent-titlebar.
|
||||
|
||||
2017-08-22 Alan Mackenzie <acm@muc.de>
|
||||
|
||||
|
|
@ -203190,7 +202762,7 @@
|
|||
(w32_frame_parm_handlers): Add entries for new frame
|
||||
parameters.
|
||||
* src/w32font.c (Fx_select_font): Handle `z-group-above'
|
||||
frames during font selection dialog.
|
||||
frames during font selection dialogue.
|
||||
* src/w32term.c (construct_mouse_wheel): Construct mouse wheel
|
||||
event from F's w32 window.
|
||||
(w32_mouse_position): Handle child frames.
|
||||
|
|
@ -204444,7 +204016,7 @@
|
|||
|
||||
2017-04-02 Michael Albinus <michael.albinus@gmx.de>
|
||||
|
||||
Apply connection-local variables for shells
|
||||
Apply connecion-local variables for shells
|
||||
|
||||
* doc/misc/tramp.texi (Remote processes): Show use of connection-local
|
||||
variables. Don't mention Emacs 23 anymore.
|
||||
|
|
@ -204455,7 +204027,7 @@
|
|||
(connection-local-set-profiles, with-connection-local-profiles):
|
||||
Adapt docstring.
|
||||
|
||||
* lisp/shell.el (shell): Apply connection-local variables.
|
||||
* lisp/shell.el (shell): Apply connecion-local variables.
|
||||
|
||||
2017-04-01 Evgeni Kolev <evgenysw@gmail.com> (tiny change)
|
||||
|
||||
|
|
@ -205169,7 +204741,7 @@
|
|||
|
||||
2017-03-21 Noam Postavsky <npostavs@gmail.com>
|
||||
|
||||
Narrow scope of modification hook re-enabling in org-src fontification
|
||||
Narrow scope of modification hook renabling in org-src fontification
|
||||
|
||||
Modification hooks should be enabled while modifying text in the
|
||||
org-src temp buffer, but in 2017-01-29 "Call modification hooks in
|
||||
|
|
@ -207101,7 +206673,7 @@
|
|||
* lisp/emacs-lisp/package.el (package-initialize): Check
|
||||
`after-init-time' rather than `load-file-name' to decide if
|
||||
`package--ensure-init-file' should be called. Depending on
|
||||
`load-file-name' will fail if the user calls `package-initialize' in
|
||||
`load-file-name' will fail if the user calls `pacakge-initialize' in
|
||||
file which is loaded from the init file (Bug#24643, Bug#25819).
|
||||
|
||||
2017-02-26 Eli Zaretskii <eliz@gnu.org>
|
||||
|
|
@ -222017,7 +221589,7 @@
|
|||
(ses-define-if-new-local-printer): New defsubst.
|
||||
(ses-center, ses-center-span, ses-dashfill)
|
||||
(ses-dashfill-span, ses-tildefill-span): Allow to pass printer
|
||||
as an optional argument to supersede column printer/default
|
||||
as an optional argument to superseed column printer/default
|
||||
spreadsheet printer.
|
||||
(ses-prin1): New defun.
|
||||
|
||||
|
|
@ -230386,7 +229958,7 @@
|
|||
Use #' read syntax for functions.
|
||||
(file-notify-test05-dir-validity)
|
||||
(file-notify-test06-many-events): Simplify directory creation.
|
||||
(file-notify-test09-sufficient-resources): New test.
|
||||
(file-notify-test09-sufficient-ressources): New test.
|
||||
|
||||
2016-03-04 Lars Ingebrigtsen <larsi@gnus.org>
|
||||
|
||||
|
|
@ -231516,7 +231088,7 @@
|
|||
* lisp/gnus/gnus-rfc1843.el: New file for Gnus/rfc1843
|
||||
interface functions.
|
||||
|
||||
* lisp/gnus/gnus-rfc1843.el: Move all Gnus-specific functions to
|
||||
* lisp/gnus/gnus-rfc1843.el: Move all Gnus-specifig functions to
|
||||
gnus-rfc1843.
|
||||
|
||||
2016-02-22 Lars Ingebrigtsen <larsi@gnus.org>
|
||||
|
|
@ -237348,14 +236920,14 @@
|
|||
|
||||
This file records repository revisions from
|
||||
commit 9d56a21e6a696ad19ac65c4b405aeca44785884a (exclusive) to
|
||||
commit f7bd5ac55211ad0ae2e473f0dff46df1e60f99bf (inclusive).
|
||||
commit ddabb03a0176beb4b7fc8d4f2267d459fd2ebded (inclusive).
|
||||
See ChangeLog.2 for earlier changes.
|
||||
|
||||
;; Local Variables:
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
|
||||
Copyright (C) 2015-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2015-2022 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
114348
ChangeLog.4
114348
ChangeLog.4
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
# Build Emacs from a fresh tarball or version-control checkout.
|
||||
|
||||
# Copyright (C) 2011-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2011-2022 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of GNU Emacs.
|
||||
#
|
||||
|
|
|
|||
2
INSTALL
2
INSTALL
|
|
@ -1,5 +1,5 @@
|
|||
GNU Emacs Installation Guide
|
||||
Copyright (C) 1992, 1994, 1996-1997, 2000-2023 Free Software Foundation,
|
||||
Copyright (C) 1992, 1994, 1996-1997, 2000-2022 Free Software Foundation,
|
||||
Inc.
|
||||
See the end of the file for license conditions.
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ The Emacs repository is hosted on Savannah. The following Git command
|
|||
will clone the repository to the 'emacs' subdirectory of the current
|
||||
directory on your local machine:
|
||||
|
||||
git clone https://git.savannah.gnu.org/git/emacs.git
|
||||
git clone git://git.sv.gnu.org/emacs.git
|
||||
|
||||
To build the repository code, simply run 'make' in the 'emacs'
|
||||
directory. This should work if your files are freshly checked out
|
||||
|
|
@ -98,7 +98,7 @@ never platform-specific.
|
|||
|
||||
|
||||
|
||||
Copyright (C) 2002-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-2022 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
15
Makefile.in
15
Makefile.in
|
|
@ -1,6 +1,6 @@
|
|||
### @configure_input@
|
||||
|
||||
# Copyright (C) 1992-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1992-2022 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU Emacs.
|
||||
|
||||
|
|
@ -417,9 +417,9 @@ advice-on-failure:
|
|||
|
||||
sanity-check:
|
||||
@[ -f .no-advice-on-failure ] && exit 0; true
|
||||
@v=`src/emacs${EXEEXT} --batch --eval \
|
||||
@v=$$(src/emacs${EXEEXT} --batch --eval \
|
||||
'(progn (defun f (n) (if (= 0 n) 1 (* n (f (- n 1))))) (princ (f 10)))' \
|
||||
2> /dev/null`; \
|
||||
2> /dev/null); \
|
||||
[ "X$$v" = "X3628800" ] && exit 0; \
|
||||
echo >&2 '***'; \
|
||||
echo >&2 '*** '"\"make ${make-target}\" succeeded, but Emacs is not functional."; \
|
||||
|
|
@ -841,7 +841,7 @@ install-etc:
|
|||
rm -f $${tmp}
|
||||
tmp=etc/emacsclient.tmpdesktop; rm -f $${tmp}; \
|
||||
client_name=`echo emacsclient | sed '$(TRANSFORM)'`${EXEEXT}; \
|
||||
sed -e "/^Exec=/ s|emacsclient|${bindir}/$${client_name}|" \
|
||||
sed -e "/^Exec=emacsclient/ s|emacsclient|${bindir}/$${client_name}|" \
|
||||
-e "/^Icon=emacs/ s/emacs/${EMACS_NAME}/" \
|
||||
$(USE_STARTUP_NOTIFICATION_SED_CMD) \
|
||||
${srcdir}/etc/emacsclient.desktop > $${tmp}; \
|
||||
|
|
@ -855,7 +855,7 @@ install-etc:
|
|||
rm -f $${tmp}
|
||||
tmp=etc/emacsclient-mail.tmpdesktop; rm -f $${tmp}; \
|
||||
client_name=`echo emacsclient | sed '$(TRANSFORM)'`${EXEEXT}; \
|
||||
sed -e "/^Exec=/ s|emacsclient|${bindir}/$${client_name}|" \
|
||||
sed -e "/^Exec=emacsclient/ s|emacsclient|${bindir}/$${client_name}|" \
|
||||
-e "/^Icon=emacs/ s/emacs/${EMACS_NAME}/" \
|
||||
${srcdir}/etc/emacsclient-mail.desktop > $${tmp}; \
|
||||
${INSTALL_DATA} $${tmp} "$(DESTDIR)${desktopdir}/$${client_name}-mail.desktop"; \
|
||||
|
|
@ -1030,9 +1030,6 @@ $(foreach dir,$(distclean_dirs),$(eval $(call submake_template,$(dir),distclean)
|
|||
|
||||
distclean: $(distclean_dirs:=_distclean) clean-gsettings-schemas
|
||||
${top_distclean}
|
||||
ifeq ($(HAVE_NATIVE_COMP),yes)
|
||||
rm -rf native-lisp
|
||||
endif
|
||||
|
||||
### 'bootstrap-clean'
|
||||
### Delete everything that can be reconstructed by 'make' and that
|
||||
|
|
@ -1287,7 +1284,7 @@ PREFERRED_BRANCH = emacs-28
|
|||
preferred-branch-is-current:
|
||||
git branch | grep -q '^\* $(PREFERRED_BRANCH)$$'
|
||||
unchanged-history-files:
|
||||
x=`git diff-files --name-only $(CHANGELOG_N) $(emacslog)` && \
|
||||
x=$$(git diff-files --name-only $(CHANGELOG_N) $(emacslog)) && \
|
||||
test -z "$$x"
|
||||
|
||||
# Regular expression that matches the newest commit covered by a ChangeLog.
|
||||
|
|
|
|||
2
README
2
README
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001-2022 Free Software Foundation, Inc.
|
||||
See the end of the file for license conditions.
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2577,7 +2577,7 @@
|
|||
;; coding: utf-8
|
||||
;; End:
|
||||
|
||||
Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001-2022 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ Po Lu
|
|||
|
||||
Tramp
|
||||
Maintainer: Michael Albinus
|
||||
Repository: https://git.savannah.gnu.org/git/tramp.git
|
||||
Repository: git://git.savannah.gnu.org/tramp.git
|
||||
Mailing List: tramp-devel@gnu.org
|
||||
Bug Reports: M-x tramp-bug
|
||||
Notes: For backward compatibility requirements, see
|
||||
|
|
@ -316,7 +316,7 @@ Modus themes
|
|||
Org Mode
|
||||
Home Page: https://orgmode.org/
|
||||
Maintainer: Org Mode developers
|
||||
Repository: https://git.savannah.gnu.org/git/emacs/org-mode.git
|
||||
Repository: git://git.sv.gnu.org/emacs/org-mode.git
|
||||
Mailing list: emacs-orgmode@gnu.org
|
||||
Bug Reports: M-x org-submit-bug-report
|
||||
Notes: Org Mode is maintained as a separate project that is
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001-2022 Free Software Foundation, Inc.
|
||||
See the end of the file for license conditions.
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
;;; admin.el --- utilities for Emacs administration -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2001-2022 Free Software Foundation, Inc.
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
|
|
@ -843,11 +843,8 @@ $Date: %s $
|
|||
(package-install pkg)
|
||||
(require pkg nil t))))
|
||||
|
||||
(declare-function org-html-export-as-html "ox-html.el")
|
||||
(defvar org-html-postamble)
|
||||
(defvar org-html-mathjax-template)
|
||||
(defvar htmlize-output-type)
|
||||
|
||||
(defun make-news-html-file (root version)
|
||||
"Convert the NEWS file into an HTML file."
|
||||
(interactive (let ((root
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Allocate X colors. Used for testing with dense colormaps.
|
||||
|
||||
Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001-2022 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
;;; authors.el --- utility for maintaining Emacs's AUTHORS file -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2000-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2000-2022 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Gerd Moellmann <gerd@gnu.org>
|
||||
;; Maintainer: emacs-devel@gnu.org
|
||||
|
|
@ -182,7 +182,7 @@ files.")
|
|||
("Philip Kaludercic" "Philip K\\." "Philip K")
|
||||
("Philipp Stephani" "Philipp .*phst@google")
|
||||
("Piotr Zieliński" "Piotr Zielinski")
|
||||
("Po Lu" "Po Lu Via" "Your Name") ; looks like a mistake
|
||||
("Po Lu" "Po Lu Via") ; looks like a mistake
|
||||
("Przemysław Wojnowski" "Przemyslaw Wojnowski")
|
||||
("R. Bernstein" "rb@dustyfeet.com")
|
||||
("Rainer Schöpf" "Rainer Schoepf")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
### automerge - automatically merge the Emacs release branch to master
|
||||
|
||||
## Copyright (C) 2018-2023 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2018-2022 Free Software Foundation, Inc.
|
||||
|
||||
## Author: Glenn Morris <rgm@gnu.org>
|
||||
## Maintainer: Stefan Kangas <stefankangas@gmail.com>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#! /usr/bin/perl
|
||||
# Build Emacs in several different configurations.
|
||||
|
||||
# Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2022 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
### @configure_input@
|
||||
|
||||
# Copyright (C) 2015-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2015-2022 Free Software Foundation, Inc.
|
||||
|
||||
# Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
|
||||
# National Institute of Advanced Industrial Science and Technology (AIST)
|
||||
|
|
@ -181,7 +181,7 @@ ${charsetdir}/GB180304.map: ${charsetdir}/GB180302.map ${gb180304}
|
|||
${AM_V_GEN}$(AWK) -f ${gb180304} < $< > $@
|
||||
|
||||
${charsetdir}/JISX0201.map: ${GLIBC_CHARMAPS}/JIS_X0201.gz ${mapconv} ${compact}
|
||||
${AM_V_GEN}(${run_mapconv} $< '/^<.*[ ]\/x[0-9]/' GLIBC-1 ${compact} && \
|
||||
${AM_V_GEN}(${mapconv} $< '/^<.*[ ]\/x[0-9]/' GLIBC-1 ${compact} && \
|
||||
echo "# Generated by hand" && \
|
||||
echo "0xA1-0xDF 0xFF61" ) > $@
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2015-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2015-2022 Free Software Foundation, Inc.
|
||||
|
||||
# Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
|
||||
# National Institute of Advanced Industrial Science and Technology (AIST)
|
||||
|
|
@ -38,8 +38,7 @@
|
|||
## So that eg [A-F] as used by KANJI-DATABASE branch below works as expected.
|
||||
## Otherwise with LANG=en_US.utf8, CNS-6.map was generated with a
|
||||
## bogus entry. By experiment, LC_COLLATE=C was not enough.
|
||||
LC_ALL=C
|
||||
export LC_ALL
|
||||
export LC_ALL=C
|
||||
|
||||
BASE=`expr "$1" : '.*/\(.*\)' '|' "$1"` # basename
|
||||
FILE="admin/charsets/mapfiles/$BASE"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (C) 2009-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2009-2022 Free Software Foundation, Inc.
|
||||
Copyright (C) 2009, 2010, 2011
|
||||
National Institute of Advanced Industrial Science and Technology (AIST)
|
||||
Registration Number H13PRO009
|
||||
|
|
|
|||
|
|
@ -1,56 +0,0 @@
|
|||
#!/bin/bash
|
||||
### check-man-pages - check man pages for errors
|
||||
|
||||
## Copyright (C) 2022-2023 Free Software Foundation, Inc.
|
||||
|
||||
## Author: Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
## This file is part of GNU Emacs.
|
||||
|
||||
## GNU Emacs is free software: you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation, either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
|
||||
## GNU Emacs is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
### Commentary:
|
||||
|
||||
## Check Emacs man pages for errors using `man'.
|
||||
|
||||
### Code:
|
||||
|
||||
source "${0%/*}/emacs-shell-lib"
|
||||
|
||||
exit_status=0
|
||||
|
||||
cd "$PD"/../doc/man
|
||||
for page in *.1; do
|
||||
# ctags.1 just includes the man page etags.1, which AFAICT will
|
||||
# default to the one installed on the system (!), instead of the
|
||||
# one in the repository. So checking it is pointless, and we will
|
||||
# in any case already check etags.1 separately.
|
||||
if [ "$page" == "ctags.1" ]; then
|
||||
continue
|
||||
fi
|
||||
log=$(emacs_mktemp)
|
||||
LC_ALL=C.UTF-8 MANROFFSEQ='' MANWIDTH=80 \
|
||||
man --warnings=all,mac -E UTF-8 -l -Tutf8 -Z "$page" >/dev/null 2> "$log"
|
||||
log_size=$(stat --format=%s "$log")
|
||||
if [ "$log_size" -ne 0 ]; then
|
||||
echo "doc/man/$page:"
|
||||
# Point to the correct file for *compilation* buffers.
|
||||
cat "$log" \
|
||||
| sed 's/troff: man1\/\([^ ]\+\)\.1/troff: doc\/man\/\1.1/' \
|
||||
| sed "s/<standard input>/doc\/man\/$page/"
|
||||
exit_status=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $exit_status
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
;;; cus-test.el --- tests for custom types and load problems -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 1998, 2000, 2002-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 1998, 2000, 2002-2022 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Markus Rost <rost@math.uni-bielefeld.de>
|
||||
;; Created: 13 Sep 1998
|
||||
|
|
@ -145,8 +145,7 @@ Names should be as they appear in loaddefs.el.")
|
|||
(require 'cus-load)
|
||||
|
||||
(defvar cus-test-errors nil
|
||||
"List of problematic variables found by `cus-test-apropos'.
|
||||
Each element is (VARIABLE . PROBLEM); see `cus-test--format-problem'.")
|
||||
"List of problematic variables found by `cus-test-apropos'.")
|
||||
|
||||
(defvar cus-test-tested-variables nil
|
||||
"List of options tested by last call of `cus-test-apropos'.")
|
||||
|
|
@ -182,15 +181,6 @@ Set by `cus-test-noloads'.")
|
|||
;; (defvar cus-test-vars-cus-loaded nil
|
||||
;; "A list of options loaded by `custom-load-symbol'.")
|
||||
|
||||
(defun cus-test--format-error (err)
|
||||
"Format an element of `cus-test-errors'."
|
||||
(pcase err
|
||||
(`(,var :type-error ,value ,type)
|
||||
(format "variable: %s\n value: %S\n type: %S" var value type))
|
||||
(`(,var :other-error ,e)
|
||||
(format "variable: %s\n error: %S" var e))
|
||||
(_ (format "%S" err))))
|
||||
|
||||
(defun cus-test-apropos (regexp)
|
||||
"Check the options matching REGEXP.
|
||||
The detected problematic options are stored in `cus-test-errors'."
|
||||
|
|
@ -210,7 +200,8 @@ The detected problematic options are stored in `cus-test-errors'."
|
|||
(let* ((type (custom-variable-type symbol))
|
||||
(conv (widget-convert type))
|
||||
(get (or (get symbol 'custom-get) 'default-value))
|
||||
values)
|
||||
values
|
||||
mismatch)
|
||||
(when (default-boundp symbol)
|
||||
(push (funcall get symbol) values)
|
||||
(push (eval (car (get symbol 'standard-value)) t) values))
|
||||
|
|
@ -224,9 +215,7 @@ The detected problematic options are stored in `cus-test-errors'."
|
|||
;; TODO for booleans, check for values that can be
|
||||
;; evaluated and are not t or nil. Usually a bug.
|
||||
(unless (widget-apply conv :match value)
|
||||
(let ((err (list symbol :type-error value type)))
|
||||
(unless (member err cus-test-errors)
|
||||
(push err cus-test-errors)))))
|
||||
(setq mismatch 'mismatch)))
|
||||
values)
|
||||
|
||||
;; Store symbols with a custom-get property.
|
||||
|
|
@ -242,12 +231,13 @@ The detected problematic options are stored in `cus-test-errors'."
|
|||
(and (consp c-value)
|
||||
(boundp symbol)
|
||||
(not (equal (eval (car c-value) t) (symbol-value symbol)))
|
||||
(add-to-list 'cus-test-vars-with-changed-state symbol))))
|
||||
(add-to-list 'cus-test-vars-with-changed-state symbol)))
|
||||
|
||||
(if mismatch
|
||||
(push symbol cus-test-errors)))
|
||||
|
||||
(error
|
||||
(let ((err (list symbol :other-error alpha)))
|
||||
(unless (member err cus-test-errors)
|
||||
(push err cus-test-errors)))
|
||||
(push symbol cus-test-errors)
|
||||
(message "Error for %s: %s" symbol alpha))))
|
||||
(cus-test-get-options regexp))
|
||||
(message "%s options tested"
|
||||
|
|
@ -302,7 +292,7 @@ currently defined groups."
|
|||
(insert "No errors found by cus-test.")
|
||||
(insert "The following variables seem to have problems:\n\n")
|
||||
(dolist (e cus-test-errors)
|
||||
(insert (cus-test--format-error e) "\n")))))
|
||||
(insert (symbol-name e) "\n")))))
|
||||
|
||||
(defun cus-test-load-custom-loads ()
|
||||
"Call `custom-load-symbol' on all atoms."
|
||||
|
|
@ -409,7 +399,7 @@ Returns a list of variables with suspicious types."
|
|||
(message "No problems found")
|
||||
nil)
|
||||
(message "The following options might have problems:")
|
||||
(cus-test-message (mapcar #'cus-test--format-error cus-test-errors))
|
||||
(cus-test-message cus-test-errors)
|
||||
cus-test-errors))
|
||||
|
||||
(defun cus-test-deps ()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2022 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
### emacs-shell-lib - shared code for Emacs shell scripts
|
||||
|
||||
## Copyright (C) 2022-2023 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2022 Free Software Foundation, Inc.
|
||||
|
||||
## Author: Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2022-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2022 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
;;; find-gc.el --- detect functions that call the garbage collector -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 1992, 2001-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 1992, 2001-2022 Free Software Foundation, Inc.
|
||||
|
||||
;; Maintainer: emacs-devel@gnu.org
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ Also store it in `find-gc-unsafe-list'."
|
|||
|
||||
|
||||
|
||||
(defun trace-call-tree (&optional _ignored)
|
||||
(defun trace-call-tree (&optional ignored)
|
||||
(message "Setting up directories...")
|
||||
(setq find-gc-subrs-called nil)
|
||||
(let ((case-fold-search nil)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
;;; gitmerge.el --- help merge one Emacs branch into another -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2010-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2010-2022 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: David Engster <deng@randomsample.de>
|
||||
;; Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
|
@ -293,7 +293,7 @@ should not be skipped."
|
|||
"Try to resolve conflicts in FILE with smerge.
|
||||
Returns non-nil if conflicts remain."
|
||||
(unless (file-exists-p file) (error "Gitmerge-resolve: Can't find %s" file))
|
||||
(with-demoted-errors "Error: %S"
|
||||
(with-demoted-errors
|
||||
(let ((exists (find-buffer-visiting file)))
|
||||
(with-current-buffer (let ((enable-local-variables :safe)
|
||||
(enable-local-eval nil))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
### @configure_input@
|
||||
|
||||
## Copyright (C) 2013-2023 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2013-2022 Free Software Foundation, Inc.
|
||||
|
||||
## This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;;; c.by -- LL grammar for C/C++ language specification
|
||||
;; Copyright (C) 1999-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 1999-2022 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: Eric M. Ludlam <zappo@gnu.org>
|
||||
;; David Ponce <david@dponce.com>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
;;; semantic-grammar.wy -- LALR grammar of Semantic input grammars
|
||||
;;
|
||||
;; Copyright (C) 2002-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2002-2022 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: David Ponce <david@dponce.com>
|
||||
;; Created: 26 Aug 2002
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
;;; java-tags.wy -- Semantic LALR grammar for Java
|
||||
|
||||
;; Copyright (C) 2002-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2002-2022 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: David Ponce <david@dponce.com>
|
||||
;; Created: 26 Aug 2002
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
;;; javascript-jv.wy -- LALR grammar for Javascript
|
||||
|
||||
;; Copyright (C) 2005-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2005-2022 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 1998-2011 Ecma International.
|
||||
|
||||
;; Author: Joakim Verona
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
;;; make.by -- BY notation for Makefiles.
|
||||
|
||||
;; Copyright (C) 1999-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 1999-2022 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: Eric M. Ludlam <zappo@gnu.org>
|
||||
;; David Ponce <david@dponce.com>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
;;; python.wy -- LALR grammar for Python
|
||||
|
||||
;; Copyright (C) 2002-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2002-2022 Free Software Foundation, Inc.
|
||||
;; Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
|
||||
;; 2009, 2010 Python Software Foundation; All Rights Reserved
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
;;; scheme.by -- Scheme BNF language specification
|
||||
|
||||
;; Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2001-2022 Free Software Foundation, Inc.
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
;;; srecode-template.wy --- Semantic Recoder Template parser
|
||||
|
||||
;; Copyright (C) 2005-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2005-2022 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric M. Ludlam <zappo@gnu.org>
|
||||
;; Keywords: syntax
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
;;; last-chance.el --- dangling deterrence -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2016-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2016-2022 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Thien-Thi Nguyen <ttn@gnu.org>
|
||||
;; Maintainer: emacs-devel@gnu.org
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# Build Emacs with various options for profiling, debugging,
|
||||
# with and without warnings enabled etc.
|
||||
|
||||
# Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2022 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
### make-manuals - create the Emacs manuals to upload to the gnu.org website
|
||||
|
||||
## Copyright 2018-2023 Free Software Foundation, Inc.
|
||||
## Copyright 2018-2022 Free Software Foundation, Inc.
|
||||
|
||||
## Author: Glenn Morris <rgm@gnu.org>
|
||||
## Maintainer: emacs-devel@gnu.org
|
||||
|
|
|
|||
|
|
@ -68,25 +68,16 @@ General steps (for each step, check for possible errors):
|
|||
PREFERRED_BRANCH = emacs-NN
|
||||
|
||||
where NN is the version on the release branch from which you are
|
||||
producing the tarball. If NN is incorrect (which it usually is
|
||||
when starting a pretest of a new major release), update
|
||||
Makefile.in and re-run 'configure' to update Makefile.
|
||||
producing the tarball. If NN is incorrect, update Makefile.in and
|
||||
re-run 'configure' to update Makefile.
|
||||
|
||||
For the first pretest of a new major release, consider starting a
|
||||
new top-level ChangeLog.N file if the last versioned ChangeLog.N
|
||||
file is too large. A good point to start a new ChangeLog.N file
|
||||
is when the last one gets larger than 1.5 MiB. If so, start a new
|
||||
one by bumping N, and also update the line in top-level
|
||||
Makefile.in which says
|
||||
If the versioned ChangeLog.N file is too large, start a new one
|
||||
by bumping N, and also update the line in top-level Makefile.in
|
||||
which says
|
||||
|
||||
CHANGELOG_HISTORY_INDEX_MAX = N
|
||||
|
||||
by incrementing the value of N by 1; then regenerate Makefile.
|
||||
After bumping N, you need to actually create and commit
|
||||
ChangeLog.N with the updated N, otherwise "M-x authors" below will
|
||||
fail. The easiest way of creating the new ChangeLog.N is to
|
||||
rename the file ChangeLog (without the .N suffix) left over from
|
||||
the last major release (it is usually unversioned) and commit it.
|
||||
|
||||
Now:
|
||||
|
||||
|
|
@ -108,12 +99,11 @@ General steps (for each step, check for possible errors):
|
|||
the relevant entry. If a file was deleted or renamed, consider
|
||||
adding an appropriate entry to variables authors-ignored-files,
|
||||
authors-valid-file-names, or authors-renamed-files-alist in
|
||||
authors.el. If some authors are "ignored", consider adding
|
||||
entries to the author-aliases variable.
|
||||
authors.el.
|
||||
|
||||
If necessary, repeat 'C-u M-x authors' after making those changes.
|
||||
Save the "*Authors*" buffer as etc/AUTHORS.
|
||||
Check the diff looks reasonable. Maybe add more entries to
|
||||
Check the diff looks reasonable. Maybe add entries to
|
||||
authors-ambiguous-files or authors-aliases, and repeat.
|
||||
Commit any fixes to authors.el.
|
||||
|
||||
|
|
@ -160,13 +150,6 @@ General steps (for each step, check for possible errors):
|
|||
4. autoreconf -i -I m4 --force
|
||||
make bootstrap
|
||||
|
||||
The below script checks for any mistakes in the source text of
|
||||
manual pages. Fix any errors and re-run the script to verify.
|
||||
|
||||
./admin/check-man-pages
|
||||
|
||||
Then do this:
|
||||
|
||||
make -C etc/refcards
|
||||
make -C etc/refcards clean
|
||||
|
||||
|
|
@ -179,13 +162,7 @@ General steps (for each step, check for possible errors):
|
|||
messages from TeX, but those seem to be harmless, as the result
|
||||
looks just fine.)
|
||||
|
||||
5. Copy lisp/loaddefs.el to lisp/ldefs-boot.el. After copying, edit
|
||||
ldefs-boot.el to add
|
||||
|
||||
;; no-byte-compile: t
|
||||
|
||||
to its file-local variables section, otherwise make-dist will
|
||||
complain.
|
||||
5. Copy lisp/loaddefs.el to lisp/ldefs-boot.el.
|
||||
|
||||
Commit ChangeLog.N, etc/AUTHORS, lisp/ldefs-boot.el, and the files
|
||||
changed by M-x set-version. Note that the set-version changes
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
# admin/merge-gnulib
|
||||
|
||||
# Copyright 2012-2023 Free Software Foundation, Inc.
|
||||
# Copyright 2012-2022 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU Emacs.
|
||||
|
||||
|
|
@ -23,30 +23,29 @@
|
|||
|
||||
# written by Paul Eggert
|
||||
|
||||
GNULIB_URL=https://git.savannah.gnu.org/git/gnulib.git
|
||||
GNULIB_URL=git://git.savannah.gnu.org/gnulib.git
|
||||
|
||||
GNULIB_MODULES='
|
||||
alignasof alloca-opt binary-io byteswap c-ctype c-strcase
|
||||
alloca-opt binary-io byteswap c-ctype c-strcase
|
||||
canonicalize-lgpl
|
||||
careadlinkat close-stream copy-file-range
|
||||
count-leading-zeros count-one-bits count-trailing-zeros
|
||||
crypto/md5 crypto/md5-buffer
|
||||
crypto/sha1-buffer crypto/sha256-buffer crypto/sha512-buffer
|
||||
d-type diffseq double-slash-root dtoastr dtotimespec dup2
|
||||
environ execinfo faccessat
|
||||
environ execinfo explicit_bzero faccessat
|
||||
fchmodat fcntl fcntl-h fdopendir file-has-acl
|
||||
filemode filename filevercmp flexmember fpieee
|
||||
free-posix fstatat fsusage fsync futimens
|
||||
getloadavg getopt-gnu getrandom gettime gettimeofday gitlog-to-changelog
|
||||
ieee754-h ignore-value intprops largefile libgmp lstat
|
||||
manywarnings memmem-simple mempcpy memrchr memset_explicit
|
||||
minmax mkostemp mktime
|
||||
manywarnings memmem-simple mempcpy memrchr minmax mkostemp mktime
|
||||
nanosleep nproc nstrftime
|
||||
pathmax pipe2 pselect pthread_sigmask
|
||||
qcopy-acl readlink readlinkat regex
|
||||
sig2str sigdescr_np socklen stat-time std-gnu11 stdbool stddef stdio
|
||||
sig2str sigdescr_np socklen stat-time std-gnu11 stdalign stdbool stddef stdio
|
||||
stpcpy strnlen strtoimax symlink sys_stat sys_time
|
||||
tempname time-h time_r time_rz timegm timer-time timespec-add timespec-sub
|
||||
tempname time time_r time_rz timegm timer-time timespec-add timespec-sub
|
||||
update-copyright unlocked-io utimensat
|
||||
vla warnings
|
||||
'
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
# admin/merge-pkg-config
|
||||
|
||||
# Copyright 2014-2023 Free Software Foundation, Inc.
|
||||
# Copyright 2014-2022 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (C) 2007-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2022 Free Software Foundation, Inc.
|
||||
See the end of the file for license conditions.
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ NOTES ON THE EMACS PACKAGE ARCHIVE
|
|||
The GNU Emacs package archive, at elpa.gnu.org, is managed using a Git
|
||||
repository named "elpa", hosted on Savannah. To check it out:
|
||||
|
||||
git clone https://git.savannah.gnu.org/git/emacs/elpa
|
||||
git clone git://git.sv.gnu.org/emacs/elpa
|
||||
cd elpa
|
||||
make setup
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
-*- mode: outline; coding: utf-8 -*-
|
||||
|
||||
Copyright (C) 2019-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2019-2022 Free Software Foundation, Inc.
|
||||
See the end of the file for license conditions.
|
||||
|
||||
NOTES FOR EMACS CONTINUOUS BUILD ON EMBA
|
||||
|
|
@ -83,46 +83,6 @@ Lisp packages, Makefiles, scripts, and other software could determine
|
|||
whether they run on emba by checking for the environment variable
|
||||
EMACS_EMBA_CI.
|
||||
|
||||
* Running Emba tests locally
|
||||
|
||||
As usual in GitLab, the tests run in containers, which could be
|
||||
applied also locally. Unfortunately, the Emba container registry,
|
||||
emba.gnu.org:5050, is not accessible publicly. Instead, the container
|
||||
images must be build locally. Change the current directory to a
|
||||
recent Emacs branch, and apply the command
|
||||
|
||||
docker build --target emacs-inotify --tag emacs-inotify \
|
||||
-f test/infra/Dockerfile.emba .
|
||||
|
||||
This creates the Debian-based image emacs-inotify, based on the
|
||||
instructions in the file Dockerfile.emba. This image is good for the
|
||||
majority of tests. However, there are also other image build
|
||||
instructions like emacs-filenotify-gio, emacs-eglot, emacs-gnustep and
|
||||
emacs-native-comp-speed{0,1,2}. Use the appropriate one.
|
||||
|
||||
The image contains a directory "/checkout", which is a copy of your
|
||||
local Emacs git repository. Emacs has been built in this directory
|
||||
via "make bootstrap". In order to use the image, start a container
|
||||
like
|
||||
|
||||
docker run --interactive --env EMACS_EMBA_CI=1 --name emacs-inotify \
|
||||
emacs-inotify /bin/sh -i
|
||||
|
||||
In this container, change the current directory to "/checkout". Now
|
||||
you can apply all commands known for Emacs, like
|
||||
|
||||
cd /checkout
|
||||
make -C test files-tests.log
|
||||
|
||||
While this container runs, you can also access its filesystem from
|
||||
your local Emacs via Tramp. For example, in order to see the result
|
||||
of the above test run, open the log file in your local Emacs with
|
||||
|
||||
C-x C-f /docker:emacs-inotify:/checkout/test/lisp/files-tests.log
|
||||
|
||||
Note: On local Red Hat-based systems, use "podman" instead of "docker"
|
||||
in the shell commands and Tramp file names.
|
||||
|
||||
|
||||
This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@ Initial setup
|
|||
|
||||
Then we want to clone the repository. We normally want to have both
|
||||
the current master and (if there is one) the active release branch
|
||||
(eg emacs-29).
|
||||
(eg emacs-28).
|
||||
|
||||
mkdir ~/emacs
|
||||
cd ~/emacs
|
||||
git clone <membername>@git.sv.gnu.org:/srv/git/emacs.git master
|
||||
cd master
|
||||
git config push.default current
|
||||
git worktree add ../emacs-29 emacs-29
|
||||
git worktree add ../emacs-28 emacs-28
|
||||
|
||||
You now have both branches conveniently accessible, and you can do
|
||||
"git pull" in them once in a while to keep updated.
|
||||
|
|
@ -67,7 +67,7 @@ which will look like
|
|||
|
||||
commit 958b768a6534ae6e77a8547a56fc31b46b63710b
|
||||
|
||||
cd ~/emacs/emacs-29
|
||||
cd ~/emacs/emacs-28
|
||||
git cherry-pick -xe 958b768a6534ae6e77a8547a56fc31b46b63710b
|
||||
|
||||
and add "Backport:" to the commit string. Then
|
||||
|
|
@ -109,7 +109,7 @@ up-to-date by doing a pull. Then start Emacs with
|
|||
emacs -l admin/gitmerge.el -f gitmerge
|
||||
|
||||
You'll be asked for the branch to merge, which will default to
|
||||
(eg) 'origin/emacs-29', which you should accept. Merging a local tracking
|
||||
(eg) 'origin/emacs-28', which you should accept. Merging a local tracking
|
||||
branch is discouraged, since it might not be up-to-date, or worse,
|
||||
contain commits from you which are not yet pushed upstream.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
-*- mode: outline; coding: utf-8 -*-
|
||||
|
||||
Copyright (C) 2013-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2013-2022 Free Software Foundation, Inc.
|
||||
See the end of the file for license conditions.
|
||||
|
||||
NOTES FOR EMACS CONTINUOUS BUILD ON HYDRA
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
-*- coding: utf-8; mode: text; -*-
|
||||
|
||||
Copyright (C) 2007-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2022 Free Software Foundation, Inc.
|
||||
See the end of the file for license conditions.
|
||||
|
||||
From README.multi-tty in the multi-tty branch.
|
||||
|
|
|
|||
|
|
@ -129,12 +129,8 @@ This is a semi-automated way to find the revision that introduced a bug.
|
|||
Browse 'git help bisect' for technical instructions.
|
||||
|
||||
It is recommended to start a bisection with the admin/git-bisect-start
|
||||
script. Using that script ensures that commits in branches that are
|
||||
the result of merging external trees into the Emacs repository, as
|
||||
well as certain commits on which Emacs fails to build, are skipped
|
||||
during the bisection process. That script can also be executed
|
||||
automatically when 'git bisect start' is called, with the help of a
|
||||
wrapper script that is included in its commentary section.
|
||||
script. This script prunes the branches that are the result of
|
||||
merging external trees into the Emacs repository.
|
||||
|
||||
* Maintaining ChangeLog history
|
||||
|
||||
|
|
|
|||
17
admin/notes/tree-sitter/build-module/README
Normal file
17
admin/notes/tree-sitter/build-module/README
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
To build the language definition for a particular language, run
|
||||
|
||||
./build.sh <language>
|
||||
|
||||
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.
|
||||
|
|
@ -1,26 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
languages=(
|
||||
'bash'
|
||||
'c'
|
||||
'cmake'
|
||||
'cpp'
|
||||
'css'
|
||||
'c-sharp'
|
||||
'dockerfile'
|
||||
'elixir'
|
||||
'go'
|
||||
'go-mod'
|
||||
'heex'
|
||||
'html'
|
||||
'javascript'
|
||||
'json'
|
||||
'python'
|
||||
'rust'
|
||||
'toml'
|
||||
'tsx'
|
||||
'typescript'
|
||||
'yaml'
|
||||
)
|
||||
|
||||
for language in "${languages[@]}"
|
||||
|
|
|
|||
|
|
@ -1,71 +1,35 @@
|
|||
#!/bin/bash
|
||||
|
||||
lang=$1
|
||||
topdir="$PWD"
|
||||
|
||||
case $(uname) in
|
||||
"Darwin")
|
||||
soext="dylib"
|
||||
;;
|
||||
*"MINGW"*)
|
||||
soext="dll"
|
||||
;;
|
||||
*)
|
||||
soext="so"
|
||||
;;
|
||||
esac
|
||||
if [ $(uname) == "Darwin" ]
|
||||
then
|
||||
soext="dylib"
|
||||
else
|
||||
soext="so"
|
||||
fi
|
||||
|
||||
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"
|
||||
;;
|
||||
"elixir")
|
||||
org="elixir-lang"
|
||||
;;
|
||||
"go-mod")
|
||||
# The parser is called "gomod".
|
||||
lang="gomod"
|
||||
org="camdencheek"
|
||||
;;
|
||||
"heex")
|
||||
org="phoenixframework"
|
||||
;;
|
||||
"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" \
|
||||
# Retrieve sources.
|
||||
git clone "https://github.com/tree-sitter/tree-sitter-${lang}.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}"
|
||||
if [ "${lang}" == "typescript" ]
|
||||
then
|
||||
lang="typescript/tsx"
|
||||
fi
|
||||
cp tree-sitter-lang.in "tree-sitter-${lang}/src"
|
||||
cp emacs-module.h "tree-sitter-${lang}/src"
|
||||
cp "tree-sitter-${lang}/grammar.js" "tree-sitter-${lang}/src"
|
||||
cd "tree-sitter-${lang}/src"
|
||||
|
||||
### Build
|
||||
if [ "${lang}" == "typescript/tsx" ]
|
||||
then
|
||||
lang="tsx"
|
||||
fi
|
||||
|
||||
cc -fPIC -c -I. parser.c
|
||||
# Build.
|
||||
cc -c -I. parser.c
|
||||
# Compile scanner.c.
|
||||
if test -f scanner.c
|
||||
then
|
||||
|
|
@ -84,9 +48,15 @@ else
|
|||
cc -fPIC -shared *.o -o "libtree-sitter-${lang}.${soext}"
|
||||
fi
|
||||
|
||||
### Copy out
|
||||
# Copy out.
|
||||
|
||||
mkdir -p "${topdir}/dist"
|
||||
cp "libtree-sitter-${lang}.${soext}" "${topdir}/dist"
|
||||
cd "${topdir}"
|
||||
rm -rf "${repo}"
|
||||
if [ "${lang}" == "typescript" ]
|
||||
then
|
||||
cp "libtree-sitter-${lang}.${soext}" ..
|
||||
cd ..
|
||||
fi
|
||||
|
||||
mkdir -p ../../dist
|
||||
cp "libtree-sitter-${lang}.${soext}" ../../dist
|
||||
cd ../../
|
||||
rm -rf "tree-sitter-${lang}"
|
||||
|
|
|
|||
206
admin/notes/tree-sitter/html-manual/Accessing-Node.html
Normal file
206
admin/notes/tree-sitter/html-manual/Accessing-Node.html
Normal file
|
|
@ -0,0 +1,206 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<!-- This is the GNU Emacs Lisp Reference Manual
|
||||
corresponding to Emacs version 29.0.50.
|
||||
|
||||
Copyright © 1990-1996, 1998-2022 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with the
|
||||
Invariant Sections being "GNU General Public License," with the
|
||||
Front-Cover Texts being "A GNU Manual," and with the Back-Cover
|
||||
Texts as in (a) below. A copy of the license is included in the
|
||||
section entitled "GNU Free Documentation License."
|
||||
|
||||
(a) The FSF's Back-Cover Text is: "You have the freedom to copy and
|
||||
modify this GNU manual. Buying copies from the FSF supports it in
|
||||
developing GNU and promoting software freedom." -->
|
||||
<title>Accessing Node (GNU Emacs Lisp Reference Manual)</title>
|
||||
|
||||
<meta name="description" content="Accessing Node (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="keywords" content="Accessing Node (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="resource-type" content="document">
|
||||
<meta name="distribution" content="global">
|
||||
<meta name="Generator" content="makeinfo">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
|
||||
<link href="index.html" rel="start" title="Top">
|
||||
<link href="Index.html" rel="index" title="Index">
|
||||
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||||
<link href="Parsing-Program-Source.html" rel="up" title="Parsing Program Source">
|
||||
<link href="Pattern-Matching.html" rel="next" title="Pattern Matching">
|
||||
<link href="Retrieving-Node.html" rel="prev" title="Retrieving Node">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em}
|
||||
a.summary-letter {text-decoration: none}
|
||||
blockquote.indentedblock {margin-right: 0em}
|
||||
div.display {margin-left: 3.2em}
|
||||
div.example {margin-left: 3.2em}
|
||||
kbd {font-style: oblique}
|
||||
pre.display {font-family: inherit}
|
||||
pre.format {font-family: inherit}
|
||||
pre.menu-comment {font-family: serif}
|
||||
pre.menu-preformatted {font-family: serif}
|
||||
span.nolinebreak {white-space: nowrap}
|
||||
span.roman {font-family: initial; font-weight: normal}
|
||||
span.sansserif {font-family: sans-serif; font-weight: normal}
|
||||
span:hover a.copiable-anchor {visibility: visible}
|
||||
ul.no-bullet {list-style: none}
|
||||
-->
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="./manual.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body lang="en">
|
||||
<div class="section" id="Accessing-Node">
|
||||
<div class="header">
|
||||
<p>
|
||||
Next: <a href="Pattern-Matching.html" accesskey="n" rel="next">Pattern Matching Tree-sitter Nodes</a>, Previous: <a href="Retrieving-Node.html" accesskey="p" rel="prev">Retrieving Node</a>, Up: <a href="Parsing-Program-Source.html" accesskey="u" rel="up">Parsing Program Source</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
<hr>
|
||||
<span id="Accessing-Node-Information"></span><h3 class="section">37.4 Accessing Node Information</h3>
|
||||
|
||||
<p>Before going further, make sure you have read the basic conventions
|
||||
about tree-sitter nodes in the previous node.
|
||||
</p>
|
||||
<span id="Basic-information"></span><h3 class="heading">Basic information</h3>
|
||||
|
||||
<p>Every node is associated with a parser, and that parser is associated
|
||||
with a buffer. The following functions let you retrieve them.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002dparser"><span class="category">Function: </span><span><strong>treesit-node-parser</strong> <em>node</em><a href='#index-treesit_002dnode_002dparser' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns <var>node</var>’s associated parser.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002dbuffer"><span class="category">Function: </span><span><strong>treesit-node-buffer</strong> <em>node</em><a href='#index-treesit_002dnode_002dbuffer' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns <var>node</var>’s parser’s associated buffer.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002dlanguage"><span class="category">Function: </span><span><strong>treesit-node-language</strong> <em>node</em><a href='#index-treesit_002dnode_002dlanguage' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns <var>node</var>’s parser’s associated language.
|
||||
</p></dd></dl>
|
||||
|
||||
<p>Each node represents a piece of text in the buffer. Functions below
|
||||
finds relevant information about that text.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002dstart"><span class="category">Function: </span><span><strong>treesit-node-start</strong> <em>node</em><a href='#index-treesit_002dnode_002dstart' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>Return the start position of <var>node</var>.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002dend"><span class="category">Function: </span><span><strong>treesit-node-end</strong> <em>node</em><a href='#index-treesit_002dnode_002dend' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>Return the end position of <var>node</var>.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002dtext"><span class="category">Function: </span><span><strong>treesit-node-text</strong> <em>node &optional object</em><a href='#index-treesit_002dnode_002dtext' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>Returns the buffer text that <var>node</var> represents. (If <var>node</var> is
|
||||
retrieved from parsing a string, it will be text from that string.)
|
||||
</p></dd></dl>
|
||||
|
||||
<p>Here are some basic checks on tree-sitter nodes.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002dp"><span class="category">Function: </span><span><strong>treesit-node-p</strong> <em>object</em><a href='#index-treesit_002dnode_002dp' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>Checks if <var>object</var> is a tree-sitter syntax node.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002deq"><span class="category">Function: </span><span><strong>treesit-node-eq</strong> <em>node1 node2</em><a href='#index-treesit_002dnode_002deq' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>Checks if <var>node1</var> and <var>node2</var> are the same node in a syntax
|
||||
tree.
|
||||
</p></dd></dl>
|
||||
|
||||
<span id="Property-information"></span><h3 class="heading">Property information</h3>
|
||||
|
||||
<p>In general, nodes in a concrete syntax tree fall into two categories:
|
||||
<em>named nodes</em> and <em>anonymous nodes</em>. Whether a node is named
|
||||
or anonymous is determined by the language definition
|
||||
(see <a href="Language-Definitions.html#tree_002dsitter-named-node">named node</a>).
|
||||
</p>
|
||||
<span id="index-tree_002dsitter-missing-node"></span>
|
||||
<p>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.
|
||||
</p>
|
||||
<span id="index-tree_002dsitter-extra-node"></span>
|
||||
<p>A node can be “extra”: extra nodes represent things like comments,
|
||||
which can appear anywhere in the text.
|
||||
</p>
|
||||
<span id="index-tree_002dsitter-node-that-has-changes"></span>
|
||||
<p>A node “has changes” if the buffer changed since when the node is
|
||||
retrieved, i.e., outdated.
|
||||
</p>
|
||||
<span id="index-tree_002dsitter-node-that-has-error"></span>
|
||||
<p>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.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002dcheck"><span class="category">Function: </span><span><strong>treesit-node-check</strong> <em>node property</em><a href='#index-treesit_002dnode_002dcheck' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function checks if <var>node</var> has <var>property</var>. <var>property</var>
|
||||
can be <code>'named</code>, <code>'missing</code>, <code>'extra</code>,
|
||||
<code>'has-changes</code>, or <code>'has-error</code>.
|
||||
</p></dd></dl>
|
||||
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002dtype"><span class="category">Function: </span><span><strong>treesit-node-type</strong> <em>node</em><a href='#index-treesit_002dnode_002dtype' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>Named nodes have “types” (see <a href="Language-Definitions.html#tree_002dsitter-node-type">node type</a>).
|
||||
For example, a named node can be a <code>string_literal</code> node, where
|
||||
<code>string_literal</code> is its type.
|
||||
</p>
|
||||
<p>This function returns <var>node</var>’s type as a string.
|
||||
</p></dd></dl>
|
||||
|
||||
<span id="Information-as-a-child-or-parent"></span><h3 class="heading">Information as a child or parent</h3>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002dindex"><span class="category">Function: </span><span><strong>treesit-node-index</strong> <em>node &optional named</em><a href='#index-treesit_002dnode_002dindex' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns the index of <var>node</var> as a child node of its
|
||||
parent. If <var>named</var> is non-nil, it only count named nodes
|
||||
(see <a href="Language-Definitions.html#tree_002dsitter-named-node">named node</a>).
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002dfield_002dname"><span class="category">Function: </span><span><strong>treesit-node-field-name</strong> <em>node</em><a href='#index-treesit_002dnode_002dfield_002dname' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>A child of a parent node could have a field name (see <a href="Language-Definitions.html#tree_002dsitter-node-field-name">field name</a>). This function returns the field name
|
||||
of <var>node</var> as a child of its parent.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002dfield_002dname_002dfor_002dchild"><span class="category">Function: </span><span><strong>treesit-node-field-name-for-child</strong> <em>node n</em><a href='#index-treesit_002dnode_002dfield_002dname_002dfor_002dchild' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns the field name of the <var>n</var>’th child of
|
||||
<var>node</var>.
|
||||
</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>
|
||||
<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>
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
<div class="header">
|
||||
<p>
|
||||
Next: <a href="Pattern-Matching.html">Pattern Matching Tree-sitter Nodes</a>, Previous: <a href="Retrieving-Node.html">Retrieving Node</a>, Up: <a href="Parsing-Program-Source.html">Parsing Program Source</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
402
admin/notes/tree-sitter/html-manual/Language-Definitions.html
Normal file
402
admin/notes/tree-sitter/html-manual/Language-Definitions.html
Normal file
|
|
@ -0,0 +1,402 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<!-- This is the GNU Emacs Lisp Reference Manual
|
||||
corresponding to Emacs version 29.0.50.
|
||||
|
||||
Copyright © 1990-1996, 1998-2022 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with the
|
||||
Invariant Sections being "GNU General Public License," with the
|
||||
Front-Cover Texts being "A GNU Manual," and with the Back-Cover
|
||||
Texts as in (a) below. A copy of the license is included in the
|
||||
section entitled "GNU Free Documentation License."
|
||||
|
||||
(a) The FSF's Back-Cover Text is: "You have the freedom to copy and
|
||||
modify this GNU manual. Buying copies from the FSF supports it in
|
||||
developing GNU and promoting software freedom." -->
|
||||
<title>Language Definitions (GNU Emacs Lisp Reference Manual)</title>
|
||||
|
||||
<meta name="description" content="Language Definitions (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="keywords" content="Language Definitions (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="resource-type" content="document">
|
||||
<meta name="distribution" content="global">
|
||||
<meta name="Generator" content="makeinfo">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
|
||||
<link href="index.html" rel="start" title="Top">
|
||||
<link href="Index.html" rel="index" title="Index">
|
||||
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||||
<link href="Parsing-Program-Source.html" rel="up" title="Parsing Program Source">
|
||||
<link href="Using-Parser.html" rel="next" title="Using Parser">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em}
|
||||
a.summary-letter {text-decoration: none}
|
||||
blockquote.indentedblock {margin-right: 0em}
|
||||
div.display {margin-left: 3.2em}
|
||||
div.example {margin-left: 3.2em}
|
||||
kbd {font-style: oblique}
|
||||
pre.display {font-family: inherit}
|
||||
pre.format {font-family: inherit}
|
||||
pre.menu-comment {font-family: serif}
|
||||
pre.menu-preformatted {font-family: serif}
|
||||
span.nolinebreak {white-space: nowrap}
|
||||
span.roman {font-family: initial; font-weight: normal}
|
||||
span.sansserif {font-family: sans-serif; font-weight: normal}
|
||||
span:hover a.copiable-anchor {visibility: visible}
|
||||
ul.no-bullet {list-style: none}
|
||||
-->
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="./manual.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body lang="en">
|
||||
<div class="section" id="Language-Definitions">
|
||||
<div class="header">
|
||||
<p>
|
||||
Next: <a href="Using-Parser.html" accesskey="n" rel="next">Using Tree-sitter Parser</a>, Up: <a href="Parsing-Program-Source.html" accesskey="u" rel="up">Parsing Program Source</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
<hr>
|
||||
<span id="Tree_002dsitter-Language-Definitions"></span><h3 class="section">37.1 Tree-sitter Language Definitions</h3>
|
||||
<span id="index-language-definitions_002c-for-tree_002dsitter"></span>
|
||||
|
||||
<span id="Loading-a-language-definition"></span><h3 class="heading">Loading a language definition</h3>
|
||||
<span id="index-loading-language-definition-for-tree_002dsitter"></span>
|
||||
|
||||
<span id="index-language-argument_002c-for-tree_002dsitter"></span>
|
||||
<p>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
|
||||
<code>c</code>, and <code>c</code> can be passed to tree-sitter functions as the
|
||||
<var>language</var> argument.
|
||||
</p>
|
||||
<span id="index-treesit_002dextra_002dload_002dpath"></span>
|
||||
<span id="index-treesit_002dload_002dlanguage_002derror"></span>
|
||||
<span id="index-treesit_002dload_002dsuffixes"></span>
|
||||
<p>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:
|
||||
</p>
|
||||
<ul>
|
||||
<li> first, in the list of directories specified by the variable
|
||||
<code>treesit-extra-load-path</code>;
|
||||
</li><li> then, in the <samp>tree-sitter</samp> subdirectory of the directory
|
||||
specified by <code>user-emacs-directory</code> (see <a href="Init-File.html">The Init File</a>);
|
||||
</li><li> and finally, in the system’s default locations for dynamic libraries.
|
||||
</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>.
|
||||
</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
|
||||
that signal could be one of the following:
|
||||
</p>
|
||||
<dl compact="compact">
|
||||
<dt><span><code>(not-found <var>error-msg</var> …)</code></span></dt>
|
||||
<dd><p>This means that Emacs could not find the language definition library.
|
||||
</p></dd>
|
||||
<dt><span><code>(symbol-error <var>error-msg</var>)</code></span></dt>
|
||||
<dd><p>This means that Emacs could not find in the library the expected function
|
||||
that every language definition library should export.
|
||||
</p></dd>
|
||||
<dt><span><code>(version-mismatch <var>error-msg</var>)</code></span></dt>
|
||||
<dd><p>This means that the version of language definition library is incompatible
|
||||
with that of the tree-sitter library.
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
<p>In all of these cases, <var>error-msg</var> might provide additional
|
||||
details about the failure.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dlanguage_002davailable_002dp"><span class="category">Function: </span><span><strong>treesit-language-available-p</strong> <em>language &optional detail</em><a href='#index-treesit_002dlanguage_002davailable_002dp' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns non-<code>nil</code> if the language definitions for
|
||||
<var>language</var> exist and can be loaded.
|
||||
</p>
|
||||
<p>If <var>detail</var> is non-<code>nil</code>, return <code>(t . nil)</code> when
|
||||
<var>language</var> is available, and <code>(nil . <var>data</var>)</code> when it’s
|
||||
unavailable. <var>data</var> is the signal data of
|
||||
<code>treesit-load-language-error</code>.
|
||||
</p></dd></dl>
|
||||
|
||||
<span id="index-treesit_002dload_002dname_002doverride_002dlist"></span>
|
||||
<p>By convention, the file name of the dynamic library for <var>language</var> is
|
||||
<samp>libtree-sitter-<var>language</var>.<var>ext</var></samp>, where <var>ext</var> is the
|
||||
system-specific extension for dynamic libraries. Also by convention,
|
||||
the function provided by that library is named
|
||||
<code>tree_sitter_<var>language</var></code>. If a language definition library
|
||||
doesn’t follow this convention, you should add an entry
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(<var>language</var> <var>library-base-name</var> <var>function-name</var>)
|
||||
</pre></div>
|
||||
|
||||
<p>to the list in the variable <code>treesit-load-name-override-list</code>, where
|
||||
<var>library-base-name</var> is the basename of the dynamic library’s file name,
|
||||
(usually, <samp>libtree-sitter-<var>language</var></samp>), and
|
||||
<var>function-name</var> is the function provided by the library
|
||||
(usually, <code>tree_sitter_<var>language</var></code>). For example,
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(cool-lang "libtree-sitter-coool" "tree_sitter_cooool")
|
||||
</pre></div>
|
||||
|
||||
<p>for a language that considers itself too “cool” to abide by
|
||||
conventions.
|
||||
</p>
|
||||
<span id="index-language_002ddefinition-version_002c-compatibility"></span>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dlanguage_002dversion"><span class="category">Function: </span><span><strong>treesit-language-version</strong> <em>&optional min-compatible</em><a href='#index-treesit_002dlanguage_002dversion' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns the version of the language-definition
|
||||
Application Binary Interface (<acronym>ABI</acronym>) supported by the
|
||||
tree-sitter library. By default, it returns the latest ABI version
|
||||
supported by the library, but if <var>min-compatible</var> is
|
||||
non-<code>nil</code>, 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.
|
||||
</p></dd></dl>
|
||||
|
||||
<span id="Concrete-syntax-tree"></span><h3 class="heading">Concrete syntax tree</h3>
|
||||
<span id="index-syntax-tree_002c-concrete"></span>
|
||||
|
||||
<p>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
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">1 + 2
|
||||
</pre></div>
|
||||
|
||||
<p>its syntax tree could be
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example"> +--------------+
|
||||
| root "1 + 2" |
|
||||
+--------------+
|
||||
|
|
||||
+--------------------------------+
|
||||
| expression "1 + 2" |
|
||||
+--------------------------------+
|
||||
| | |
|
||||
+------------+ +--------------+ +------------+
|
||||
| number "1" | | operator "+" | | number "2" |
|
||||
+------------+ +--------------+ +------------+
|
||||
</pre></div>
|
||||
|
||||
<p>We can also represent it as an s-expression:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(root (expression (number) (operator) (number)))
|
||||
</pre></div>
|
||||
|
||||
<span id="Node-types"></span><h4 class="subheading">Node types</h4>
|
||||
<span id="index-node-types_002c-in-a-syntax-tree"></span>
|
||||
|
||||
<span id="index-type-of-node_002c-tree_002dsitter"></span>
|
||||
<span id="tree_002dsitter-node-type"></span><span id="index-named-node_002c-tree_002dsitter"></span>
|
||||
<span id="tree_002dsitter-named-node"></span><span id="index-anonymous-node_002c-tree_002dsitter"></span>
|
||||
<p>Names like <code>root</code>, <code>expression</code>, <code>number</code>, and
|
||||
<code>operator</code> specify the <em>type</em> of the nodes. However, not all
|
||||
nodes in a syntax tree have a type. Nodes that don’t have a type are
|
||||
known as <em>anonymous nodes</em>, and nodes with a type are <em>named
|
||||
nodes</em>. Anonymous nodes are tokens with fixed spellings, including
|
||||
punctuation characters like bracket ‘<samp>]</samp>’, and keywords like
|
||||
<code>return</code>.
|
||||
</p>
|
||||
<span id="Field-names"></span><h4 class="subheading">Field names</h4>
|
||||
|
||||
<span id="index-field-name_002c-tree_002dsitter"></span>
|
||||
<span id="index-tree_002dsitter-node-field-name"></span>
|
||||
<span id="tree_002dsitter-node-field-name"></span><p>To make the syntax tree easier to analyze, many language definitions
|
||||
assign <em>field names</em> to child nodes. For example, a
|
||||
<code>function_definition</code> node could have a <code>declarator</code> and a
|
||||
<code>body</code>:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(function_definition
|
||||
declarator: (declaration)
|
||||
body: (compound_statement))
|
||||
</pre></div>
|
||||
|
||||
<span id="Exploring-the-syntax-tree"></span><h3 class="heading">Exploring the syntax tree</h3>
|
||||
<span id="index-explore-tree_002dsitter-syntax-tree"></span>
|
||||
<span id="index-inspection-of-tree_002dsitter-parse-tree-nodes"></span>
|
||||
|
||||
<p>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.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dexplore_002dmode"><span class="category">Command: </span><span><strong>treesit-explore-mode</strong><a href='#index-treesit_002dexplore_002dmode' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>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.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dinspect_002dmode"><span class="category">Command: </span><span><strong>treesit-inspect-mode</strong><a href='#index-treesit_002dinspect_002dmode' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This minor mode displays on the mode-line the node that <em>starts</em>
|
||||
at point. For example, the mode-line can display
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example"><var>parent</var> <var>field</var>: (<var>node</var> (<var>child</var> (…)))
|
||||
</pre></div>
|
||||
|
||||
<p>where <var>node</var>, <var>child</var>, etc., are nodes which begin at point.
|
||||
<var>parent</var> is the parent of <var>node</var>. <var>node</var> is displayed in
|
||||
a bold typeface. <var>field-name</var>s are field names of <var>node</var> and
|
||||
of <var>child</var>, etc.
|
||||
</p>
|
||||
<p>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.
|
||||
</p>
|
||||
<p>This minor mode doesn’t create parsers on its own. It uses the first
|
||||
parser in <code>(treesit-parser-list)</code> (see <a href="Using-Parser.html">Using Tree-sitter Parser</a>).
|
||||
</p></dd></dl>
|
||||
|
||||
<span id="Reading-the-grammar-definition"></span><h3 class="heading">Reading the grammar definition</h3>
|
||||
<span id="index-reading-grammar-definition_002c-tree_002dsitter"></span>
|
||||
|
||||
<p>Authors of language definitions define the <em>grammar</em> 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 <em>grammar file</em>.
|
||||
</p>
|
||||
<p>The grammar file is usually <samp>grammar.js</samp> in a language
|
||||
definition’s project repository. The link to a language definition’s
|
||||
home page can be found on
|
||||
<a href="https://tree-sitter.github.io/tree-sitter">tree-sitter’s
|
||||
homepage</a>.
|
||||
</p>
|
||||
<p>The grammar definition is written in JavaScript. For example, the
|
||||
rule matching a <code>function_definition</code> node looks like
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">function_definition: $ => seq(
|
||||
$.declaration_specifiers,
|
||||
field('declarator', $.declaration),
|
||||
field('body', $.compound_statement)
|
||||
)
|
||||
</pre></div>
|
||||
|
||||
<p>The rules are represented by functions that take a single argument
|
||||
<var>$</var>, representing the whole grammar. The function itself is
|
||||
constructed by other functions: the <code>seq</code> function puts together
|
||||
a sequence of children; the <code>field</code> function annotates a child
|
||||
with a field name. If we write the above definition in the so-called
|
||||
<em>Backus-Naur Form</em> (<acronym>BNF</acronym>) syntax, it would look like
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">function_definition :=
|
||||
<declaration_specifiers> <declaration> <compound_statement>
|
||||
</pre></div>
|
||||
|
||||
<p>and the node returned by the parser would look like
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(function_definition
|
||||
(declaration_specifier)
|
||||
declarator: (declaration)
|
||||
body: (compound_statement))
|
||||
</pre></div>
|
||||
|
||||
<p>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.
|
||||
</p>
|
||||
<dl compact="compact">
|
||||
<dt><span><code>seq(<var>rule1</var>, <var>rule2</var>, …)</code></span></dt>
|
||||
<dd><p>matches each rule one after another.
|
||||
</p></dd>
|
||||
<dt><span><code>choice(<var>rule1</var>, <var>rule2</var>, …)</code></span></dt>
|
||||
<dd><p>matches one of the rules in its arguments.
|
||||
</p></dd>
|
||||
<dt><span><code>repeat(<var>rule</var>)</code></span></dt>
|
||||
<dd><p>matches <var>rule</var> for <em>zero or more</em> times.
|
||||
This is like the ‘<samp>*</samp>’ operator in regular expressions.
|
||||
</p></dd>
|
||||
<dt><span><code>repeat1(<var>rule</var>)</code></span></dt>
|
||||
<dd><p>matches <var>rule</var> for <em>one or more</em> times.
|
||||
This is like the ‘<samp>+</samp>’ operator in regular expressions.
|
||||
</p></dd>
|
||||
<dt><span><code>optional(<var>rule</var>)</code></span></dt>
|
||||
<dd><p>matches <var>rule</var> for <em>zero or one</em> time.
|
||||
This is like the ‘<samp>?</samp>’ operator in regular expressions.
|
||||
</p></dd>
|
||||
<dt><span><code>field(<var>name</var>, <var>rule</var>)</code></span></dt>
|
||||
<dd><p>assigns field name <var>name</var> to the child node matched by <var>rule</var>.
|
||||
</p></dd>
|
||||
<dt><span><code>alias(<var>rule</var>, <var>alias</var>)</code></span></dt>
|
||||
<dd><p>makes nodes matched by <var>rule</var> appear as <var>alias</var> in the syntax
|
||||
tree generated by the parser. For example,
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">alias(preprocessor_call_exp, call_expression)
|
||||
</pre></div>
|
||||
|
||||
<p>makes any node matched by <code>preprocessor_call_exp</code> appear as
|
||||
<code>call_expression</code>.
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
<p>Below are grammar functions of lesser importance for reading a
|
||||
language definition.
|
||||
</p>
|
||||
<dl compact="compact">
|
||||
<dt><span><code>token(<var>rule</var>)</code></span></dt>
|
||||
<dd><p>marks <var>rule</var> 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 <a href="Retrieving-Nodes.html">Retrieving Nodes</a>.
|
||||
</p></dd>
|
||||
<dt><span><code>token.immediate(<var>rule</var>)</code></span></dt>
|
||||
<dd><p>Normally, grammar rules ignore preceding whitespace; this
|
||||
changes <var>rule</var> to match only when there is no preceding
|
||||
whitespaces.
|
||||
</p></dd>
|
||||
<dt><span><code>prec(<var>n</var>, <var>rule</var>)</code></span></dt>
|
||||
<dd><p>gives <var>rule</var> the level-<var>n</var> precedence.
|
||||
</p></dd>
|
||||
<dt><span><code>prec.left([<var>n</var>,] <var>rule</var>)</code></span></dt>
|
||||
<dd><p>marks <var>rule</var> as left-associative, optionally with level <var>n</var>.
|
||||
</p></dd>
|
||||
<dt><span><code>prec.right([<var>n</var>,] <var>rule</var>)</code></span></dt>
|
||||
<dd><p>marks <var>rule</var> as right-associative, optionally with level <var>n</var>.
|
||||
</p></dd>
|
||||
<dt><span><code>prec.dynamic(<var>n</var>, <var>rule</var>)</code></span></dt>
|
||||
<dd><p>this is like <code>prec</code>, but the precedence is applied at runtime
|
||||
instead.
|
||||
</p></dd>
|
||||
</dl>
|
||||
|
||||
<p>The documentation of the tree-sitter project has
|
||||
<a href="https://tree-sitter.github.io/tree-sitter/creating-parsers">more
|
||||
about writing a grammar</a>. Read especially “The Grammar DSL”
|
||||
section.
|
||||
</p>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="header">
|
||||
<p>
|
||||
Next: <a href="Using-Parser.html">Using Tree-sitter Parser</a>, Up: <a href="Parsing-Program-Source.html">Parsing Program Source</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
328
admin/notes/tree-sitter/html-manual/Multiple-Languages.html
Normal file
328
admin/notes/tree-sitter/html-manual/Multiple-Languages.html
Normal file
|
|
@ -0,0 +1,328 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<!-- This is the GNU Emacs Lisp Reference Manual
|
||||
corresponding to Emacs version 29.0.50.
|
||||
|
||||
Copyright © 1990-1996, 1998-2022 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with the
|
||||
Invariant Sections being "GNU General Public License," with the
|
||||
Front-Cover Texts being "A GNU Manual," and with the Back-Cover
|
||||
Texts as in (a) below. A copy of the license is included in the
|
||||
section entitled "GNU Free Documentation License."
|
||||
|
||||
(a) The FSF's Back-Cover Text is: "You have the freedom to copy and
|
||||
modify this GNU manual. Buying copies from the FSF supports it in
|
||||
developing GNU and promoting software freedom." -->
|
||||
<title>Multiple Languages (GNU Emacs Lisp Reference Manual)</title>
|
||||
|
||||
<meta name="description" content="Multiple Languages (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="keywords" content="Multiple Languages (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="resource-type" content="document">
|
||||
<meta name="distribution" content="global">
|
||||
<meta name="Generator" content="makeinfo">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
|
||||
<link href="index.html" rel="start" title="Top">
|
||||
<link href="Index.html" rel="index" title="Index">
|
||||
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||||
<link href="Parsing-Program-Source.html" rel="up" title="Parsing Program Source">
|
||||
<link href="Tree_002dsitter-major-modes.html" rel="next" title="Tree-sitter major modes">
|
||||
<link href="Pattern-Matching.html" rel="prev" title="Pattern Matching">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em}
|
||||
a.summary-letter {text-decoration: none}
|
||||
blockquote.indentedblock {margin-right: 0em}
|
||||
div.display {margin-left: 3.2em}
|
||||
div.example {margin-left: 3.2em}
|
||||
kbd {font-style: oblique}
|
||||
pre.display {font-family: inherit}
|
||||
pre.format {font-family: inherit}
|
||||
pre.menu-comment {font-family: serif}
|
||||
pre.menu-preformatted {font-family: serif}
|
||||
span.nolinebreak {white-space: nowrap}
|
||||
span.roman {font-family: initial; font-weight: normal}
|
||||
span.sansserif {font-family: sans-serif; font-weight: normal}
|
||||
span:hover a.copiable-anchor {visibility: visible}
|
||||
ul.no-bullet {list-style: none}
|
||||
-->
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="./manual.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body lang="en">
|
||||
<div class="section" id="Multiple-Languages">
|
||||
<div class="header">
|
||||
<p>
|
||||
Next: <a href="Tree_002dsitter-major-modes.html" accesskey="n" rel="next">Developing major modes with tree-sitter</a>, Previous: <a href="Pattern-Matching.html" accesskey="p" rel="prev">Pattern Matching Tree-sitter Nodes</a>, Up: <a href="Parsing-Program-Source.html" accesskey="u" rel="up">Parsing Program Source</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
<hr>
|
||||
<span id="Parsing-Text-in-Multiple-Languages"></span><h3 class="section">37.6 Parsing Text in Multiple Languages</h3>
|
||||
<span id="index-multiple-languages_002c-parsing-with-tree_002dsitter"></span>
|
||||
<span id="index-parsing-multiple-languages-with-tree_002dsitter"></span>
|
||||
<p>Sometimes, the source of a programming language could contain snippets
|
||||
of other languages; <acronym>HTML</acronym> + <acronym>CSS</acronym> + 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 <a href="Using-Parser.html#tree_002dsitter-narrowing">narrowing</a>), 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.
|
||||
</p>
|
||||
<p>Lisp programs should call <code>treesit-update-ranges</code> to make sure
|
||||
the ranges for each parser are correct before using parsers in a
|
||||
buffer, and call <code>treesit-language-at</code> 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
|
||||
<code>treesit-range-settings</code> and
|
||||
<code>treesit-language-at-point-function</code>, which do the actual work.
|
||||
These functions and variables are explained in more detail towards the
|
||||
end of the section.
|
||||
</p>
|
||||
<span id="Getting-and-setting-ranges"></span><h3 class="heading">Getting and setting ranges</h3>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dparser_002dset_002dincluded_002dranges"><span class="category">Function: </span><span><strong>treesit-parser-set-included-ranges</strong> <em>parser ranges</em><a href='#index-treesit_002dparser_002dset_002dincluded_002dranges' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function sets up <var>parser</var> to operate on <var>ranges</var>. The
|
||||
<var>parser</var> will only read the text of the specified ranges. Each
|
||||
range in <var>ranges</var> is a list of the form <code>(<var>beg</var> . <var>end</var>)</code><!-- /@w -->.
|
||||
</p>
|
||||
<p>The ranges in <var>ranges</var> must come in order and must not overlap.
|
||||
That is, in pseudo code:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(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)))
|
||||
</pre></div>
|
||||
|
||||
<span id="index-treesit_002drange_002dinvalid"></span>
|
||||
<p>If <var>ranges</var> violates this constraint, or something else went
|
||||
wrong, this function signals the <code>treesit-range-invalid</code> error.
|
||||
The signal data contains a specific error message and the ranges we
|
||||
are trying to set.
|
||||
</p>
|
||||
<p>This function can also be used for disabling ranges. If <var>ranges</var>
|
||||
is <code>nil</code>, the parser is set to parse the whole buffer.
|
||||
</p>
|
||||
<p>Example:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(treesit-parser-set-included-ranges
|
||||
parser '((1 . 9) (16 . 24) (24 . 25)))
|
||||
</pre></div>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dparser_002dincluded_002dranges"><span class="category">Function: </span><span><strong>treesit-parser-included-ranges</strong> <em>parser</em><a href='#index-treesit_002dparser_002dincluded_002dranges' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns the ranges set for <var>parser</var>. The return
|
||||
value is the same as the <var>ranges</var> argument of
|
||||
<code>treesit-parser-included-ranges</code>: a list of cons cells of the form
|
||||
<code>(<var>beg</var> . <var>end</var>)</code><!-- /@w -->. If <var>parser</var> doesn’t have any
|
||||
ranges, the return value is <code>nil</code>.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(treesit-parser-included-ranges parser)
|
||||
⇒ ((1 . 9) (16 . 24) (24 . 25))
|
||||
</pre></div>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dquery_002drange"><span class="category">Function: </span><span><strong>treesit-query-range</strong> <em>source query &optional beg end</em><a href='#index-treesit_002dquery_002drange' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function matches <var>source</var> with <var>query</var> and returns the
|
||||
ranges of captured nodes. The return value is a list of cons cells of
|
||||
the form <code>(<var>beg</var> . <var>end</var>)</code><!-- /@w -->, where <var>beg</var> and
|
||||
<var>end</var> specify the beginning and the end of a region of text.
|
||||
</p>
|
||||
<p>For convenience, <var>source</var> 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.
|
||||
</p>
|
||||
<p>The argument <var>query</var> is the query used to capture nodes
|
||||
(see <a href="Pattern-Matching.html">Pattern Matching Tree-sitter Nodes</a>). The capture names don’t matter. The
|
||||
arguments <var>beg</var> and <var>end</var>, if both non-<code>nil</code>, limit the
|
||||
range in which this function queries.
|
||||
</p>
|
||||
<p>Like other query functions, this function raises the
|
||||
<code>treesit-query-error</code> error if <var>query</var> is malformed.
|
||||
</p></dd></dl>
|
||||
|
||||
<span id="Supporting-multiple-languages-in-Lisp-programs"></span><h3 class="heading">Supporting multiple languages in Lisp programs</h3>
|
||||
|
||||
<p>It should suffice for general Lisp programs to call the following two
|
||||
functions in order to support program sources that mixes multiple
|
||||
languages.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dupdate_002dranges"><span class="category">Function: </span><span><strong>treesit-update-ranges</strong> <em>&optional beg end</em><a href='#index-treesit_002dupdate_002dranges' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function updates ranges for parsers in the buffer. It makes sure
|
||||
the parsers’ ranges are set correctly between <var>beg</var> and <var>end</var>,
|
||||
according to <code>treesit-range-settings</code>. If omitted, <var>beg</var>
|
||||
defaults to the beginning of the buffer, and <var>end</var> defaults to the
|
||||
end of the buffer.
|
||||
</p>
|
||||
<p>For example, fontification functions use this function before querying
|
||||
for nodes in a region.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dlanguage_002dat"><span class="category">Function: </span><span><strong>treesit-language-at</strong> <em>pos</em><a href='#index-treesit_002dlanguage_002dat' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns the language of the text at buffer position
|
||||
<var>pos</var>. Under the hood it calls
|
||||
<code>treesit-language-at-point-function</code> and returns its return
|
||||
value. If <code>treesit-language-at-point-function</code> is <code>nil</code>,
|
||||
this function returns the language of the first parser in the returned
|
||||
value of <code>treesit-parser-list</code>. If there is no parser in the
|
||||
buffer, it returns <code>nil</code>.
|
||||
</p></dd></dl>
|
||||
|
||||
<span id="Supporting-multiple-languages-in-major-modes"></span><h3 class="heading">Supporting multiple languages in major modes</h3>
|
||||
|
||||
<span id="index-host-language_002c-tree_002dsitter"></span>
|
||||
<span id="index-tree_002dsitter-host-and-embedded-languages"></span>
|
||||
<span id="index-embedded-language_002c-tree_002dsitter"></span>
|
||||
<p>Normally, in a set of languages that can be mixed together, there is a
|
||||
<em>host language</em> and one or more <em>embedded languages</em>. 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.
|
||||
</p>
|
||||
<p>Take a buffer containing <acronym>HTML</acronym>, <acronym>CSS</acronym> and JavaScript
|
||||
as an example. A Lisp program will first parse the whole buffer with
|
||||
an <acronym>HTML</acronym> parser, then query the parser for
|
||||
<code>style_element</code> and <code>script_element</code> nodes, which
|
||||
correspond to <acronym>CSS</acronym> and JavaScript text, respectively. Then
|
||||
it sets the range of the <acronym>CSS</acronym> and JavaScript parser to the
|
||||
ranges in which their corresponding nodes span.
|
||||
</p>
|
||||
<p>Given a simple <acronym>HTML</acronym> document:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example"><html>
|
||||
<script>1 + 2</script>
|
||||
<style>body { color: "blue"; }</style>
|
||||
</html>
|
||||
</pre></div>
|
||||
|
||||
<p>a Lisp program will first parse with a <acronym>HTML</acronym> parser, then set
|
||||
ranges for <acronym>CSS</acronym> and JavaScript parsers:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">;; Create parsers.
|
||||
(setq html (treesit-get-parser-create 'html))
|
||||
(setq css (treesit-get-parser-create 'css))
|
||||
(setq js (treesit-get-parser-create 'javascript))
|
||||
</pre><pre class="example">
|
||||
|
||||
</pre><pre class="example">;; Set CSS ranges.
|
||||
(setq css-range
|
||||
(treesit-query-range
|
||||
'html
|
||||
"(style_element (raw_text) @capture)"))
|
||||
(treesit-parser-set-included-ranges css css-range)
|
||||
</pre><pre class="example">
|
||||
|
||||
</pre><pre class="example">;; Set JavaScript ranges.
|
||||
(setq js-range
|
||||
(treesit-query-range
|
||||
'html
|
||||
"(script_element (raw_text) @capture)"))
|
||||
(treesit-parser-set-included-ranges js js-range)
|
||||
</pre></div>
|
||||
|
||||
<p>Emacs automates this process in <code>treesit-update-ranges</code>. A
|
||||
multi-language major mode should set <code>treesit-range-settings</code> so
|
||||
that <code>treesit-update-ranges</code> knows how to perform this process
|
||||
automatically. Major modes should use the helper function
|
||||
<code>treesit-range-rules</code> to generate a value that can be assigned to
|
||||
<code>treesit-range-settings</code>. The settings in the following example
|
||||
directly translate into operations shown above.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(setq-local treesit-range-settings
|
||||
(treesit-range-rules
|
||||
:embed 'javascript
|
||||
:host 'html
|
||||
'((script_element (raw_text) @capture))
|
||||
</pre><pre class="example">
|
||||
|
||||
</pre><pre class="example"> :embed 'css
|
||||
:host 'html
|
||||
'((style_element (raw_text) @capture))))
|
||||
</pre></div>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002drange_002drules"><span class="category">Function: </span><span><strong>treesit-range-rules</strong> <em>&rest query-specs</em><a href='#index-treesit_002drange_002drules' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function is used to set <var>treesit-range-settings</var>. It
|
||||
takes care of compiling queries and other post-processing, and outputs
|
||||
a value that <var>treesit-range-settings</var> can have.
|
||||
</p>
|
||||
<p>It takes a series of <var>query-spec</var>s, where each <var>query-spec</var> is
|
||||
a <var>query</var> preceded by zero or more <var>keyword</var>/<var>value</var>
|
||||
pairs. Each <var>query</var> is a tree-sitter query in either the
|
||||
string, s-expression or compiled form, or a function.
|
||||
</p>
|
||||
<p>If <var>query</var> is a tree-sitter query, it should be preceded by two
|
||||
<var>:keyword</var>/<var>value</var> pairs, where the <code>:embed</code> keyword
|
||||
specifies the embedded language, and the <code>:host</code> keyword
|
||||
specified the host language.
|
||||
</p>
|
||||
<p><code>treesit-update-ranges</code> uses <var>query</var> to figure out how to set
|
||||
the ranges for parsers for the embedded language. It queries
|
||||
<var>query</var> in a host language parser, computes the ranges in which
|
||||
the captured nodes span, and applies these ranges to embedded
|
||||
language parsers.
|
||||
</p>
|
||||
<p>If <var>query</var> is a function, it doesn’t need any <var>:keyword</var> and
|
||||
<var>value</var> pair. It should be a function that takes 2 arguments,
|
||||
<var>start</var> and <var>end</var>, and sets the ranges for parsers in the
|
||||
current buffer in the region between <var>start</var> and <var>end</var>. It is
|
||||
fine for this function to set ranges in a larger region that
|
||||
encompasses the region between <var>start</var> and <var>end</var>.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002drange_002dsettings"><span class="category">Variable: </span><span><strong>treesit-range-settings</strong><a href='#index-treesit_002drange_002dsettings' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This variable helps <code>treesit-update-ranges</code> in updating the
|
||||
ranges for parsers in the buffer. It is a list of <var>setting</var>s
|
||||
where the exact format of a <var>setting</var> is considered internal. You
|
||||
should use <code>treesit-range-rules</code> to generate a value that this
|
||||
variable can have.
|
||||
</p>
|
||||
</dd></dl>
|
||||
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dlanguage_002dat_002dpoint_002dfunction"><span class="category">Variable: </span><span><strong>treesit-language-at-point-function</strong><a href='#index-treesit_002dlanguage_002dat_002dpoint_002dfunction' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This variable’s value should be a function that takes a single
|
||||
argument, <var>pos</var>, which is a buffer position, and returns the
|
||||
language of the buffer text at <var>pos</var>. This variable is used by
|
||||
<code>treesit-language-at</code>.
|
||||
</p></dd></dl>
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
<div class="header">
|
||||
<p>
|
||||
Next: <a href="Tree_002dsitter-major-modes.html">Developing major modes with tree-sitter</a>, Previous: <a href="Pattern-Matching.html">Pattern Matching Tree-sitter Nodes</a>, Up: <a href="Parsing-Program-Source.html">Parsing Program Source</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,248 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<!-- This is the GNU Emacs Lisp Reference Manual
|
||||
corresponding to Emacs version 29.0.50.
|
||||
|
||||
Copyright © 1990-1996, 1998-2022 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with the
|
||||
Invariant Sections being "GNU General Public License," with the
|
||||
Front-Cover Texts being "A GNU Manual," and with the Back-Cover
|
||||
Texts as in (a) below. A copy of the license is included in the
|
||||
section entitled "GNU Free Documentation License."
|
||||
|
||||
(a) The FSF's Back-Cover Text is: "You have the freedom to copy and
|
||||
modify this GNU manual. Buying copies from the FSF supports it in
|
||||
developing GNU and promoting software freedom." -->
|
||||
<title>Parser-based Font Lock (GNU Emacs Lisp Reference Manual)</title>
|
||||
|
||||
<meta name="description" content="Parser-based Font Lock (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="keywords" content="Parser-based Font Lock (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="resource-type" content="document">
|
||||
<meta name="distribution" content="global">
|
||||
<meta name="Generator" content="makeinfo">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
|
||||
<link href="index.html" rel="start" title="Top">
|
||||
<link href="Index.html" rel="index" title="Index">
|
||||
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||||
<link href="Font-Lock-Mode.html" rel="up" title="Font Lock Mode">
|
||||
<link href="Multiline-Font-Lock.html" rel="prev" title="Multiline Font Lock">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em}
|
||||
a.summary-letter {text-decoration: none}
|
||||
blockquote.indentedblock {margin-right: 0em}
|
||||
div.display {margin-left: 3.2em}
|
||||
div.example {margin-left: 3.2em}
|
||||
kbd {font-style: oblique}
|
||||
pre.display {font-family: inherit}
|
||||
pre.format {font-family: inherit}
|
||||
pre.menu-comment {font-family: serif}
|
||||
pre.menu-preformatted {font-family: serif}
|
||||
span.nolinebreak {white-space: nowrap}
|
||||
span.roman {font-family: initial; font-weight: normal}
|
||||
span.sansserif {font-family: sans-serif; font-weight: normal}
|
||||
span:hover a.copiable-anchor {visibility: visible}
|
||||
ul.no-bullet {list-style: none}
|
||||
-->
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="./manual.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body lang="en">
|
||||
<div class="subsection" id="Parser_002dbased-Font-Lock">
|
||||
<div class="header">
|
||||
<p>
|
||||
Previous: <a href="Multiline-Font-Lock.html" accesskey="p" rel="prev">Multiline Font Lock Constructs</a>, Up: <a href="Font-Lock-Mode.html" accesskey="u" rel="up">Font Lock Mode</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
<hr>
|
||||
<span id="Parser_002dbased-Font-Lock-1"></span><h4 class="subsection">24.6.10 Parser-based Font Lock</h4>
|
||||
<span id="index-parser_002dbased-font_002dlock"></span>
|
||||
|
||||
|
||||
<p>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 <a href="Parsing-Program-Source.html">Parsing Program Source</a>) for this purpose.
|
||||
</p>
|
||||
<p>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.
|
||||
</p>
|
||||
<p>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 <var>font-lock-keywords</var> is
|
||||
<var>treesit-font-lock-settings</var>.
|
||||
</p>
|
||||
<span id="index-tree_002dsitter-fontifications_002c-overview"></span>
|
||||
<span id="index-fontifications-with-tree_002dsitter_002c-overview"></span>
|
||||
<p>In general, tree-sitter fontification works as follows:
|
||||
</p>
|
||||
<ul>
|
||||
<li> A Lisp program (usually, part of a major mode) provides a <em>query</em>
|
||||
consisting of <em>patterns</em>, each pattern associated with a
|
||||
<em>capture name</em>.
|
||||
|
||||
</li><li> 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.
|
||||
|
||||
</li><li> 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 <code>font-lock-keyword</code>
|
||||
would be highlighted in <code>font-lock-keyword</code> face.
|
||||
</li></ul>
|
||||
|
||||
<p>For more information about queries, patterns, and capture names, see
|
||||
<a href="Pattern-Matching.html">Pattern Matching Tree-sitter Nodes</a>.
|
||||
</p>
|
||||
<p>To setup tree-sitter fontification, a major mode should first set
|
||||
<code>treesit-font-lock-settings</code> with the output of
|
||||
<code>treesit-font-lock-rules</code>, then call
|
||||
<code>treesit-major-mode-setup</code>.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dfont_002dlock_002drules"><span class="category">Function: </span><span><strong>treesit-font-lock-rules</strong> <em>&rest query-specs</em><a href='#index-treesit_002dfont_002dlock_002drules' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function is used to set <var>treesit-font-lock-settings</var>. It
|
||||
takes care of compiling queries and other post-processing, and outputs
|
||||
a value that <var>treesit-font-lock-settings</var> accepts. Here’s an
|
||||
example:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="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")
|
||||
</pre></div>
|
||||
|
||||
<p>This function takes a series of <var>query-spec</var>s, where each
|
||||
<var>query-spec</var> is a <var>query</var> preceded by one or more
|
||||
<var>:keyword</var>/<var>value</var> pairs. Each <var>query</var> is a
|
||||
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
|
||||
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
|
||||
<code>treesit-font-lock-feature-list</code> (described below). These two
|
||||
keywords are mandatory.
|
||||
</p>
|
||||
<p>Other keywords are optional:
|
||||
</p>
|
||||
<table>
|
||||
<thead><tr><th width="15%">Keyword</th><th width="15%">Value</th><th width="60%">Description</th></tr></thead>
|
||||
<tr><td width="15%"><code>:override</code></td><td width="15%">nil</td><td width="60%">If the region already has a face, discard the new face</td></tr>
|
||||
<tr><td width="15%"></td><td width="15%">t</td><td width="60%">Always apply the new face</td></tr>
|
||||
<tr><td width="15%"></td><td width="15%"><code>append</code></td><td width="60%">Append the new face to existing ones</td></tr>
|
||||
<tr><td width="15%"></td><td width="15%"><code>prepend</code></td><td width="60%">Prepend the new face to existing ones</td></tr>
|
||||
<tr><td width="15%"></td><td width="15%"><code>keep</code></td><td width="60%">Fill-in regions without an existing face</td></tr>
|
||||
</table>
|
||||
|
||||
<p>Lisp programs mark patterns in <var>query</var> with capture names (names
|
||||
that starts with <code>@</code>), and tree-sitter will return matched nodes
|
||||
tagged with those same capture names. For the purpose of
|
||||
fontification, capture names in <var>query</var> should be face names like
|
||||
<code>font-lock-keyword-face</code>. The captured node will be fontified
|
||||
with that face.
|
||||
</p>
|
||||
<span id="index-treesit_002dfontify_002dwith_002doverride"></span>
|
||||
<p>Capture names can also be function names, in which case the function
|
||||
is called with 4 arguments: <var>node</var> and <var>override</var>, <var>start</var>
|
||||
and <var>end</var>, where <var>node</var> is the node itself, <var>override</var> is
|
||||
the override property of the rule which captured this node, and
|
||||
<var>start</var> and <var>end</var> limits the region in which this function
|
||||
should fontify. (If this function wants to respect the <var>override</var>
|
||||
argument, it can use <code>treesit-fontify-with-override</code>.)
|
||||
</p>
|
||||
<p>Beyond the 4 arguments presented, this function should accept more
|
||||
arguments as optional arguments for future extensibility.
|
||||
</p>
|
||||
<p>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.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dfont_002dlock_002dfeature_002dlist"><span class="category">Variable: </span><span><strong>treesit-font-lock-feature-list</strong><a href='#index-treesit_002dfont_002dlock_002dfeature_002dlist' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This is a list of lists of feature symbols. Each element of the list
|
||||
is a list that represents a decoration level.
|
||||
<code>font-lock-maximum-decoration</code> controls which levels are
|
||||
activated.
|
||||
</p>
|
||||
<p>Each element of the list is a list of the form <code>(<var>feature</var> …)</code><!-- /@w -->, where each <var>feature</var> corresponds to the
|
||||
<code>:feature</code> value of a query defined in
|
||||
<code>treesit-font-lock-rules</code>. Removing a feature symbol from this
|
||||
list disables the corresponding query during font-lock.
|
||||
</p>
|
||||
<p>Common feature names, for many programming languages, include
|
||||
<code>definition</code>, <code>type</code>, <code>assignment</code>, <code>builtin</code>,
|
||||
<code>constant</code>, <code>keyword</code>, <code>string-interpolation</code>,
|
||||
<code>comment</code>, <code>doc</code>, <code>string</code>, <code>operator</code>,
|
||||
<code>preprocessor</code>, <code>escape-sequence</code>, and <code>key</code>. Major
|
||||
modes are free to subdivide or extend these common features.
|
||||
</p>
|
||||
<p>Some of these features warrant some explanation: <code>definition</code>
|
||||
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; <code>assignment</code> highlights
|
||||
the whatever is being assigned to, e.g., the variable or field in an
|
||||
assignment statement; <code>key</code> highlights keys in key-value pairs,
|
||||
e.g., keys in a JSON object, or a Python dictionary; <code>doc</code>
|
||||
highlights docstrings or doc-comments.
|
||||
</p>
|
||||
<p>For example, the value of this variable could be:
|
||||
</p><div class="example">
|
||||
<pre class="example">((comment string doc) ; level 1
|
||||
(function-name keyword type builtin constant) ; level 2
|
||||
(variable-name string-interpolation key)) ; level 3
|
||||
</pre></div>
|
||||
|
||||
<p>Major modes should set this variable before calling
|
||||
<code>treesit-major-mode-setup</code>.
|
||||
</p>
|
||||
<span id="index-treesit_002dfont_002dlock_002drecompute_002dfeatures"></span>
|
||||
<p>For this variable to take effect, a Lisp program should call
|
||||
<code>treesit-font-lock-recompute-features</code> (which resets
|
||||
<code>treesit-font-lock-settings</code> accordingly), or
|
||||
<code>treesit-major-mode-setup</code> (which calls
|
||||
<code>treesit-font-lock-recompute-features</code>).
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dfont_002dlock_002dsettings"><span class="category">Variable: </span><span><strong>treesit-font-lock-settings</strong><a href='#index-treesit_002dfont_002dlock_002dsettings' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>A list of settings for tree-sitter based font lock. The exact format
|
||||
of each setting is considered internal. One should always use
|
||||
<code>treesit-font-lock-rules</code> to set this variable.
|
||||
</p>
|
||||
</dd></dl>
|
||||
|
||||
<p>Multi-language major modes should provide range functions in
|
||||
<code>treesit-range-functions</code>, and Emacs will set the ranges
|
||||
accordingly before fontifing a region (see <a href="Multiple-Languages.html">Parsing Text in Multiple Languages</a>).
|
||||
</p>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="header">
|
||||
<p>
|
||||
Previous: <a href="Multiline-Font-Lock.html">Multiline Font Lock Constructs</a>, Up: <a href="Font-Lock-Mode.html">Font Lock Mode</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,281 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<!-- This is the GNU Emacs Lisp Reference Manual
|
||||
corresponding to Emacs version 29.0.50.
|
||||
|
||||
Copyright © 1990-1996, 1998-2022 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with the
|
||||
Invariant Sections being "GNU General Public License," with the
|
||||
Front-Cover Texts being "A GNU Manual," and with the Back-Cover
|
||||
Texts as in (a) below. A copy of the license is included in the
|
||||
section entitled "GNU Free Documentation License."
|
||||
|
||||
(a) The FSF's Back-Cover Text is: "You have the freedom to copy and
|
||||
modify this GNU manual. Buying copies from the FSF supports it in
|
||||
developing GNU and promoting software freedom." -->
|
||||
<title>Parser-based Indentation (GNU Emacs Lisp Reference Manual)</title>
|
||||
|
||||
<meta name="description" content="Parser-based Indentation (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="keywords" content="Parser-based Indentation (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="resource-type" content="document">
|
||||
<meta name="distribution" content="global">
|
||||
<meta name="Generator" content="makeinfo">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
|
||||
<link href="index.html" rel="start" title="Top">
|
||||
<link href="Index.html" rel="index" title="Index">
|
||||
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||||
<link href="Auto_002dIndentation.html" rel="up" title="Auto-Indentation">
|
||||
<link href="SMIE.html" rel="prev" title="SMIE">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em}
|
||||
a.summary-letter {text-decoration: none}
|
||||
blockquote.indentedblock {margin-right: 0em}
|
||||
div.display {margin-left: 3.2em}
|
||||
div.example {margin-left: 3.2em}
|
||||
kbd {font-style: oblique}
|
||||
pre.display {font-family: inherit}
|
||||
pre.format {font-family: inherit}
|
||||
pre.menu-comment {font-family: serif}
|
||||
pre.menu-preformatted {font-family: serif}
|
||||
span.nolinebreak {white-space: nowrap}
|
||||
span.roman {font-family: initial; font-weight: normal}
|
||||
span.sansserif {font-family: sans-serif; font-weight: normal}
|
||||
span:hover a.copiable-anchor {visibility: visible}
|
||||
ul.no-bullet {list-style: none}
|
||||
-->
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="./manual.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body lang="en">
|
||||
<div class="subsection" id="Parser_002dbased-Indentation">
|
||||
<div class="header">
|
||||
<p>
|
||||
Previous: <a href="SMIE.html" accesskey="p" rel="prev">Simple Minded Indentation Engine</a>, Up: <a href="Auto_002dIndentation.html" accesskey="u" rel="up">Automatic Indentation of code</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
<hr>
|
||||
<span id="Parser_002dbased-Indentation-1"></span><h4 class="subsection">24.7.2 Parser-based Indentation</h4>
|
||||
<span id="index-parser_002dbased-indentation"></span>
|
||||
|
||||
|
||||
<p>When built with the tree-sitter library (see <a href="Parsing-Program-Source.html">Parsing Program Source</a>), 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.
|
||||
</p>
|
||||
<p>To enable the parser-based indentation engine, either set
|
||||
<var>treesit-simple-indent-rules</var> and call
|
||||
<code>treesit-major-mode-setup</code>, or equivalently, set the value of
|
||||
<code>indent-line-function</code> to <code>treesit-indent</code>.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dindent_002dfunction"><span class="category">Variable: </span><span><strong>treesit-indent-function</strong><a href='#index-treesit_002dindent_002dfunction' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This variable stores the actual function called by
|
||||
<code>treesit-indent</code>. By default, its value is
|
||||
<code>treesit-simple-indent</code>. In the future we might add other,
|
||||
more complex indentation engines.
|
||||
</p></dd></dl>
|
||||
|
||||
<span id="Writing-indentation-rules"></span><h3 class="heading">Writing indentation rules</h3>
|
||||
<span id="index-indentation-rules_002c-for-parser_002dbased-indentation"></span>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dsimple_002dindent_002drules"><span class="category">Variable: </span><span><strong>treesit-simple-indent-rules</strong><a href='#index-treesit_002dsimple_002dindent_002drules' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This local variable stores indentation rules for every language. It is
|
||||
a list of the form: <code>(<var>language</var> . <var>rules</var>)</code><!-- /@w -->, where
|
||||
<var>language</var> is a language symbol, and <var>rules</var> is a list of the
|
||||
form <code>(<var>matcher</var> <var>anchor</var> <var>offset</var>)</code><!-- /@w -->.
|
||||
</p>
|
||||
<p>First, Emacs passes the smallest tree-sitter node at the beginning of
|
||||
the current line to <var>matcher</var>; if it returns non-<code>nil</code>, this
|
||||
rule is applicable. Then Emacs passes the node to <var>anchor</var>, which
|
||||
returns a buffer position. Emacs takes the column number of that
|
||||
position, adds <var>offset</var> to it, and the result is the indentation
|
||||
column for the current line. <var>offset</var> can be an integer or a
|
||||
variable whose value is an integer.
|
||||
</p>
|
||||
<p>The <var>matcher</var> and <var>anchor</var> are functions, and Emacs provides
|
||||
convenient defaults for them.
|
||||
</p>
|
||||
<p>Each <var>matcher</var> or <var>anchor</var> is a function that takes three
|
||||
arguments: <var>node</var>, <var>parent</var>, and <var>bol</var>. The argument
|
||||
<var>bol</var> is the buffer position whose indentation is required: the
|
||||
position of the first non-whitespace character after the beginning of
|
||||
the line. The argument <var>node</var> is the largest (highest-in-tree)
|
||||
node that starts at that position; and <var>parent</var> is the parent of
|
||||
<var>node</var>. However, when that position is in a whitespace or inside
|
||||
a multi-line string, no node can start at that position, so
|
||||
<var>node</var> is <code>nil</code>. In that case, <var>parent</var> would be the
|
||||
smallest node that spans that position.
|
||||
</p>
|
||||
<p>Emacs finds <var>bol</var>, <var>node</var> and <var>parent</var> and
|
||||
passes them to each <var>matcher</var> and <var>anchor</var>. <var>matcher</var>
|
||||
should return non-<code>nil</code> if the rule is applicable, and
|
||||
<var>anchor</var> should return a buffer position.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dsimple_002dindent_002dpresets"><span class="category">Variable: </span><span><strong>treesit-simple-indent-presets</strong><a href='#index-treesit_002dsimple_002dindent_002dpresets' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This is a list of defaults for <var>matcher</var>s and <var>anchor</var>s in
|
||||
<code>treesit-simple-indent-rules</code>. Each of them represents a function
|
||||
that takes 3 arguments: <var>node</var>, <var>parent</var> and <var>bol</var>. The
|
||||
available default functions are:
|
||||
</p>
|
||||
<dl compact="compact">
|
||||
<dt id='index-no_002dnode'><span><code>no-node</code><a href='#index-no_002dnode' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This matcher is a function that is called with 3 arguments:
|
||||
<var>node</var>, <var>parent</var>, and <var>bol</var>, and returns non-<code>nil</code>,
|
||||
indicating a match, if <var>node</var> is <code>nil</code>, i.e., there is no
|
||||
node that starts at <var>bol</var>. This is the case when <var>bol</var> is on
|
||||
an empty line or inside a multi-line string, etc.
|
||||
</p>
|
||||
</dd>
|
||||
<dt id='index-parent_002dis'><span><code>parent-is</code><a href='#index-parent_002dis' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This matcher is a function of one argument, <var>type</var>; it returns a
|
||||
function that is called with 3 arguments: <var>node</var>, <var>parent</var>,
|
||||
and <var>bol</var>, and returns non-<code>nil</code> (i.e., a match) if
|
||||
<var>parent</var>’s type matches regexp <var>type</var>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt id='index-node_002dis'><span><code>node-is</code><a href='#index-node_002dis' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This matcher is a function of one argument, <var>type</var>; it returns a
|
||||
function that is called with 3 arguments: <var>node</var>, <var>parent</var>,
|
||||
and <var>bol</var>, and returns non-<code>nil</code> if <var>node</var>’s type matches
|
||||
regexp <var>type</var>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt id='index-query'><span><code>query</code><a href='#index-query' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This matcher is a function of one argument, <var>query</var>; it returns a
|
||||
function that is called with 3 arguments: <var>node</var>, <var>parent</var>,
|
||||
and <var>bol</var>, and returns non-<code>nil</code> if querying <var>parent</var>
|
||||
with <var>query</var> captures <var>node</var> (see <a href="Pattern-Matching.html">Pattern Matching Tree-sitter Nodes</a>).
|
||||
</p>
|
||||
</dd>
|
||||
<dt id='index-match'><span><code>match</code><a href='#index-match' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This matcher is a function of 5 arguments: <var>node-type</var>,
|
||||
<var>parent-type</var>, <var>node-field</var>, <var>node-index-min</var>, and
|
||||
<var>node-index-max</var>). It returns a function that is called with 3
|
||||
arguments: <var>node</var>, <var>parent</var>, and <var>bol</var>, and returns
|
||||
non-<code>nil</code> if <var>node</var>’s type matches regexp <var>node-type</var>,
|
||||
<var>parent</var>’s type matches regexp <var>parent-type</var>, <var>node</var>’s
|
||||
field name in <var>parent</var> matches regexp <var>node-field</var>, and
|
||||
<var>node</var>’s index among its siblings is between <var>node-index-min</var>
|
||||
and <var>node-index-max</var>. If the value of an argument is <code>nil</code>,
|
||||
this matcher doesn’t check that argument. For example, to match the
|
||||
first child where parent is <code>argument_list</code>, use
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(match nil "argument_list" nil nil 0 0)
|
||||
</pre></div>
|
||||
|
||||
</dd>
|
||||
<dt id='index-comment_002dend'><span><code>comment-end</code><a href='#index-comment_002dend' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This matcher is a function that is called with 3 arguments:
|
||||
<var>node</var>, <var>parent</var>, and <var>bol</var>, and returns non-<code>nil</code> if
|
||||
point is before a comment ending token. Comment ending tokens are
|
||||
defined by regular expression <code>treesit-comment-end</code>
|
||||
(see <a href="Tree_002dsitter-major-modes.html">treesit-comment-end</a>).
|
||||
</p>
|
||||
</dd>
|
||||
<dt id='index-first_002dsibling'><span><code>first-sibling</code><a href='#index-first_002dsibling' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This anchor is a function that is called with 3 arguments: <var>node</var>,
|
||||
<var>parent</var>, and <var>bol</var>, and returns the start of the first child
|
||||
of <var>parent</var>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt id='index-parent'><span><code>parent</code><a href='#index-parent' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This anchor is a function that is called with 3 arguments: <var>node</var>,
|
||||
<var>parent</var>, and <var>bol</var>, and returns the start of <var>parent</var>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt id='index-parent_002dbol'><span><code>parent-bol</code><a href='#index-parent_002dbol' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This anchor is a function that is called with 3 arguments: <var>node</var>,
|
||||
<var>parent</var>, and <var>bol</var>, and returns the first non-space character
|
||||
on the line of <var>parent</var>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt id='index-prev_002dsibling'><span><code>prev-sibling</code><a href='#index-prev_002dsibling' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This anchor is a function that is called with 3 arguments: <var>node</var>,
|
||||
<var>parent</var>, and <var>bol</var>, and returns the start of the previous
|
||||
sibling of <var>node</var>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt id='index-no_002dindent'><span><code>no-indent</code><a href='#index-no_002dindent' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This anchor is a function that is called with 3 arguments: <var>node</var>,
|
||||
<var>parent</var>, and <var>bol</var>, and returns the start of <var>node</var>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt id='index-prev_002dline'><span><code>prev-line</code><a href='#index-prev_002dline' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This anchor is a function that is called with 3 arguments: <var>node</var>,
|
||||
<var>parent</var>, and <var>bol</var>, and returns the first non-whitespace
|
||||
character on the previous line.
|
||||
</p>
|
||||
</dd>
|
||||
<dt id='index-point_002dmin'><span><code>point-min</code><a href='#index-point_002dmin' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This anchor is a function that is called with 3 arguments: <var>node</var>,
|
||||
<var>parent</var>, and <var>bol</var>, and returns the beginning of the buffer.
|
||||
This is useful as the beginning of the buffer is always at column 0.
|
||||
</p>
|
||||
</dd>
|
||||
<dt id='index-comment_002dstart'><span><code>comment-start</code><a href='#index-comment_002dstart' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This anchor is a function that is called with 3 arguments: <var>node</var>,
|
||||
<var>parent</var>, and <var>bol</var>, and returns the position right after the
|
||||
comment-start token. Comment-start tokens are defined by regular
|
||||
expression <code>treesit-comment-start</code> (see <a href="Tree_002dsitter-major-modes.html">treesit-comment-start</a>). This function assumes <var>parent</var> is
|
||||
the comment node.
|
||||
</p>
|
||||
</dd>
|
||||
<dt id='index-coment_002dstart_002dskip'><span><code>coment-start-skip</code><a href='#index-coment_002dstart_002dskip' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This anchor is a function that is called with 3 arguments: <var>node</var>,
|
||||
<var>parent</var>, and <var>bol</var>, and returns the position after the
|
||||
comment-start token and any whitespace characters following that
|
||||
token. Comment-start tokens are defined by regular expression
|
||||
<code>treesit-comment-start</code>. This function assumes <var>parent</var> is
|
||||
the comment node.
|
||||
</p></dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<span id="Indentation-utilities"></span><h3 class="heading">Indentation utilities</h3>
|
||||
<span id="index-utility-functions-for-parser_002dbased-indentation"></span>
|
||||
|
||||
<p>Here are some utility functions that can help writing parser-based
|
||||
indentation rules.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dcheck_002dindent"><span class="category">Function: </span><span><strong>treesit-check-indent</strong> <em>mode</em><a href='#index-treesit_002dcheck_002dindent' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function checks the current buffer’s indentation against major
|
||||
mode <var>mode</var>. It indents the current buffer according to
|
||||
<var>mode</var> 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. </p></dd></dl>
|
||||
|
||||
<p>It is also helpful to use <code>treesit-inspect-mode</code> (see <a href="Language-Definitions.html">Tree-sitter Language Definitions</a>) when writing indentation rules.
|
||||
</p>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="header">
|
||||
<p>
|
||||
Previous: <a href="SMIE.html">Simple Minded Indentation Engine</a>, Up: <a href="Auto_002dIndentation.html">Automatic Indentation of code</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
126
admin/notes/tree-sitter/html-manual/Parsing-Program-Source.html
Normal file
126
admin/notes/tree-sitter/html-manual/Parsing-Program-Source.html
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<!-- This is the GNU Emacs Lisp Reference Manual
|
||||
corresponding to Emacs version 29.0.50.
|
||||
|
||||
Copyright © 1990-1996, 1998-2022 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with the
|
||||
Invariant Sections being "GNU General Public License," with the
|
||||
Front-Cover Texts being "A GNU Manual," and with the Back-Cover
|
||||
Texts as in (a) below. A copy of the license is included in the
|
||||
section entitled "GNU Free Documentation License."
|
||||
|
||||
(a) The FSF's Back-Cover Text is: "You have the freedom to copy and
|
||||
modify this GNU manual. Buying copies from the FSF supports it in
|
||||
developing GNU and promoting software freedom." -->
|
||||
<title>Parsing Program Source (GNU Emacs Lisp Reference Manual)</title>
|
||||
|
||||
<meta name="description" content="Parsing Program Source (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="keywords" content="Parsing Program Source (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="resource-type" content="document">
|
||||
<meta name="distribution" content="global">
|
||||
<meta name="Generator" content="makeinfo">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
|
||||
<link href="index.html" rel="start" title="Top">
|
||||
<link href="Index.html" rel="index" title="Index">
|
||||
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||||
<link href="index.html" rel="up" title="Top">
|
||||
<link href="Abbrevs.html" rel="next" title="Abbrevs">
|
||||
<link href="Syntax-Tables.html" rel="prev" title="Syntax Tables">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em}
|
||||
a.summary-letter {text-decoration: none}
|
||||
blockquote.indentedblock {margin-right: 0em}
|
||||
div.display {margin-left: 3.2em}
|
||||
div.example {margin-left: 3.2em}
|
||||
kbd {font-style: oblique}
|
||||
pre.display {font-family: inherit}
|
||||
pre.format {font-family: inherit}
|
||||
pre.menu-comment {font-family: serif}
|
||||
pre.menu-preformatted {font-family: serif}
|
||||
span.nolinebreak {white-space: nowrap}
|
||||
span.roman {font-family: initial; font-weight: normal}
|
||||
span.sansserif {font-family: sans-serif; font-weight: normal}
|
||||
span:hover a.copiable-anchor {visibility: visible}
|
||||
ul.no-bullet {list-style: none}
|
||||
-->
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="./manual.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body lang="en">
|
||||
<div class="chapter" id="Parsing-Program-Source">
|
||||
<div class="header">
|
||||
<p>
|
||||
Next: <a href="Abbrevs.html" accesskey="n" rel="next">Abbrevs and Abbrev Expansion</a>, Previous: <a href="Syntax-Tables.html" accesskey="p" rel="prev">Syntax Tables</a>, Up: <a href="index.html" accesskey="u" rel="up">Emacs Lisp</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
<hr>
|
||||
<span id="Parsing-Program-Source-1"></span><h2 class="chapter">37 Parsing Program Source</h2>
|
||||
|
||||
<span id="index-syntax-tree_002c-from-parsing-program-source"></span>
|
||||
<p>Emacs provides various ways to parse program source text and produce a
|
||||
<em>syntax tree</em>. 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.
|
||||
</p>
|
||||
<p>Emacs has a simple facility for parsing balanced expressions
|
||||
(see <a href="Parsing-Expressions.html">Parsing Expressions</a>). There is also the SMIE library for
|
||||
generic navigation and indentation (see <a href="SMIE.html">Simple Minded Indentation Engine</a>).
|
||||
</p>
|
||||
<p>In addition to those, Emacs also provides integration with
|
||||
<a href="https://tree-sitter.github.io/tree-sitter">the tree-sitter
|
||||
library</a>) 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.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002davailable_002dp"><span class="category">Function: </span><span><strong>treesit-available-p</strong><a href='#index-treesit_002davailable_002dp' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns non-<code>nil</code> if tree-sitter features are
|
||||
available for the current Emacs session.
|
||||
</p></dd></dl>
|
||||
|
||||
<p>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.
|
||||
</p>
|
||||
|
||||
<ul class="section-toc">
|
||||
<li><a href="Language-Definitions.html" accesskey="1">Tree-sitter Language Definitions</a></li>
|
||||
<li><a href="Using-Parser.html" accesskey="2">Using Tree-sitter Parser</a></li>
|
||||
<li><a href="Retrieving-Nodes.html" accesskey="3">Retrieving Nodes</a></li>
|
||||
<li><a href="Accessing-Node-Information.html" accesskey="4">Accessing Node Information</a></li>
|
||||
<li><a href="Pattern-Matching.html" accesskey="5">Pattern Matching Tree-sitter Nodes</a></li>
|
||||
<li><a href="Multiple-Languages.html" accesskey="6">Parsing Text in Multiple Languages</a></li>
|
||||
<li><a href="Tree_002dsitter-major-modes.html" accesskey="7">Developing major modes with tree-sitter</a></li>
|
||||
<li><a href="Tree_002dsitter-C-API.html" accesskey="8">Tree-sitter C API Correspondence</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="header">
|
||||
<p>
|
||||
Next: <a href="Abbrevs.html">Abbrevs and Abbrev Expansion</a>, Previous: <a href="Syntax-Tables.html">Syntax Tables</a>, Up: <a href="index.html">Emacs Lisp</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
451
admin/notes/tree-sitter/html-manual/Pattern-Matching.html
Normal file
451
admin/notes/tree-sitter/html-manual/Pattern-Matching.html
Normal file
|
|
@ -0,0 +1,451 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<!-- This is the GNU Emacs Lisp Reference Manual
|
||||
corresponding to Emacs version 29.0.50.
|
||||
|
||||
Copyright © 1990-1996, 1998-2022 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with the
|
||||
Invariant Sections being "GNU General Public License," with the
|
||||
Front-Cover Texts being "A GNU Manual," and with the Back-Cover
|
||||
Texts as in (a) below. A copy of the license is included in the
|
||||
section entitled "GNU Free Documentation License."
|
||||
|
||||
(a) The FSF's Back-Cover Text is: "You have the freedom to copy and
|
||||
modify this GNU manual. Buying copies from the FSF supports it in
|
||||
developing GNU and promoting software freedom." -->
|
||||
<title>Pattern Matching (GNU Emacs Lisp Reference Manual)</title>
|
||||
|
||||
<meta name="description" content="Pattern Matching (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="keywords" content="Pattern Matching (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="resource-type" content="document">
|
||||
<meta name="distribution" content="global">
|
||||
<meta name="Generator" content="makeinfo">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
|
||||
<link href="index.html" rel="start" title="Top">
|
||||
<link href="Index.html" rel="index" title="Index">
|
||||
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||||
<link href="Parsing-Program-Source.html" rel="up" title="Parsing Program Source">
|
||||
<link href="Multiple-Languages.html" rel="next" title="Multiple Languages">
|
||||
<link href="Accessing-Node-Information.html" rel="prev" title="Accessing Node Information">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em}
|
||||
a.summary-letter {text-decoration: none}
|
||||
blockquote.indentedblock {margin-right: 0em}
|
||||
div.display {margin-left: 3.2em}
|
||||
div.example {margin-left: 3.2em}
|
||||
kbd {font-style: oblique}
|
||||
pre.display {font-family: inherit}
|
||||
pre.format {font-family: inherit}
|
||||
pre.menu-comment {font-family: serif}
|
||||
pre.menu-preformatted {font-family: serif}
|
||||
span.nolinebreak {white-space: nowrap}
|
||||
span.roman {font-family: initial; font-weight: normal}
|
||||
span.sansserif {font-family: sans-serif; font-weight: normal}
|
||||
span:hover a.copiable-anchor {visibility: visible}
|
||||
ul.no-bullet {list-style: none}
|
||||
-->
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="./manual.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body lang="en">
|
||||
<div class="section" id="Pattern-Matching">
|
||||
<div class="header">
|
||||
<p>
|
||||
Next: <a href="Multiple-Languages.html" accesskey="n" rel="next">Parsing Text in Multiple Languages</a>, Previous: <a href="Accessing-Node-Information.html" accesskey="p" rel="prev">Accessing Node Information</a>, Up: <a href="Parsing-Program-Source.html" accesskey="u" rel="up">Parsing Program Source</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
<hr>
|
||||
<span id="Pattern-Matching-Tree_002dsitter-Nodes"></span><h3 class="section">37.5 Pattern Matching Tree-sitter Nodes</h3>
|
||||
<span id="index-pattern-matching-with-tree_002dsitter-nodes"></span>
|
||||
|
||||
<span id="index-capturing_002c-tree_002dsitter-node"></span>
|
||||
<p>Tree-sitter lets Lisp programs match patterns using a small
|
||||
declarative language. This pattern matching consists of two steps:
|
||||
first tree-sitter matches a <em>pattern</em> against nodes in the syntax
|
||||
tree, then it <em>captures</em> specific nodes that matched the pattern
|
||||
and returns the captured nodes.
|
||||
</p>
|
||||
<p>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.
|
||||
</p>
|
||||
<span id="Basic-query-syntax"></span><h3 class="heading">Basic query syntax</h3>
|
||||
|
||||
<span id="index-tree_002dsitter-query-pattern-syntax"></span>
|
||||
<span id="index-pattern-syntax_002c-tree_002dsitter-query"></span>
|
||||
<span id="index-query_002c-tree_002dsitter"></span>
|
||||
<p>A <em>query</em> consists of multiple <em>patterns</em>. Each pattern is an
|
||||
s-expression that matches a certain node in the syntax node. A
|
||||
pattern has the form <code>(<var>type</var> (<var>child</var>…))</code><!-- /@w -->
|
||||
</p>
|
||||
<p>For example, a pattern that matches a <code>binary_expression</code> node that
|
||||
contains <code>number_literal</code> child nodes would look like
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(binary_expression (number_literal))
|
||||
</pre></div>
|
||||
|
||||
<p>To <em>capture</em> a node using the query pattern above, append
|
||||
<code>@<var>capture-name</var></code> after the node pattern you want to
|
||||
capture. For example,
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(binary_expression (number_literal) @number-in-exp)
|
||||
</pre></div>
|
||||
|
||||
<p>captures <code>number_literal</code> nodes that are inside a
|
||||
<code>binary_expression</code> node with the capture name
|
||||
<code>number-in-exp</code>.
|
||||
</p>
|
||||
<p>We can capture the <code>binary_expression</code> node as well, with, for
|
||||
example, the capture name <code>biexp</code>:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(binary_expression
|
||||
(number_literal) @number-in-exp) @biexp
|
||||
</pre></div>
|
||||
|
||||
<span id="Query-function"></span><h3 class="heading">Query function</h3>
|
||||
|
||||
<span id="index-query-functions_002c-tree_002dsitter"></span>
|
||||
<p>Now we can introduce the <em>query functions</em>.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dquery_002dcapture"><span class="category">Function: </span><span><strong>treesit-query-capture</strong> <em>node query &optional beg end node-only</em><a href='#index-treesit_002dquery_002dcapture' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function matches patterns in <var>query</var> within <var>node</var>.
|
||||
The argument <var>query</var> 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.
|
||||
</p>
|
||||
<p>The argument <var>node</var> 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.
|
||||
</p>
|
||||
<p>The function returns all the captured nodes in a list of the form
|
||||
<code>(<var><span class="nolinebreak">capture_name</span></var> . <var>node</var>)</code><!-- /@w -->. If <var>node-only</var> is
|
||||
non-<code>nil</code>, it returns the list of nodes instead. By default the
|
||||
entire text of <var>node</var> is searched, but if <var>beg</var> and <var>end</var>
|
||||
are both non-<code>nil</code>, they specify the region of buffer text where
|
||||
this function should match nodes. Any matching node whose span
|
||||
overlaps with the region between <var>beg</var> and <var>end</var> are captured,
|
||||
it doesn’t have to be completely in the region.
|
||||
</p>
|
||||
<span id="index-treesit_002dquery_002derror"></span>
|
||||
<span id="index-treesit_002dquery_002dvalidate"></span>
|
||||
<p>This function raises the <code>treesit-query-error</code> error if
|
||||
<var>query</var> is malformed. The signal data contains a description of
|
||||
the specific error. You can use <code>treesit-query-validate</code> to
|
||||
validate and debug the query.
|
||||
</p></dd></dl>
|
||||
|
||||
<p>For example, suppose <var>node</var>’s text is <code>1 + 2</code>, and
|
||||
<var>query</var> is
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(setq query
|
||||
"(binary_expression
|
||||
(number_literal) @number-in-exp) @biexp")
|
||||
</pre></div>
|
||||
|
||||
<p>Matching that query would return
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(treesit-query-capture node query)
|
||||
⇒ ((biexp . <var><node for "1 + 2"></var>)
|
||||
(number-in-exp . <var><node for "1"></var>)
|
||||
(number-in-exp . <var><node for "2"></var>))
|
||||
</pre></div>
|
||||
|
||||
<p>As mentioned earlier, <var>query</var> could contain multiple patterns.
|
||||
For example, it could have two top-level patterns:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(setq query
|
||||
"(binary_expression) @biexp
|
||||
(number_literal) @number @biexp")
|
||||
</pre></div>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dquery_002dstring"><span class="category">Function: </span><span><strong>treesit-query-string</strong> <em>string query language</em><a href='#index-treesit_002dquery_002dstring' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function parses <var>string</var> with <var>language</var>, matches its
|
||||
root node with <var>query</var>, and returns the result.
|
||||
</p></dd></dl>
|
||||
|
||||
<span id="More-query-syntax"></span><h3 class="heading">More query syntax</h3>
|
||||
|
||||
<p>Besides node type and capture, tree-sitter’s pattern syntax can
|
||||
express anonymous node, field name, wildcard, quantification,
|
||||
grouping, alternation, anchor, and predicate.
|
||||
</p>
|
||||
<span id="Anonymous-node"></span><h4 class="subheading">Anonymous node</h4>
|
||||
|
||||
<p>An anonymous node is written verbatim, surrounded by quotes. A
|
||||
pattern matching (and capturing) keyword <code>return</code> would be
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">"return" @keyword
|
||||
</pre></div>
|
||||
|
||||
<span id="Wild-card"></span><h4 class="subheading">Wild card</h4>
|
||||
|
||||
<p>In a pattern, ‘<samp>(_)</samp>’ matches any named node, and ‘<samp>_</samp>’ matches
|
||||
any named and anonymous node. For example, to capture any named child
|
||||
of a <code>binary_expression</code> node, the pattern would be
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(binary_expression (_) @in_biexp)
|
||||
</pre></div>
|
||||
|
||||
<span id="Field-name"></span><h4 class="subheading">Field name</h4>
|
||||
|
||||
<p>It is possible to capture child nodes that have specific field names.
|
||||
In the pattern below, <code>declarator</code> and <code>body</code> are field
|
||||
names, indicated by the colon following them.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(function_definition
|
||||
declarator: (_) @func-declarator
|
||||
body: (_) @func-body)
|
||||
</pre></div>
|
||||
|
||||
<p>It is also possible to capture a node that doesn’t have a certain
|
||||
field, say, a <code>function_definition</code> without a <code>body</code> field.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(function_definition !body) @func-no-body
|
||||
</pre></div>
|
||||
|
||||
<span id="Quantify-node"></span><h4 class="subheading">Quantify node</h4>
|
||||
|
||||
<span id="index-quantify-node_002c-tree_002dsitter"></span>
|
||||
<p>Tree-sitter recognizes quantification operators ‘<samp>*</samp>’, ‘<samp>+</samp>’ and
|
||||
‘<samp>?</samp>’. Their meanings are the same as in regular expressions:
|
||||
‘<samp>*</samp>’ matches the preceding pattern zero or more times, ‘<samp>+</samp>’
|
||||
matches one or more times, and ‘<samp>?</samp>’ matches zero or one time.
|
||||
</p>
|
||||
<p>For example, the following pattern matches <code>type_declaration</code>
|
||||
nodes that has <em>zero or more</em> <code>long</code> keyword.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(type_declaration "long"*) @long-type
|
||||
</pre></div>
|
||||
|
||||
<p>The following pattern matches a type declaration that has zero or one
|
||||
<code>long</code> keyword:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(type_declaration "long"?) @long-type
|
||||
</pre></div>
|
||||
|
||||
<span id="Grouping"></span><h4 class="subheading">Grouping</h4>
|
||||
|
||||
<p>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
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(identifier) ("," (identifier))*
|
||||
</pre></div>
|
||||
|
||||
<span id="Alternation"></span><h4 class="subheading">Alternation</h4>
|
||||
|
||||
<p>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
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">[
|
||||
"return"
|
||||
"break"
|
||||
"if"
|
||||
"else"
|
||||
] @keyword
|
||||
</pre></div>
|
||||
|
||||
<span id="Anchor"></span><h4 class="subheading">Anchor</h4>
|
||||
|
||||
<p>The anchor operator ‘<samp>.</samp>’ 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:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">;; Anchor the child with the end of its parent.
|
||||
(compound_expression (_) @last-child .)
|
||||
</pre><pre class="example">
|
||||
|
||||
</pre><pre class="example">;; Anchor the child with the beginning of its parent.
|
||||
(compound_expression . (_) @first-child)
|
||||
</pre><pre class="example">
|
||||
|
||||
</pre><pre class="example">;; Anchor two adjacent children.
|
||||
(compound_expression
|
||||
(_) @prev-child
|
||||
.
|
||||
(_) @next-child)
|
||||
</pre></div>
|
||||
|
||||
<p>Note that the enforcement of juxtaposition ignores any anonymous
|
||||
nodes.
|
||||
</p>
|
||||
<span id="Predicate"></span><h4 class="subheading">Predicate</h4>
|
||||
|
||||
<p>It is possible to add predicate constraints to a pattern. For
|
||||
example, with the following pattern:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(
|
||||
(array . (_) @first (_) @last .)
|
||||
(#equal @first @last)
|
||||
)
|
||||
</pre></div>
|
||||
|
||||
<p>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 ‘<samp>#</samp>’.
|
||||
Currently there are two predicates, <code>#equal</code> and <code>#match</code>.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-equal-1"><span class="category">Predicate: </span><span><strong>equal</strong> <em>arg1 arg2</em><a href='#index-equal-1' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>Matches if <var>arg1</var> equals to <var>arg2</var>. Arguments can be either
|
||||
strings or capture names. Capture names represent the text that the
|
||||
captured node spans in the buffer.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-match-1"><span class="category">Predicate: </span><span><strong>match</strong> <em>regexp capture-name</em><a href='#index-match-1' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>Matches if the text that <var>capture-name</var>’s node spans in the buffer
|
||||
matches regular expression <var>regexp</var>. Matching is case-sensitive.
|
||||
</p></dd></dl>
|
||||
|
||||
<p>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.
|
||||
</p>
|
||||
<span id="S_002dexpression-patterns"></span><h3 class="heading">S-expression patterns</h3>
|
||||
|
||||
<span id="index-tree_002dsitter-patterns-as-sexps"></span>
|
||||
<span id="index-patterns_002c-tree_002dsitter_002c-in-sexp-form"></span>
|
||||
<p>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
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(treesit-query-capture
|
||||
node "(addition_expression
|
||||
left: (_) @left
|
||||
\"+\" @plus-sign
|
||||
right: (_) @right) @addition
|
||||
|
||||
[\"return\" \"break\"] @keyword")
|
||||
</pre></div>
|
||||
|
||||
<p>is equivalent to
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">(treesit-query-capture
|
||||
node '((addition_expression
|
||||
left: (_) @left
|
||||
"+" @plus-sign
|
||||
right: (_) @right) @addition
|
||||
|
||||
["return" "break"] @keyword))
|
||||
</pre></div>
|
||||
|
||||
<p>Most patterns can be written directly as strange but nevertheless
|
||||
valid s-expressions. Only a few of them needs modification:
|
||||
</p>
|
||||
<ul>
|
||||
<li> Anchor ‘<samp>.</samp>’ is written as <code>:anchor</code>.
|
||||
</li><li> ‘<samp>?</samp>’ is written as ‘<samp>:?</samp>’.
|
||||
</li><li> ‘<samp>*</samp>’ is written as ‘<samp>:*</samp>’.
|
||||
</li><li> ‘<samp>+</samp>’ is written as ‘<samp>:+</samp>’.
|
||||
</li><li> <code>#equal</code> is written as <code>:equal</code>. In general, predicates
|
||||
change their ‘<samp>#</samp>’ to ‘<samp>:</samp>’.
|
||||
</li></ul>
|
||||
|
||||
<p>For example,
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">"(
|
||||
(compound_expression . (_) @first (_)* @rest)
|
||||
(#match \"love\" @first)
|
||||
)"
|
||||
</pre></div>
|
||||
|
||||
<p>is written in s-expression as
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">'((
|
||||
(compound_expression :anchor (_) @first (_) :* @rest)
|
||||
(:match "love" @first)
|
||||
))
|
||||
</pre></div>
|
||||
|
||||
<span id="Compiling-queries"></span><h3 class="heading">Compiling queries</h3>
|
||||
|
||||
<span id="index-compiling-tree_002dsitter-queries"></span>
|
||||
<span id="index-queries_002c-compiling"></span>
|
||||
<p>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.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dquery_002dcompile"><span class="category">Function: </span><span><strong>treesit-query-compile</strong> <em>language query</em><a href='#index-treesit_002dquery_002dcompile' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function compiles <var>query</var> for <var>language</var> into a compiled
|
||||
query object and returns it.
|
||||
</p>
|
||||
<p>This function raises the <code>treesit-query-error</code> error if
|
||||
<var>query</var> is malformed. The signal data contains a description of
|
||||
the specific error. You can use <code>treesit-query-validate</code> to
|
||||
validate and debug the query.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dquery_002dlanguage"><span class="category">Function: </span><span><strong>treesit-query-language</strong> <em>query</em><a href='#index-treesit_002dquery_002dlanguage' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function return the language of <var>query</var>.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dquery_002dexpand"><span class="category">Function: </span><span><strong>treesit-query-expand</strong> <em>query</em><a href='#index-treesit_002dquery_002dexpand' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function converts the s-expression <var>query</var> into the string
|
||||
format.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dpattern_002dexpand"><span class="category">Function: </span><span><strong>treesit-pattern-expand</strong> <em>pattern</em><a href='#index-treesit_002dpattern_002dexpand' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function converts the s-expression <var>pattern</var> into the string
|
||||
format.
|
||||
</p></dd></dl>
|
||||
|
||||
<p>For more details, read the tree-sitter project’s documentation about
|
||||
pattern-matching, which can be found at
|
||||
<a href="https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries">https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries</a>.
|
||||
</p>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="header">
|
||||
<p>
|
||||
Next: <a href="Multiple-Languages.html">Parsing Text in Multiple Languages</a>, Previous: <a href="Accessing-Node-Information.html">Accessing Node Information</a>, Up: <a href="Parsing-Program-Source.html">Parsing Program Source</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
421
admin/notes/tree-sitter/html-manual/Retrieving-Node.html
Normal file
421
admin/notes/tree-sitter/html-manual/Retrieving-Node.html
Normal file
|
|
@ -0,0 +1,421 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<!-- This is the GNU Emacs Lisp Reference Manual
|
||||
corresponding to Emacs version 29.0.50.
|
||||
|
||||
Copyright © 1990-1996, 1998-2022 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with the
|
||||
Invariant Sections being "GNU General Public License," with the
|
||||
Front-Cover Texts being "A GNU Manual," and with the Back-Cover
|
||||
Texts as in (a) below. A copy of the license is included in the
|
||||
section entitled "GNU Free Documentation License."
|
||||
|
||||
(a) The FSF's Back-Cover Text is: "You have the freedom to copy and
|
||||
modify this GNU manual. Buying copies from the FSF supports it in
|
||||
developing GNU and promoting software freedom." -->
|
||||
<title>Retrieving Node (GNU Emacs Lisp Reference Manual)</title>
|
||||
|
||||
<meta name="description" content="Retrieving Node (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="keywords" content="Retrieving Node (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="resource-type" content="document">
|
||||
<meta name="distribution" content="global">
|
||||
<meta name="Generator" content="makeinfo">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
|
||||
<link href="index.html" rel="start" title="Top">
|
||||
<link href="Index.html" rel="index" title="Index">
|
||||
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||||
<link href="Parsing-Program-Source.html" rel="up" title="Parsing Program Source">
|
||||
<link href="Accessing-Node-Information.html" rel="next" title="Accessing Node Information">
|
||||
<link href="Using-Parser.html" rel="prev" title="Using Parser">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em}
|
||||
a.summary-letter {text-decoration: none}
|
||||
blockquote.indentedblock {margin-right: 0em}
|
||||
div.display {margin-left: 3.2em}
|
||||
div.example {margin-left: 3.2em}
|
||||
kbd {font-style: oblique}
|
||||
pre.display {font-family: inherit}
|
||||
pre.format {font-family: inherit}
|
||||
pre.menu-comment {font-family: serif}
|
||||
pre.menu-preformatted {font-family: serif}
|
||||
span.nolinebreak {white-space: nowrap}
|
||||
span.roman {font-family: initial; font-weight: normal}
|
||||
span.sansserif {font-family: sans-serif; font-weight: normal}
|
||||
span:hover a.copiable-anchor {visibility: visible}
|
||||
ul.no-bullet {list-style: none}
|
||||
-->
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="./manual.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body lang="en">
|
||||
<div class="section" id="Retrieving-Node">
|
||||
<div class="header">
|
||||
<p>
|
||||
Next: <a href="Accessing-Node-Information.html" accesskey="n" rel="next">Accessing Node Information</a>, Previous: <a href="Using-Parser.html" accesskey="p" rel="prev">Using Tree-sitter Parser</a>, Up: <a href="Parsing-Program-Source.html" accesskey="u" rel="up">Parsing Program Source</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
<hr>
|
||||
<span id="Retrieving-Node-1"></span><h3 class="section">37.3 Retrieving Node</h3>
|
||||
<span id="index-retrieve-node_002c-tree_002dsitter"></span>
|
||||
<span id="index-tree_002dsitter_002c-find-node"></span>
|
||||
<span id="index-get-node_002c-tree_002dsitter"></span>
|
||||
|
||||
<span id="index-terminology_002c-for-tree_002dsitter-functions"></span>
|
||||
<p>Here’s some terminology and conventions we use when documenting
|
||||
tree-sitter functions.
|
||||
</p>
|
||||
<p>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.
|
||||
</p>
|
||||
<p>When a function cannot find a node, it returns <code>nil</code>. For
|
||||
convenience, all functions that take a node as argument and return
|
||||
a node, also accept the node argument of <code>nil</code> and in that case
|
||||
just return <code>nil</code>.
|
||||
</p>
|
||||
<span id="index-treesit_002dnode_002doutdated"></span>
|
||||
<p>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 <code>treesit-node-outdated</code> error.
|
||||
</p>
|
||||
<span id="Retrieving-node-from-syntax-tree"></span><h3 class="heading">Retrieving node from syntax tree</h3>
|
||||
<span id="index-retrieving-tree_002dsitter-nodes"></span>
|
||||
<span id="index-syntax-tree_002c-retrieving-nodes"></span>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002dat"><span class="category">Function: </span><span><strong>treesit-node-at</strong> <em>pos &optional parser-or-lang named</em><a href='#index-treesit_002dnode_002dat' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns the <em>smallest</em> node that starts at or after
|
||||
the buffer position <var>pos</var>. In other words, the start of the node
|
||||
is greater or equal to <var>pos</var>.
|
||||
</p>
|
||||
<p>When <var>parser-or-lang</var> is <code>nil</code> or omitted, this function uses
|
||||
the first parser in <code>(treesit-parser-list)</code> of the current
|
||||
buffer. If <var>parser-or-lang</var> is a parser object, it uses that
|
||||
parser; if <var>parser-or-lang</var> is a language, it finds the first
|
||||
parser using that language in <code>(treesit-parser-list)</code>, and uses
|
||||
that.
|
||||
</p>
|
||||
<p>If <var>named</var> is non-<code>nil</code>, this function looks for a named node
|
||||
only (see <a href="Language-Definitions.html#tree_002dsitter-named-node">named node</a>).
|
||||
</p>
|
||||
<p>When <var>pos</var> is after all the text in the buffer, technically there
|
||||
is no node after <var>pos</var>. But for convenience, this function will
|
||||
return the last leaf node in the parse tree. If <var>strict</var> is
|
||||
non-<code>nil</code>, this function will strictly comply to the semantics and
|
||||
return <var>nil</var>.
|
||||
</p>
|
||||
<p>Example:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="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>
|
||||
</pre></div>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002don"><span class="category">Function: </span><span><strong>treesit-node-on</strong> <em>beg end &optional parser-or-lang named</em><a href='#index-treesit_002dnode_002don' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns the <em>smallest</em> node that covers the region
|
||||
of buffer text between <var>beg</var> and <var>end</var>. In other words, the
|
||||
start of the node is before or at <var>beg</var>, and the end of the node
|
||||
is at or after <var>end</var>.
|
||||
</p>
|
||||
<p><em>Beware:</em> 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 <code>treesit-node-at</code>, described above, instead.
|
||||
</p>
|
||||
<p>When <var>parser-or-lang</var> is <code>nil</code>, this function uses the first
|
||||
parser in <code>(treesit-parser-list)</code> of the current buffer. If
|
||||
<var>parser-or-lang</var> is a parser object, it uses that parser; if
|
||||
<var>parser-or-lang</var> is a language, it finds the first parser using
|
||||
that language in <code>(treesit-parser-list)</code>, and uses that.
|
||||
</p>
|
||||
<p>If <var>named</var> is non-<code>nil</code>, this function looks for a named node
|
||||
only (see <a href="Language-Definitions.html#tree_002dsitter-named-node">named node</a>).
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dparser_002droot_002dnode"><span class="category">Function: </span><span><strong>treesit-parser-root-node</strong> <em>parser</em><a href='#index-treesit_002dparser_002droot_002dnode' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns the root node of the syntax tree generated by
|
||||
<var>parser</var>.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dbuffer_002droot_002dnode"><span class="category">Function: </span><span><strong>treesit-buffer-root-node</strong> <em>&optional language</em><a href='#index-treesit_002dbuffer_002droot_002dnode' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function finds the first parser that uses <var>language</var> in
|
||||
<code>(treesit-parser-list)</code> of the current buffer, and returns the
|
||||
root node generated by that parser. If it cannot find an appropriate
|
||||
parser, it returns <code>nil</code>.
|
||||
</p></dd></dl>
|
||||
|
||||
<p>Given a node, a Lisp program can retrieve other nodes starting from
|
||||
it, or query for information about this node.
|
||||
</p>
|
||||
<span id="Retrieving-node-from-other-nodes"></span><h3 class="heading">Retrieving node from other nodes</h3>
|
||||
<span id="index-syntax-tree-nodes_002c-retrieving-from-other-nodes"></span>
|
||||
|
||||
<span id="By-kinship"></span><h4 class="subheading">By kinship</h4>
|
||||
<span id="index-kinship_002c-syntax-tree-nodes"></span>
|
||||
<span id="index-nodes_002c-by-kinship"></span>
|
||||
<span id="index-syntax-tree-nodes_002c-by-kinship"></span>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002dparent"><span class="category">Function: </span><span><strong>treesit-node-parent</strong> <em>node</em><a href='#index-treesit_002dnode_002dparent' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns the immediate parent of <var>node</var>.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002dchild"><span class="category">Function: </span><span><strong>treesit-node-child</strong> <em>node n &optional named</em><a href='#index-treesit_002dnode_002dchild' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns the <var>n</var>’th child of <var>node</var>. If
|
||||
<var>named</var> is non-<code>nil</code>, it counts only named nodes
|
||||
(see <a href="Language-Definitions.html#tree_002dsitter-named-node">named node</a>).
|
||||
</p>
|
||||
<p>For example, in a node that represents a string <code>"text"</code>, there
|
||||
are three children nodes: the opening quote <code>"</code>, the string text
|
||||
<code>text</code>, and the closing quote <code>"</code>. Among these nodes, the
|
||||
first child is the opening quote <code>"</code>, and the first named child
|
||||
is the string text.
|
||||
</p>
|
||||
<p>This function returns <code>nil</code> if there is no <var>n</var>’th child.
|
||||
<var>n</var> could be negative, e.g., <code>-1</code> represents the last child.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002dchildren"><span class="category">Function: </span><span><strong>treesit-node-children</strong> <em>node &optional named</em><a href='#index-treesit_002dnode_002dchildren' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns all of <var>node</var>’s children as a list. If
|
||||
<var>named</var> is non-<code>nil</code>, it retrieves only named nodes.
|
||||
</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>
|
||||
<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>
|
||||
<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>
|
||||
|
||||
<span id="By-field-name"></span><h4 class="subheading">By field name</h4>
|
||||
<span id="index-nodes_002c-by-field-name"></span>
|
||||
<span id="index-syntax-tree-nodes_002c-by-field-name"></span>
|
||||
|
||||
<p>To make the syntax tree easier to analyze, many language definitions
|
||||
assign <em>field names</em> to child nodes (see <a href="Language-Definitions.html#tree_002dsitter-node-field-name">field name</a>). For example, a <code>function_definition</code> node
|
||||
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>
|
||||
<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 (compound_statement) in 45-89>
|
||||
</pre></div>
|
||||
</dd></dl>
|
||||
|
||||
<span id="By-position"></span><h4 class="subheading">By position</h4>
|
||||
<span id="index-nodes_002c-by-position"></span>
|
||||
<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>
|
||||
<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
|
||||
for immediate children of <var>node</var>, and doesn’t look in its
|
||||
grandchildren. If <var>named</var> is non-<code>nil</code>, it looks for the
|
||||
first named child (see <a href="Language-Definitions.html#tree_002dsitter-named-node">named node</a>).
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002ddescendant_002dfor_002drange"><span class="category">Function: </span><span><strong>treesit-node-descendant-for-range</strong> <em>node beg end &optional named</em><a href='#index-treesit_002dnode_002ddescendant_002dfor_002drange' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function finds the <em>smallest</em> descendant node of <var>node</var>
|
||||
that spans the region of text between positions <var>beg</var> and
|
||||
<var>end</var>. It is similar to <code>treesit-node-at</code>. If <var>named</var>
|
||||
is non-<code>nil</code>, it looks for smallest named child.
|
||||
</p></dd></dl>
|
||||
|
||||
<span id="Searching-for-node"></span><h3 class="heading">Searching for node</h3>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dsearch_002dsubtree"><span class="category">Function: </span><span><strong>treesit-search-subtree</strong> <em>node predicate &optional backward all limit</em><a href='#index-treesit_002dsearch_002dsubtree' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function traverses the subtree of <var>node</var> (including
|
||||
<var>node</var> itself), looking for a node for which <var>predicate</var>
|
||||
returns non-<code>nil</code>. <var>predicate</var> is a regexp that is matched
|
||||
against each node’s type, or a predicate function that takes a node
|
||||
and returns non-<code>nil</code> if the node matches. The function returns
|
||||
the first node that matches, or <code>nil</code> if none does.
|
||||
</p>
|
||||
<p>By default, this function only traverses named nodes, but if <var>all</var>
|
||||
is non-<code>nil</code>, it traverses all the nodes. If <var>backward</var> is
|
||||
non-<code>nil</code>, it traverses backwards (i.e., it visits the last child first
|
||||
when traversing down the tree). If <var>limit</var> is non-<code>nil</code>, it
|
||||
must be a number that limits the tree traversal to that many levels
|
||||
down the tree.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dsearch_002dforward"><span class="category">Function: </span><span><strong>treesit-search-forward</strong> <em>start predicate &optional backward all</em><a href='#index-treesit_002dsearch_002dforward' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>Like <code>treesit-search-subtree</code>, this function also traverses the
|
||||
parse tree and matches each node with <var>predicate</var> (except for
|
||||
<var>start</var>), where <var>predicate</var> can be a regexp or a function.
|
||||
For a tree like the below where <var>start</var> is marked S, this function
|
||||
traverses as numbered from 1 to 12:
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example"> 12
|
||||
|
|
||||
S--------3----------11
|
||||
| | |
|
||||
o--o-+--o 1--+--2 6--+-----10
|
||||
| | | |
|
||||
o o +-+-+ +--+--+
|
||||
| | | | |
|
||||
4 5 7 8 9
|
||||
</pre></div>
|
||||
|
||||
<p>Note that this function doesn’t traverse the subtree of <var>start</var>,
|
||||
and it always traverse leaf nodes first, then upwards.
|
||||
</p>
|
||||
<p>Like <code>treesit-search-subtree</code>, this function only searches for
|
||||
named nodes by default, but if <var>all</var> is non-<code>nil</code>, it
|
||||
searches for all nodes. If <var>backward</var> is non-<code>nil</code>, it
|
||||
searches backwards.
|
||||
</p>
|
||||
<p>While <code>treesit-search-subtree</code> traverses the subtree of a node,
|
||||
this function starts with node <var>start</var> 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 <var>start</var>.
|
||||
</p>
|
||||
<p>In the tree shown above, <code>treesit-search-subtree</code> traverses node
|
||||
S (<var>start</var>) and nodes marked with <code>o</code>, where this function
|
||||
traverses the nodes marked with numbers. This function is useful for
|
||||
answering questions like “what is the first node after <var>start</var> in
|
||||
the buffer that satisfies some condition?”
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dsearch_002dforward_002dgoto"><span class="category">Function: </span><span><strong>treesit-search-forward-goto</strong> <em>node predicate &optional start backward all</em><a href='#index-treesit_002dsearch_002dforward_002dgoto' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function moves point to the start or end of the next node after
|
||||
<var>node</var> in the buffer that matches <var>predicate</var>. If <var>start</var>
|
||||
is non-<code>nil</code>, stop at the beginning rather than the end of a node.
|
||||
</p>
|
||||
<p>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 <var>node</var>.
|
||||
</p>
|
||||
<p>Arguments <var>predicate</var>, <var>backward</var> and <var>all</var> are the same
|
||||
as in <code>treesit-search-forward</code>.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dinduce_002dsparse_002dtree"><span class="category">Function: </span><span><strong>treesit-induce-sparse-tree</strong> <em>root predicate &optional process-fn limit</em><a href='#index-treesit_002dinduce_002dsparse_002dtree' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function creates a sparse tree from <var>root</var>’s subtree.
|
||||
</p>
|
||||
<p>It takes the subtree under <var>root</var>, and combs it so only the nodes
|
||||
that match <var>predicate</var> are left. Like previous functions, the
|
||||
<var>predicate</var> can be a regexp string that matches against each
|
||||
node’s type, or a function that takes a node and return non-<code>nil</code>
|
||||
if it matches.
|
||||
</p>
|
||||
<p>For example, for a subtree on the left that consist of both numbers
|
||||
and letters, if <var>predicate</var> is “letter only”, the returned tree
|
||||
is the one on the right.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example"> a a a
|
||||
| | |
|
||||
+---+---+ +---+---+ +---+---+
|
||||
| | | | | | | | |
|
||||
b 1 2 b | | b c d
|
||||
| | => | | => |
|
||||
c +--+ c + e
|
||||
| | | | |
|
||||
+--+ d 4 +--+ d
|
||||
| | |
|
||||
e 5 e
|
||||
</pre></div>
|
||||
|
||||
<p>If <var>process-fn</var> is non-<code>nil</code>, instead of returning the matched
|
||||
nodes, this function passes each node to <var>process-fn</var> and uses the
|
||||
returned value instead. If non-<code>nil</code>, <var>limit</var> is the number of
|
||||
levels to go down from <var>root</var>.
|
||||
</p>
|
||||
<p>Each node in the returned tree looks like
|
||||
<code>(<var><span class="nolinebreak">tree-sitter-node</span></var> . (<var>child</var> …))</code><!-- /@w -->. The
|
||||
<var>tree-sitter-node</var> of the root of this tree will be nil if
|
||||
<var>root</var> doesn’t match <var>predicate</var>. If no node matches
|
||||
<var>predicate</var>, the function returns <code>nil</code>.
|
||||
</p></dd></dl>
|
||||
|
||||
<span id="More-convenience-functions"></span><h3 class="heading">More convenience functions</h3>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dfilter_002dchild"><span class="category">Function: </span><span><strong>treesit-filter-child</strong> <em>node predicate &optional named</em><a href='#index-treesit_002dfilter_002dchild' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function finds immediate children of <var>node</var> that satisfy
|
||||
<var>predicate</var>.
|
||||
</p>
|
||||
<p>The <var>predicate</var> function takes a node as the argument and should
|
||||
return non-<code>nil</code> to indicate that the node should be kept. If
|
||||
<var>named</var> is non-<code>nil</code>, this function only examines the named
|
||||
nodes.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dparent_002duntil"><span class="category">Function: </span><span><strong>treesit-parent-until</strong> <em>node predicate</em><a href='#index-treesit_002dparent_002duntil' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function repeatedly finds the parents of <var>node</var>, and returns
|
||||
the parent that satisfies <var>predicate</var>, a function that takes a
|
||||
node as the argument. If no parent satisfies <var>predicate</var>, this
|
||||
function returns <code>nil</code>.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dparent_002dwhile"><span class="category">Function: </span><span><strong>treesit-parent-while</strong> <em>node predicate</em><a href='#index-treesit_002dparent_002dwhile' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function repeatedly finds the parent of <var>node</var>, and keeps
|
||||
doing so as long as the nodes satisfy <var>predicate</var>, a function that
|
||||
takes a node as the argument. That is, this function returns the
|
||||
farthest parent that still satisfies <var>predicate</var>.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dnode_002dtop_002dlevel"><span class="category">Function: </span><span><strong>treesit-node-top-level</strong> <em>node &optional type</em><a href='#index-treesit_002dnode_002dtop_002dlevel' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns the highest parent of <var>node</var> that has the
|
||||
same type as <var>node</var>. If no such parent exists, it returns
|
||||
<code>nil</code>. Therefore this function is also useful for testing
|
||||
whether <var>node</var> is top-level.
|
||||
</p>
|
||||
<p>If <var>type</var> is non-<code>nil</code>, this function matches each parent’s
|
||||
type with <var>type</var> as a regexp, rather than using <var>node</var>’s type.
|
||||
</p></dd></dl>
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
<div class="header">
|
||||
<p>
|
||||
Next: <a href="Accessing-Node-Information.html">Accessing Node Information</a>, Previous: <a href="Using-Parser.html">Using Tree-sitter Parser</a>, Up: <a href="Parsing-Program-Source.html">Parsing Program Source</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
212
admin/notes/tree-sitter/html-manual/Tree_002dsitter-C-API.html
Normal file
212
admin/notes/tree-sitter/html-manual/Tree_002dsitter-C-API.html
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<!-- This is the GNU Emacs Lisp Reference Manual
|
||||
corresponding to Emacs version 29.0.50.
|
||||
|
||||
Copyright © 1990-1996, 1998-2022 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with the
|
||||
Invariant Sections being "GNU General Public License," with the
|
||||
Front-Cover Texts being "A GNU Manual," and with the Back-Cover
|
||||
Texts as in (a) below. A copy of the license is included in the
|
||||
section entitled "GNU Free Documentation License."
|
||||
|
||||
(a) The FSF's Back-Cover Text is: "You have the freedom to copy and
|
||||
modify this GNU manual. Buying copies from the FSF supports it in
|
||||
developing GNU and promoting software freedom." -->
|
||||
<title>Tree-sitter C API (GNU Emacs Lisp Reference Manual)</title>
|
||||
|
||||
<meta name="description" content="Tree-sitter C API (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="keywords" content="Tree-sitter C API (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="resource-type" content="document">
|
||||
<meta name="distribution" content="global">
|
||||
<meta name="Generator" content="makeinfo">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
|
||||
<link href="index.html" rel="start" title="Top">
|
||||
<link href="Index.html" rel="index" title="Index">
|
||||
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||||
<link href="Parsing-Program-Source.html" rel="up" title="Parsing Program Source">
|
||||
<link href="Tree_002dsitter-major-modes.html" rel="prev" title="Tree-sitter major modes">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em}
|
||||
a.summary-letter {text-decoration: none}
|
||||
blockquote.indentedblock {margin-right: 0em}
|
||||
div.display {margin-left: 3.2em}
|
||||
div.example {margin-left: 3.2em}
|
||||
kbd {font-style: oblique}
|
||||
pre.display {font-family: inherit}
|
||||
pre.format {font-family: inherit}
|
||||
pre.menu-comment {font-family: serif}
|
||||
pre.menu-preformatted {font-family: serif}
|
||||
span.nolinebreak {white-space: nowrap}
|
||||
span.roman {font-family: initial; font-weight: normal}
|
||||
span.sansserif {font-family: sans-serif; font-weight: normal}
|
||||
span:hover a.copiable-anchor {visibility: visible}
|
||||
ul.no-bullet {list-style: none}
|
||||
-->
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="./manual.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body lang="en">
|
||||
<div class="section" id="Tree_002dsitter-C-API">
|
||||
<div class="header">
|
||||
<p>
|
||||
Previous: <a href="Tree_002dsitter-major-modes.html" accesskey="p" rel="prev">Developing major modes with tree-sitter</a>, Up: <a href="Parsing-Program-Source.html" accesskey="u" rel="up">Parsing Program Source</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
<hr>
|
||||
<span id="Tree_002dsitter-C-API-Correspondence"></span><h3 class="section">37.8 Tree-sitter C API Correspondence</h3>
|
||||
|
||||
<p>Emacs’ tree-sitter integration doesn’t expose every feature
|
||||
provided by tree-sitter’s C API. Missing features include:
|
||||
</p>
|
||||
<ul>
|
||||
<li> Creating a tree cursor and navigating the syntax tree with it.
|
||||
</li><li> Setting timeout and cancellation flag for a parser.
|
||||
</li><li> Setting the logger for a parser.
|
||||
</li><li> Printing a <acronym>DOT</acronym> graph of the syntax tree to a file.
|
||||
</li><li> Copying and modifying a syntax tree. (Emacs doesn’t expose a tree
|
||||
object.)
|
||||
</li><li> Using (row, column) coordinates as position.
|
||||
</li><li> Updating a node with changes. (In Emacs, retrieve a new node instead
|
||||
of updating the existing one.)
|
||||
</li><li> Querying statics of a language definition.
|
||||
</li></ul>
|
||||
|
||||
<p>In addition, Emacs makes some changes to the C API to make the API more
|
||||
convenient and idiomatic:
|
||||
</p>
|
||||
<ul>
|
||||
<li> Instead of using byte positions, the Emacs Lisp API uses character
|
||||
positions.
|
||||
</li><li> Null nodes are converted to nil.
|
||||
</li></ul>
|
||||
|
||||
<p>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.
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">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-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_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
|
||||
</pre></div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="header">
|
||||
<p>
|
||||
Previous: <a href="Tree_002dsitter-major-modes.html">Developing major modes with tree-sitter</a>, Up: <a href="Parsing-Program-Source.html">Parsing Program Source</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
231
admin/notes/tree-sitter/html-manual/Using-Parser.html
Normal file
231
admin/notes/tree-sitter/html-manual/Using-Parser.html
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ -->
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<!-- This is the GNU Emacs Lisp Reference Manual
|
||||
corresponding to Emacs version 29.0.50.
|
||||
|
||||
Copyright © 1990-1996, 1998-2022 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with the
|
||||
Invariant Sections being "GNU General Public License," with the
|
||||
Front-Cover Texts being "A GNU Manual," and with the Back-Cover
|
||||
Texts as in (a) below. A copy of the license is included in the
|
||||
section entitled "GNU Free Documentation License."
|
||||
|
||||
(a) The FSF's Back-Cover Text is: "You have the freedom to copy and
|
||||
modify this GNU manual. Buying copies from the FSF supports it in
|
||||
developing GNU and promoting software freedom." -->
|
||||
<title>Using Parser (GNU Emacs Lisp Reference Manual)</title>
|
||||
|
||||
<meta name="description" content="Using Parser (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="keywords" content="Using Parser (GNU Emacs Lisp Reference Manual)">
|
||||
<meta name="resource-type" content="document">
|
||||
<meta name="distribution" content="global">
|
||||
<meta name="Generator" content="makeinfo">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
|
||||
<link href="index.html" rel="start" title="Top">
|
||||
<link href="Index.html" rel="index" title="Index">
|
||||
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||||
<link href="Parsing-Program-Source.html" rel="up" title="Parsing Program Source">
|
||||
<link href="Retrieving-Nodes.html" rel="next" title="Retrieving Nodes">
|
||||
<link href="Language-Definitions.html" rel="prev" title="Language Definitions">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em}
|
||||
a.summary-letter {text-decoration: none}
|
||||
blockquote.indentedblock {margin-right: 0em}
|
||||
div.display {margin-left: 3.2em}
|
||||
div.example {margin-left: 3.2em}
|
||||
kbd {font-style: oblique}
|
||||
pre.display {font-family: inherit}
|
||||
pre.format {font-family: inherit}
|
||||
pre.menu-comment {font-family: serif}
|
||||
pre.menu-preformatted {font-family: serif}
|
||||
span.nolinebreak {white-space: nowrap}
|
||||
span.roman {font-family: initial; font-weight: normal}
|
||||
span.sansserif {font-family: sans-serif; font-weight: normal}
|
||||
span:hover a.copiable-anchor {visibility: visible}
|
||||
ul.no-bullet {list-style: none}
|
||||
-->
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="./manual.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body lang="en">
|
||||
<div class="section" id="Using-Parser">
|
||||
<div class="header">
|
||||
<p>
|
||||
Next: <a href="Retrieving-Nodes.html" accesskey="n" rel="next">Retrieving Nodes</a>, Previous: <a href="Language-Definitions.html" accesskey="p" rel="prev">Tree-sitter Language Definitions</a>, Up: <a href="Parsing-Program-Source.html" accesskey="u" rel="up">Parsing Program Source</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
<hr>
|
||||
<span id="Using-Tree_002dsitter-Parser"></span><h3 class="section">37.2 Using Tree-sitter Parser</h3>
|
||||
<span id="index-tree_002dsitter-parser_002c-using"></span>
|
||||
|
||||
<p>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.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dmax_002dbuffer_002dsize"><span class="category">Variable: </span><span><strong>treesit-max-buffer-size</strong><a href='#index-treesit_002dmax_002dbuffer_002dsize' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>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.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dcan_002denable_002dp"><span class="category">Function: </span><span><strong>treesit-can-enable-p</strong><a href='#index-treesit_002dcan_002denable_002dp' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function checks whether the current buffer is suitable for
|
||||
activating tree-sitter features. It basically checks
|
||||
<code>treesit-available-p</code> and <code>treesit-max-buffer-size</code>.
|
||||
</p></dd></dl>
|
||||
|
||||
<span id="index-creating-tree_002dsitter-parsers"></span>
|
||||
<span id="index-tree_002dsitter-parser_002c-creating"></span>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dparser_002dcreate"><span class="category">Function: </span><span><strong>treesit-parser-create</strong> <em>language &optional buffer no-reuse</em><a href='#index-treesit_002dparser_002dcreate' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>Create a parser for the specified <var>buffer</var> and <var>language</var>
|
||||
(see <a href="Language-Definitions.html">Tree-sitter Language Definitions</a>). If <var>buffer</var> is omitted or
|
||||
<code>nil</code>, it stands for the current buffer.
|
||||
</p>
|
||||
<p>By default, this function reuses a parser if one already exists for
|
||||
<var>language</var> in <var>buffer</var>, but if <var>no-reuse</var> is
|
||||
non-<code>nil</code>, this function always creates a new parser.
|
||||
</p></dd></dl>
|
||||
|
||||
<p>Given a parser, we can query information about it.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dparser_002dbuffer"><span class="category">Function: </span><span><strong>treesit-parser-buffer</strong> <em>parser</em><a href='#index-treesit_002dparser_002dbuffer' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns the buffer associated with <var>parser</var>.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dparser_002dlanguage"><span class="category">Function: </span><span><strong>treesit-parser-language</strong> <em>parser</em><a href='#index-treesit_002dparser_002dlanguage' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns the language used by <var>parser</var>.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dparser_002dp"><span class="category">Function: </span><span><strong>treesit-parser-p</strong> <em>object</em><a href='#index-treesit_002dparser_002dp' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function checks if <var>object</var> is a tree-sitter parser, and
|
||||
returns non-<code>nil</code> if it is, and <code>nil</code> otherwise.
|
||||
</p></dd></dl>
|
||||
|
||||
<p>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.
|
||||
</p>
|
||||
<span id="index-treesit_002dbuffer_002dtoo_002dlarge"></span>
|
||||
<p>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 <code>treesit-buffer-too-large</code>
|
||||
error with signal data being the buffer size.
|
||||
</p>
|
||||
<p>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.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dparser_002dlist"><span class="category">Function: </span><span><strong>treesit-parser-list</strong> <em>&optional buffer</em><a href='#index-treesit_002dparser_002dlist' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns the parser list of <var>buffer</var>. If
|
||||
<var>buffer</var> is <code>nil</code> or omitted, it defaults to the current
|
||||
buffer.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dparser_002ddelete"><span class="category">Function: </span><span><strong>treesit-parser-delete</strong> <em>parser</em><a href='#index-treesit_002dparser_002ddelete' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function deletes <var>parser</var>.
|
||||
</p></dd></dl>
|
||||
|
||||
<span id="index-tree_002dsitter-narrowing"></span>
|
||||
<span id="tree_002dsitter-narrowing"></span><p>Normally, a parser “sees” the whole buffer, but when the buffer is
|
||||
narrowed (see <a href="Narrowing.html">Narrowing</a>), 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 <a href="Multiple-Languages.html">Parsing Text in Multiple Languages</a>.
|
||||
</p>
|
||||
<p>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.
|
||||
</p>
|
||||
<span id="index-tree_002dsitter-parse-string"></span>
|
||||
<span id="index-parse-string_002c-tree_002dsitter"></span>
|
||||
<p>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.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dparse_002dstring"><span class="category">Function: </span><span><strong>treesit-parse-string</strong> <em>string language</em><a href='#index-treesit_002dparse_002dstring' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function parses <var>string</var> using <var>language</var>, and returns
|
||||
the root node of the generated syntax tree.
|
||||
</p></dd></dl>
|
||||
|
||||
<span id="Be-notified-by-changes-to-the-parse-tree"></span><h3 class="heading">Be notified by changes to the parse tree</h3>
|
||||
<span id="index-update-callback_002c-for-tree_002dsitter-parse_002dtree"></span>
|
||||
<span id="index-after_002dchange-notifier_002c-for-tree_002dsitter-parse_002dtree"></span>
|
||||
<span id="index-tree_002dsitter-parse_002dtree_002c-update-and-after_002dchange-callback"></span>
|
||||
<span id="index-notifiers_002c-tree_002dsitter"></span>
|
||||
|
||||
<p>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.
|
||||
</p>
|
||||
<p>Emacs lets a Lisp program to register callback functions
|
||||
(a.k.a. <em>notifiers</em>) for this kind of changes. A notifier
|
||||
function takes two arguments: <var>ranges</var> and <var>parser</var>.
|
||||
<var>ranges</var> is a list of cons cells of the form <code>(<var>start</var> . <var>end</var>)</code><!-- /@w -->, where <var>start</var> and <var>end</var> mark the start and the
|
||||
end positions of a range. <var>parser</var> is the parser issuing the
|
||||
notification.
|
||||
</p>
|
||||
<p>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.
|
||||
</p>
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dparser_002dadd_002dnotifier"><span class="category">Function: </span><span><strong>treesit-parser-add-notifier</strong> <em>parser function</em><a href='#index-treesit_002dparser_002dadd_002dnotifier' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function adds <var>function</var> to <var>parser</var>’s list of
|
||||
after-change notifier functions. <var>function</var> must be a function
|
||||
symbol, not a lambda function (see <a href="Anonymous-Functions.html">Anonymous Functions</a>).
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dparser_002dremove_002dnotifier"><span class="category">Function: </span><span><strong>treesit-parser-remove-notifier</strong> <em>parser function</em><a href='#index-treesit_002dparser_002dremove_002dnotifier' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function removes <var>function</var> from the list of <var>parser</var>’s
|
||||
after-change notifier functions. <var>function</var> must be a function
|
||||
symbol, rather than a lambda function.
|
||||
</p></dd></dl>
|
||||
|
||||
<dl class="def">
|
||||
<dt id="index-treesit_002dparser_002dnotifiers"><span class="category">Function: </span><span><strong>treesit-parser-notifiers</strong> <em>parser</em><a href='#index-treesit_002dparser_002dnotifiers' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>This function returns the list of <var>parser</var>’s notifier functions.
|
||||
</p></dd></dl>
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
<div class="header">
|
||||
<p>
|
||||
Next: <a href="Retrieving-Nodes.html">Retrieving Nodes</a>, Previous: <a href="Language-Definitions.html">Tree-sitter Language Definitions</a>, Up: <a href="Parsing-Program-Source.html">Parsing Program Source</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
23
admin/notes/tree-sitter/html-manual/build-manual.sh
Executable file
23
admin/notes/tree-sitter/html-manual/build-manual.sh
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
#!/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" .
|
||||
374
admin/notes/tree-sitter/html-manual/manual.css
Normal file
374
admin/notes/tree-sitter/html-manual/manual.css
Normal file
|
|
@ -0,0 +1,374 @@
|
|||
/* Style-sheet to use for Emacs manuals */
|
||||
|
||||
/* Copyright (C) 2013-2014 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 <dd> child is an anonymous box */
|
||||
dd { margin: .5em 3% 1em 3%; }
|
||||
/* separate anonymous box (used to be the first element in <dd>)
|
||||
from subsequent <p> */
|
||||
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
|
||||
<blockquote>. 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 <var>
|
||||
inside <blockquote>. Since <var> is also italic, it makes it
|
||||
impossible to distinguish variables. We could change <var> 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;
|
||||
}
|
||||
|
|
@ -17,7 +17,6 @@ TOC:
|
|||
- More features?
|
||||
- Common tasks (code snippets)
|
||||
- Manual
|
||||
- Appendix 1
|
||||
|
||||
* Building Emacs with tree-sitter
|
||||
|
||||
|
|
@ -43,9 +42,11 @@ You can use this script that I put together here:
|
|||
|
||||
https://github.com/casouri/tree-sitter-module
|
||||
|
||||
You can also find them under this directory in /build-modules.
|
||||
|
||||
This script automatically pulls and builds language definitions for C,
|
||||
C++, Rust, JSON, Go, HTML, JavaScript, CSS, Python, Typescript,
|
||||
C#, etc. Better yet, I pre-built these language definitions for
|
||||
C++, Rust, JSON, Go, HTML, Javascript, CSS, Python, Typescript,
|
||||
and C#. Better yet, I pre-built these language definitions for
|
||||
GNU/Linux and macOS, they can be downloaded here:
|
||||
|
||||
https://github.com/casouri/tree-sitter-module/releases/tag/v2.1
|
||||
|
|
@ -67,10 +68,6 @@ organization has all the "official" language definitions:
|
|||
|
||||
https://github.com/tree-sitter
|
||||
|
||||
Alternatively, you can use treesit-install-language-grammar command
|
||||
and follow its instructions. If everything goes right, it should
|
||||
automatically download and compile the language grammar for you.
|
||||
|
||||
* Setting up for adding major mode features
|
||||
|
||||
Start Emacs and load tree-sitter with
|
||||
|
|
@ -81,10 +78,6 @@ Now check if Emacs is built with tree-sitter library
|
|||
|
||||
(treesit-available-p)
|
||||
|
||||
Make sure Emacs can find the language grammar you want to use
|
||||
|
||||
(treesit-language-available-p 'lang)
|
||||
|
||||
* Tree-sitter major modes
|
||||
|
||||
Tree-sitter modes should be separate major modes, so other modes
|
||||
|
|
@ -96,15 +89,12 @@ modes.
|
|||
|
||||
If the tree-sitter variant and the "native" variant could share some
|
||||
setup, you can create a "base mode", which only contains the common
|
||||
setup. For example, python.el defines python-base-mode (shared),
|
||||
python-mode (native), and python-ts-mode (tree-sitter).
|
||||
setup. For example, there is python-base-mode (shared), python-mode
|
||||
(native), and python-ts-mode (tree-sitter).
|
||||
|
||||
In the tree-sitter mode, check if we can use tree-sitter with
|
||||
treesit-ready-p, it will error out if tree-sitter is not ready.
|
||||
|
||||
In Emacs 30 we'll introduce some mechanism to more gracefully inherit
|
||||
modes and fallback to other modes.
|
||||
|
||||
* Naming convention
|
||||
|
||||
Use tree-sitter for text (documentation, comment), use treesit for
|
||||
|
|
@ -190,17 +180,18 @@ mark the offending part in red.
|
|||
To enable tree-sitter font-lock, set ‘treesit-font-lock-settings’ and
|
||||
‘treesit-font-lock-feature-list’ buffer-locally and call
|
||||
‘treesit-major-mode-setup’. For example, see
|
||||
‘python--treesit-settings’ in python.el. Below is a snippet of it.
|
||||
‘python--treesit-settings’ in python.el. Below I paste a snippet of
|
||||
it.
|
||||
|
||||
Just like the current font-lock, if the to-be-fontified region already
|
||||
has a face (ie, an earlier match fontified part/all of the region),
|
||||
the new face is discarded rather than applied. If you want later
|
||||
matches always override earlier matches, use the :override keyword.
|
||||
Note that like the current font-lock, if the to-be-fontified region
|
||||
already has a face (ie, an earlier match fontified part/all of the
|
||||
region), the new face is discarded rather than applied. If you want
|
||||
later matches always override earlier matches, use the :override
|
||||
keyword.
|
||||
|
||||
Each rule should have a :feature, like function-name,
|
||||
string-interpolation, builtin, etc. Users can then enable/disable each
|
||||
feature individually. See Appendix 1 at the bottom for a set of common
|
||||
features names.
|
||||
feature individually.
|
||||
|
||||
#+begin_src elisp
|
||||
(defvar python--treesit-settings
|
||||
|
|
@ -247,7 +238,7 @@ Concretely, something like this:
|
|||
...
|
||||
(cond
|
||||
;; Tree-sitter.
|
||||
((treesit-ready-p 'python)
|
||||
((treesit-ready-p 'python-mode 'python)
|
||||
(treesit-parser-create 'python)
|
||||
(setq-local treesit-font-lock-settings python--treesit-settings)
|
||||
(setq-local treesit-font-lock-feature-list
|
||||
|
|
@ -256,7 +247,8 @@ Concretely, something like this:
|
|||
(string-interpolation decorator)))
|
||||
(treesit-major-mode-setup))
|
||||
(t
|
||||
;; No tree-sitter, do nothing or fallback to another mode.
|
||||
;; No tree-sitter
|
||||
(setq-local font-lock-defaults ...)
|
||||
...)))
|
||||
#+end_src
|
||||
|
||||
|
|
@ -279,7 +271,7 @@ Matchers and anchors are functions that takes (NODE PARENT BOL &rest
|
|||
_). Matches return nil/non-nil for no match/match, and anchors return
|
||||
the anchor point. Below are some convenient builtin matchers and anchors.
|
||||
|
||||
For MATCHER we have
|
||||
For MATHCER we have
|
||||
|
||||
(parent-is TYPE) => matches if PARENT’s type matches TYPE as regexp
|
||||
(node-is TYPE) => matches NODE’s type
|
||||
|
|
@ -290,14 +282,13 @@ For MATCHER we have
|
|||
NODE-INDEX-MIN NODE-INDEX-MAX)
|
||||
|
||||
=> checks everything. If an argument is nil, don’t match that. Eg,
|
||||
(match nil TYPE) is the same as (parent-is TYPE)
|
||||
(match nil nil TYPE) is the same as (parent-is TYPE)
|
||||
|
||||
For ANCHOR we have
|
||||
|
||||
first-sibling => start of the first sibling
|
||||
parent => start of parent
|
||||
parent-bol => BOL of the line parent is on.
|
||||
standalone-parent => Like parent-bol but handles more edge cases
|
||||
prev-sibling => start of previous sibling
|
||||
no-indent => current position (don’t indent)
|
||||
prev-line => start of previous line
|
||||
|
|
@ -338,8 +329,7 @@ tells you which rule is applied in the echo area.
|
|||
...))))
|
||||
#+end_src
|
||||
|
||||
To setup indentation for your major mode, set
|
||||
‘treesit-simple-indent-rules’ to your rules, and call
|
||||
Then you set ‘treesit-simple-indent-rules’ to your rules, and call
|
||||
‘treesit-major-mode-setup’:
|
||||
|
||||
#+begin_src elisp
|
||||
|
|
@ -349,14 +339,36 @@ To setup indentation for your major mode, set
|
|||
|
||||
* Imenu
|
||||
|
||||
Set ‘treesit-simple-imenu-settings’ and call
|
||||
‘treesit-major-mode-setup’.
|
||||
Not much to say except for utilizing ‘treesit-induce-sparse-tree’ (and
|
||||
explicitly pass a LIMIT argument: most of the time you don't need more
|
||||
than 10). See ‘js--treesit-imenu-1’ in js.el for an example.
|
||||
|
||||
Once you have the index builder, set ‘imenu-create-index-function’ to
|
||||
it.
|
||||
|
||||
* Navigation
|
||||
|
||||
Set ‘treesit-defun-type-regexp’ and call
|
||||
‘treesit-major-mode-setup’. You can additionally set
|
||||
‘treesit-defun-name-function’.
|
||||
Mainly ‘beginning-of-defun-function’ and ‘end-of-defun-function’.
|
||||
You can find the end of a defun with something like
|
||||
|
||||
(treesit-search-forward-goto "function_definition" 'end)
|
||||
|
||||
where "function_definition" matches the node type of a function
|
||||
definition node, and ’end means we want to go to the end of that node.
|
||||
|
||||
Tree-sitter has default implementations for
|
||||
‘beginning-of-defun-function’ and ‘end-of-defun-function’. So for
|
||||
ordinary languages, it is enough to set ‘treesit-defun-type-regexp’
|
||||
to something that matches all the defun struct types in the language,
|
||||
and call ‘treesit-major-mode-setup’. For example,
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(setq-local treesit-defun-type-regexp (rx bol
|
||||
(or "function" "class")
|
||||
"_definition"
|
||||
eol))
|
||||
(treesit-major-mode-setup)
|
||||
#+end_src>
|
||||
|
||||
* Which-func
|
||||
|
||||
|
|
@ -364,7 +376,36 @@ If you have an imenu implementation, set ‘which-func-functions’ to
|
|||
nil, and which-func will automatically use imenu’s data.
|
||||
|
||||
If you want an independent implementation for which-func, you can
|
||||
find the current function by ‘treesit-defun-at-point’.
|
||||
find the current function by going up the tree and looking for the
|
||||
function_definition node. See the function below for an example.
|
||||
Since Python allows nested function definitions, that function keeps
|
||||
going until it reaches the root node, and records all the function
|
||||
names along the way.
|
||||
|
||||
#+begin_src elisp
|
||||
(defun python-info-treesit-current-defun (&optional include-type)
|
||||
"Identical to `python-info-current-defun' but use tree-sitter.
|
||||
For INCLUDE-TYPE see `python-info-current-defun'."
|
||||
(let ((node (treesit-node-at (point)))
|
||||
(name-list ())
|
||||
(type nil))
|
||||
(cl-loop while node
|
||||
if (pcase (treesit-node-type node)
|
||||
("function_definition"
|
||||
(setq type 'def))
|
||||
("class_definition"
|
||||
(setq type 'class))
|
||||
(_ nil))
|
||||
do (push (treesit-node-text
|
||||
(treesit-node-child-by-field-name node "name")
|
||||
t)
|
||||
name-list)
|
||||
do (setq node (treesit-node-parent node))
|
||||
finally return (concat (if include-type
|
||||
(format "%s " type)
|
||||
"")
|
||||
(string-join name-list ".")))))
|
||||
#+end_src
|
||||
|
||||
* More features?
|
||||
|
||||
|
|
@ -408,51 +449,7 @@ section is Parsing Program Source. Typing
|
|||
|
||||
C-h i d m elisp RET g Parsing Program Source RET
|
||||
|
||||
will bring you to that section. You don’t need to read through every
|
||||
sentence, just read the text paragraphs and glance over function
|
||||
names.
|
||||
|
||||
* Appendix 1
|
||||
|
||||
Below is a set of common features used by built-in major mode.
|
||||
|
||||
Basic tokens:
|
||||
|
||||
delimiter ,.; (delimit things)
|
||||
operator == != || (produces a value)
|
||||
bracket []{}()
|
||||
misc-punctuation (other punctuation that you want to highlight)
|
||||
|
||||
constant true, false, null
|
||||
number
|
||||
keyword
|
||||
comment (includes doc-comments)
|
||||
string (includes chars and docstrings)
|
||||
string-interpolation f"text {variable}"
|
||||
escape-sequence "\n\t\\"
|
||||
function every function identifier
|
||||
variable every variable identifier
|
||||
type every type identifier
|
||||
property a.b <--- highlight b
|
||||
key { a: b, c: d } <--- highlight a, c
|
||||
error highlight parse error
|
||||
|
||||
Abstract features:
|
||||
|
||||
assignment: the LHS of an assignment (thing being assigned to), eg:
|
||||
|
||||
a = b <--- highlight a
|
||||
a.b = c <--- highlight b
|
||||
a[1] = d <--- highlight a
|
||||
|
||||
definition: the thing being defined, eg:
|
||||
|
||||
int a(int b) { <--- highlight a
|
||||
return 0
|
||||
}
|
||||
|
||||
int a; <-- highlight a
|
||||
|
||||
struct a { <--- highlight a
|
||||
int b; <--- highlight b
|
||||
}
|
||||
will bring you to that section. You can also read the HTML version
|
||||
under /html-manual in this directory. I find the HTML version easier
|
||||
to read. You don’t need to read through every sentence, just read the
|
||||
text paragraphs and glance over function names.
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
NOTES ON TREESIT_RECORD_CHANGE
|
||||
|
||||
It is vital that Emacs informs tree-sitter of every change made to the
|
||||
buffer, lest tree-sitter's parse tree would be corrupted/out of sync.
|
||||
|
||||
All buffer changes in Emacs are made through functions in insdel.c
|
||||
(and casefiddle.c), I augmented functions in those files with calls to
|
||||
treesit_record_change. Below is a manifest of all the relevant
|
||||
functions in insdel.c as of Emacs 29:
|
||||
|
||||
Function Calls
|
||||
----------------------------------------------------------------------
|
||||
copy_text (*1)
|
||||
insert insert_1_both
|
||||
insert_and_inherit insert_1_both
|
||||
insert_char insert
|
||||
insert_string insert
|
||||
insert_before_markers insert_1_both
|
||||
insert_before_markers_and_inherit insert_1_both
|
||||
insert_1_both treesit_record_change
|
||||
insert_from_string insert_from_string_1
|
||||
insert_from_string_before_markers insert_from_string_1
|
||||
insert_from_string_1 treesit_record_change
|
||||
insert_from_gap_1 treesit_record_change
|
||||
insert_from_gap insert_from_gap_1
|
||||
insert_from_buffer treesit_record_change
|
||||
insert_from_buffer_1 (used by insert_from_buffer) (*2)
|
||||
replace_range treesit_record_change
|
||||
replace_range_2 (caller needs to call treesit_r_c)
|
||||
del_range del_range_1
|
||||
del_range_1 del_range_2
|
||||
del_range_byte del_range_2
|
||||
del_range_both del_range_2
|
||||
del_range_2 treesit_record_change
|
||||
|
||||
(*1) This functions is used only to copy from string to string when
|
||||
used outside of insdel.c, and when used inside insdel.c, the caller
|
||||
calls treesit_record_change.
|
||||
|
||||
(*2) This function is a static function, and insert_from_buffer is its
|
||||
only caller. So it should be fine to call treesit_record_change in
|
||||
insert_from_buffer but not insert_from_buffer_1. I also left a
|
||||
reminder comment.
|
||||
|
||||
|
||||
As for casefiddle.c, do_casify_unibyte_region and
|
||||
do_casify_multibyte_region modifies buffer, but they are static
|
||||
functions and are called by casify_region, which calls
|
||||
treesit_record_change. Other higher-level functions calls
|
||||
casify_region to do the work.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
-*-mode: text; coding: utf-8;-*-
|
||||
|
||||
Copyright (C) 2002-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-2022 Free Software Foundation, Inc.
|
||||
See the end of the file for license conditions.
|
||||
|
||||
Importing a new Unicode Standard version into Emacs
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
-*- outline -*-
|
||||
|
||||
Copyright (C) 2013-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2013-2022 Free Software Foundation, Inc.
|
||||
See the end of the file for license conditions.
|
||||
|
||||
NOTES FOR EMACS WWW PAGES
|
||||
|
|
|
|||
|
|
@ -10,10 +10,9 @@ results for plausibility, then commit them.
|
|||
A few known problems with the build-aux/update-copyright script:
|
||||
|
||||
. it doesn't update config.bat, msdos/depfiles.bat,
|
||||
nt/configure.bat, etc/tutorials/TUTORIAL.cn,
|
||||
etc/tutorials/TUTORIAL.el_GR, and etc/tutorials/TUTORIAL.he
|
||||
because the "Copyright" statement begins in these files
|
||||
after a prefix that is more than 5 characters long
|
||||
nt/configure.bat, etc/tutorials/TUTORIAL.cn, and
|
||||
etc/tutorials/TUTORIAL.he because the "Copyright" statement begins
|
||||
in these files after a prefix that is more than 5 characters long
|
||||
. it doesn't update etc/tutorials/TUTORIAL.nl and
|
||||
etc/tutorials/TUTORIAL.ro for some reason
|
||||
. it doesn't update the second Copyright notice, the one that gets
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001-2022 Free Software Foundation, Inc.
|
||||
See the end of the file for license conditions.
|
||||
|
||||
Emacs for Windows
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001-2022 Free Software Foundation, Inc.
|
||||
See the end of the file for license conditions.
|
||||
|
||||
Precompiled Distributions of
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
## Copyright (C) 2017-2023 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2017-2022 Free Software Foundation, Inc.
|
||||
|
||||
## This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
## Copyright (C) 2017-2023 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2017-2022 Free Software Foundation, Inc.
|
||||
|
||||
## This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
### quick-install-emacs --- do a halfway-decent job of installing emacs quickly
|
||||
|
||||
## Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2001-2022 Free Software Foundation, Inc.
|
||||
|
||||
## Author: Miles Bader <miles@gnu.org>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
### @configure_input@
|
||||
|
||||
# Copyright (C) 2012-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2012-2022 Free Software Foundation, Inc.
|
||||
|
||||
# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
|
||||
# National Institute of Advanced Industrial Science and Technology (AIST)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/awk -f
|
||||
|
||||
## Copyright (C) 2015-2023 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2015-2022 Free Software Foundation, Inc.
|
||||
|
||||
## Author: Glenn Morris <rgm@gnu.org>
|
||||
## Maintainer: emacs-devel@gnu.org
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/awk -f
|
||||
|
||||
## Copyright (C) 2020, 2022-2023 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2020, 2022 Free Software Foundation, Inc.
|
||||
|
||||
## Author: Robert Pluim <rpluim@gmail.com>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
;;; unidata-gen.el --- Create files containing character property data -*- lexical-binding:t -*-
|
||||
|
||||
;; Copyright (C) 2008-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2008-2022 Free Software Foundation, Inc.
|
||||
|
||||
;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
|
||||
;; National Institute of Advanced Industrial Science and Technology (AIST)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
;;; uvs.el --- utility for UVS (format 14) cmap subtables in OpenType fonts -*- lexical-binding:t -*-
|
||||
|
||||
;; Copyright (C) 2014-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2014-2022 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
# By default, this script uses the local-time calendar year.
|
||||
# Set the UPDATE_COPYRIGHT_YEAR environment variable to override the default.
|
||||
|
||||
# Copyright 2013-2023 Free Software Foundation, Inc.
|
||||
# Copyright 2013-2022 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
### update_autogen - update some auto-generated files in the Emacs tree
|
||||
|
||||
## Copyright (C) 2011-2023 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2011-2022 Free Software Foundation, Inc.
|
||||
|
||||
## Author: Glenn Morris <rgm@gnu.org>
|
||||
## Maintainer: Stefan Kangas <stefankangas@gmail.com>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
### upload-manuals - upload the Emacs manuals to the gnu.org website
|
||||
|
||||
## Copyright 2018-2023 Free Software Foundation, Inc.
|
||||
## Copyright 2018-2022 Free Software Foundation, Inc.
|
||||
|
||||
## Author: Glenn Morris <rgm@gnu.org>
|
||||
## Maintainer: emacs-devel@gnu.org
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
### autogen.sh - tool to help build Emacs from a repository checkout
|
||||
|
||||
## Copyright (C) 2011-2023 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2011-2022 Free Software Foundation, Inc.
|
||||
|
||||
## Author: Glenn Morris <rgm@gnu.org>
|
||||
## Maintainer: emacs-devel@gnu.org
|
||||
|
|
@ -340,8 +340,7 @@ git_config diff.texinfo.xfuncname \
|
|||
tailored_hooks=
|
||||
sample_hooks=
|
||||
|
||||
for hook in commit-msg pre-commit prepare-commit-msg post-commit \
|
||||
pre-push commit-msg-files.awk; do
|
||||
for hook in commit-msg pre-commit prepare-commit-msg; do
|
||||
cmp -- build-aux/git-hooks/$hook "$hooks/$hook" >/dev/null 2>&1 ||
|
||||
tailored_hooks="$tailored_hooks $hook"
|
||||
done
|
||||
|
|
|
|||
6
build-aux/config.guess
vendored
6
build-aux/config.guess
vendored
|
|
@ -1,10 +1,10 @@
|
|||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright 1992-2023 Free Software Foundation, Inc.
|
||||
# Copyright 1992-2022 Free Software Foundation, Inc.
|
||||
|
||||
# shellcheck disable=SC2006,SC2268 # see below for rationale
|
||||
|
||||
timestamp='2023-01-01'
|
||||
timestamp='2022-09-17'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
|
|
@ -60,7 +60,7 @@ version="\
|
|||
GNU config.guess ($timestamp)
|
||||
|
||||
Originally written by Per Bothner.
|
||||
Copyright 1992-2023 Free Software Foundation, Inc.
|
||||
Copyright 1992-2022 Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||
|
|
|
|||
8
build-aux/config.sub
vendored
8
build-aux/config.sub
vendored
|
|
@ -1,10 +1,10 @@
|
|||
#! /bin/sh
|
||||
# Configuration validation subroutine script.
|
||||
# Copyright 1992-2023 Free Software Foundation, Inc.
|
||||
# Copyright 1992-2022 Free Software Foundation, Inc.
|
||||
|
||||
# shellcheck disable=SC2006,SC2268 # see below for rationale
|
||||
|
||||
timestamp='2023-01-21'
|
||||
timestamp='2022-09-17'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
|
|
@ -76,7 +76,7 @@ Report bugs and patches to <config-patches@gnu.org>."
|
|||
version="\
|
||||
GNU config.sub ($timestamp)
|
||||
|
||||
Copyright 1992-2023 Free Software Foundation, Inc.
|
||||
Copyright 1992-2022 Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||
|
|
@ -1075,7 +1075,7 @@ case $cpu-$vendor in
|
|||
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
|
||||
cpu=i586
|
||||
;;
|
||||
pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
|
||||
pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
|
||||
cpu=i686
|
||||
;;
|
||||
pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
# Check the format of GNU Emacs change log entries.
|
||||
|
||||
# Copyright 2014-2023 Free Software Foundation, Inc.
|
||||
# Copyright 2014-2022 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,128 +0,0 @@
|
|||
# Check the file list of GNU Emacs change log entries for each commit SHA.
|
||||
|
||||
# Copyright 2023 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU Emacs.
|
||||
|
||||
# GNU Emacs is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# GNU Emacs is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
### Commentary:
|
||||
|
||||
# This script accepts a list of (unabbreviated) Git commit SHAs, and
|
||||
# will then iterate over them to check that any files mentioned in the
|
||||
# commit message are actually present in the commit's diff. If not,
|
||||
# it will print out the incorrect file names and return 1.
|
||||
|
||||
# You can also pass "-v reason=pre-push", which will add more-verbose
|
||||
# output, indicating the abbreviated commit SHA and first line of the
|
||||
# commit message for any improper commits.
|
||||
|
||||
### Code:
|
||||
|
||||
function get_commit_changes(commit_sha, changes, cmd, i, j, len, \
|
||||
bits, filename) {
|
||||
# Collect all the files touched in the specified commit.
|
||||
cmd = ("git show --name-status --first-parent --format= " commit_sha)
|
||||
while ((cmd | getline) > 0) {
|
||||
for (i = 2; i <= NF; i++) {
|
||||
len = split($i, bits, "/")
|
||||
for (j = 1; j <= len; j++) {
|
||||
if (j == 1)
|
||||
filename = bits[j]
|
||||
else
|
||||
filename = filename "/" bits[j]
|
||||
changes[filename] = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
close(cmd)
|
||||
}
|
||||
|
||||
function check_commit_msg_files(commit_sha, verbose, changes, good, \
|
||||
cmd, msg, filenames_str, filenames, i) {
|
||||
get_commit_changes(commit_sha, changes)
|
||||
good = 1
|
||||
|
||||
cmd = ("git log -1 --format=%B " commit_sha)
|
||||
while ((cmd | getline) > 0) {
|
||||
if (verbose && ! msg)
|
||||
msg = $0
|
||||
|
||||
# Find file entries in the commit message. We look at any line
|
||||
# starting with "*" (possibly prefixed by "; ") followed by a ":",
|
||||
# possibly on a different line. If we encounter a blank line
|
||||
# without seeing a ":", then we don't treat that as a file entry.
|
||||
|
||||
# Accumulate the contents of a (possible) file entry.
|
||||
if (/^[ \t]*$/)
|
||||
filenames_str = ""
|
||||
else if (/^(; )?\*[ \t]+[[:alnum:]]/)
|
||||
filenames_str = $0
|
||||
else if (filenames_str)
|
||||
filenames_str = (filenames_str $0)
|
||||
|
||||
# We have a file entry; analyze it.
|
||||
if (filenames_str && /:/) {
|
||||
# Delete the leading "*" and any trailing information.
|
||||
sub(/^(; )?\*[ \t]+/, "", filenames_str)
|
||||
sub(/[ \t]*[[(<:].*$/, "", filenames_str)
|
||||
|
||||
# There might be multiple files listed in this entry, separated
|
||||
# by spaces (and possibly a comma). Iterate over each of them.
|
||||
split(filenames_str, filenames, ",[ \t]+")
|
||||
for (i in filenames) {
|
||||
# Remove trailing slashes from any directory entries.
|
||||
sub(/\/$/, "", filenames[i])
|
||||
|
||||
if (length(filenames[i]) && ! (filenames[i] in changes)) {
|
||||
if (good) {
|
||||
# Print a header describing the error.
|
||||
if (verbose)
|
||||
printf("In commit %s \"%s\"...\n", substr(commit_sha, 1, 10), msg)
|
||||
printf("Files listed in commit message, but not in diff:\n")
|
||||
}
|
||||
printf(" %s\n", filenames[i])
|
||||
good = 0
|
||||
}
|
||||
}
|
||||
|
||||
filenames_str = ""
|
||||
}
|
||||
}
|
||||
close(cmd)
|
||||
|
||||
return good
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
if (reason == "pre-push")
|
||||
verbose = 1
|
||||
}
|
||||
|
||||
/^[a-z0-9]{40}$/ {
|
||||
if (! check_commit_msg_files($0, verbose)) {
|
||||
status = 1
|
||||
}
|
||||
}
|
||||
|
||||
END {
|
||||
if (status != 0) {
|
||||
if (reason == "pre-push")
|
||||
error_msg = "Push aborted"
|
||||
else
|
||||
error_msg = "Bad commit message"
|
||||
printf("%s; please see the file 'CONTRIBUTE'\n", error_msg)
|
||||
}
|
||||
exit status
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Check the file list of GNU Emacs change log entries after committing.
|
||||
|
||||
# Copyright 2023 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU Emacs.
|
||||
|
||||
# GNU Emacs is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# GNU Emacs is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
### Commentary:
|
||||
|
||||
# This hook runs after a commit is finalized and checks that the files
|
||||
# mentioned in the commit message match the diff. We perform this in
|
||||
# the post-commit phase so that we can be sure we properly detect all
|
||||
# the files in the diff (this is difficult during the commit-msg hook,
|
||||
# since there's no cross-platform way to detect when a commit is being
|
||||
# amended).
|
||||
|
||||
# However, since this is a post-commit hook, it's too late to error
|
||||
# out and abort the commit: it's already done! As a result, this hook
|
||||
# is purely advisory, and instead we error out when trying to push
|
||||
# (see "pre-push" in this directory).
|
||||
|
||||
### Code:
|
||||
|
||||
HOOKS_DIR=`dirname "$0"`
|
||||
|
||||
# Prefer gawk if available, as it handles NUL bytes properly.
|
||||
if type gawk >/dev/null 2>&1; then
|
||||
awk="gawk"
|
||||
else
|
||||
awk="awk"
|
||||
fi
|
||||
|
||||
git rev-parse HEAD | $awk -v reason=post-commit \
|
||||
-f "$HOOKS_DIR"/commit-msg-files.awk
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
# Check file names in git commits for GNU Emacs.
|
||||
|
||||
# Copyright 2014-2023 Free Software Foundation, Inc.
|
||||
# Copyright 2014-2022 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,88 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Check the file list of GNU Emacs change log entries before pushing.
|
||||
|
||||
# Copyright 2023 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU Emacs.
|
||||
|
||||
# GNU Emacs is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# GNU Emacs is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
### Commentary:
|
||||
|
||||
# This hook runs before pushing a series of commits and checks that
|
||||
# the files mentioned in each commit message match the diffs. This
|
||||
# helps ensure that the resulting change logs are correct, which
|
||||
# should prevent errors when generating etc/AUTHORS.
|
||||
|
||||
# These checks also happen in the "post-commit" hook (which see), but
|
||||
# that hook can't abort a commit; it just advises the committer to fix
|
||||
# the commit so that this hook runs without errors.
|
||||
|
||||
### Code:
|
||||
|
||||
HOOKS_DIR=`dirname "$0"`
|
||||
|
||||
# Prefer gawk if available, as it handles NUL bytes properly.
|
||||
if type gawk >/dev/null 2>&1; then
|
||||
awk="gawk"
|
||||
else
|
||||
awk="awk"
|
||||
fi
|
||||
|
||||
# Standard input receives lines of the form:
|
||||
# <local ref> SP <local sha> SP <remote ref> SP <remote sha> LF
|
||||
$awk -v origin_name="$1" '
|
||||
# If the local SHA is all zeroes, ignore it.
|
||||
$2 ~ /^0{40}$/ {
|
||||
next
|
||||
}
|
||||
|
||||
# Check any lines with a valid local SHA and whose remote ref is
|
||||
# master or an emacs-NN release branch. (We want to avoid checking
|
||||
# feature or scratch branches here.)
|
||||
$2 ~ /^[a-z0-9]{40}$/ && $3 ~ /^refs\/heads\/(master|emacs-[0-9]+)$/ {
|
||||
newref = $2
|
||||
# If the remote SHA is all zeroes, this is a new object to be
|
||||
# pushed (likely a branch)...
|
||||
if ($4 ~ /^0{40}$/) {
|
||||
back = 0
|
||||
# ... Go backwards until we find a SHA on an origin branch.
|
||||
# Stop trying after 1000 commits, just in case...
|
||||
for (back = 0; back < 1000; back++) {
|
||||
cmd = ("git branch -r -l '\''" origin_name "/*'\''" \
|
||||
" --contains " newref "~" back)
|
||||
rv = (cmd | getline)
|
||||
close(cmd)
|
||||
if (rv > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
cmd = ("git rev-parse " newref "~" back)
|
||||
cmd | getline oldref
|
||||
if (!(oldref ~ /^[a-z0-9]{40}$/)) {
|
||||
# The SHA is misformatted! Skip this line.
|
||||
next
|
||||
}
|
||||
close(cmd)
|
||||
} else if ($4 ~ /^[a-z0-9]{40}$/) {
|
||||
oldref = $4
|
||||
} else {
|
||||
# The SHA is misformatted! Skip this line.
|
||||
next
|
||||
}
|
||||
|
||||
# Print every SHA after oldref, up to (and including) newref.
|
||||
system("git rev-list --first-parent --reverse " oldref ".." newref)
|
||||
}
|
||||
' | $awk -v reason=pre-push -f "$HOOKS_DIR"/commit-msg-files.awk
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
# Check the format of GNU Emacs change log entries.
|
||||
|
||||
# Copyright 2019-2023 Free Software Foundation, Inc.
|
||||
# Copyright 2019-2022 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU Emacs.
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
# Convert git log output to ChangeLog format.
|
||||
|
||||
# Copyright (C) 2008-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2008-2022 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Convert git log output to ChangeLog format for GNU Emacs.
|
||||
|
||||
# Copyright (C) 2014-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2014-2022 Free Software Foundation, Inc.
|
||||
|
||||
# Author: Paul Eggert
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
### make-info-dir - create info/dir, for systems without install-info
|
||||
|
||||
## Copyright (C) 2013-2023 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2013-2022 Free Software Foundation, Inc.
|
||||
|
||||
## Author: Glenn Morris <rgm@gnu.org>
|
||||
## Maintainer: emacs-devel@gnu.org
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue