Commit graph

358 commits

Author SHA1 Message Date
Eli Zaretskii
617c358da7 Merge from origin/emacs-29
c966e7ec38 * lisp/net/tramp.el (tramp-skeleton-write-region): Fix mi...
a2953ea300 Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/...
5cba5ee890 Fix tree-sitter range update function
41333cb2d5 ; * etc/NEWS: Fix typos.
a3a9ed40d8 ; * CONTRIBUTE: Clarify "mark" wrt NEWS entries.  (Bug#66...
0a6a9ac6f1 ; * etc/NEWS: Fix last change.
5611274bbd Announce handling 'org-protocol' URI scheme in NEWS

# Conflicts:
#	lisp/treesit.el
2023-09-23 09:41:02 -04:00
Yuan Fu
5cba5ee890
Fix tree-sitter range update function
* lisp/treesit.el (treesit-update-ranges): If an embedded language
doesn't have any range, don't set its range to nil (which means whole
buffer), instead, set its range to a dummy (1 . 1) zero range.
2023-09-18 20:48:54 -07:00
Yuan Fu
fc7c1f1e93
Fix treesit--update-ranges-local
* lisp/treesit.el (treesit--update-ranges-local): Don't forget to set
local parser's range when creating it.
2023-09-18 20:48:28 -07:00
Danny Freeman
b892da5f61
Offset ranges before applying embedded tree-sitter parser
This feature would allow treesitter major modes to easily specify
offsets when using embeded parsers.  A potential use case for this is
javascript template strings, when we want to apply a different parser
to the string's contents, but do not want to include the template
string's delimiters.

* lisp/treesit.el
(treesit-query-range): Accept an optional offest arg, apply the offset
to all returned ranges.
(treesit-range-rules): Accept an optional :offset keyword arg to adjust
ranges an embded parser is applied to.
(treesit-update-ranges): Forward optional :offset setting from
`treesit-range-rules' to `treesit-query-rang'.
* test/lisp/treesit-tests.el
(treesit-range-offset): Tests the new offset functionality.
2023-09-17 21:12:56 -07:00
Yuan Fu
04fd8b173b
Allow treesit-font-lock-recompute-features to be language-specific
* lisp/treesit.el:
(treesit-font-lock-recompute-features): Add LANGUAGE parameter.
2023-09-15 00:44:23 -07:00
Yuan Fu
de6a652a03
Refactor treesit-font-lock-fontify-region
* lisp/treesit.el (treesit-font-lock-fontify-region): Extract out
treesit--font-lock-fontify-region-1.
2023-09-13 21:04:18 -07:00
Yuan Fu
63766b49e2
Fix treesit-font-lock-fontify-region wrt local parsers
* lisp/treesit.el (treesit--update-ranges-local): Minor change.
(treesit-font-lock-fontify-region): Don't try to fontify if node is
nil.  Don't use alist-get to get the root node for a language: there
might be multiple root nodes (from multiple local parsers) for the
same language.
(treesit-major-mode-setup): Remove existing local parsers when major
mode is activated.
2023-09-13 21:00:29 -07:00
Yuan Fu
8facdb62d3
Improve docstring for treesit-language-at
* lisp/treesit.el (treesit-language-at-point-function)
(treesit-language-at): Several people has confused over this, make it
extra clear than treesit-language-at requires
treesit-language-at-point-function to work.
2023-09-13 18:15:28 -07:00
Yuan Fu
b1c4089171
; * lisp/treesit.el (treesit-explore-mode): Support local parsers. 2023-09-11 18:08:08 -07:00
Yuan Fu
93a458f25f
Fix treesit-node-at wrt local parsers
* lisp/treesit.el (treesit-node-at): Don't compute language at point
first.  Because treesit-language-at uses treesit-node-at with a
language argument. Only call treesit-language-at when PARSER-OR-LANG
is nil.
2023-09-09 12:36:49 -07:00
Yuan Fu
98f98c66e0
; * lisp/treesit.el (treesit--indent-1): Get all parsers. 2023-09-08 09:09:14 -07:00
Yuan Fu
2db725fb24
; * lisp/treesit.el (treesit--indent-1): Add missing call. 2023-09-08 09:08:28 -07:00
Yuan Fu
b1bcd396ed
Fix treesit-thing-definition
* lisp/treesit.el (treesit-thing-definition): Don't modify
treesit-thing-settings itself.
2023-09-07 17:56:11 -07:00
Yuan Fu
9f6cf89fb1
; * lisp/treesit.el (treesit-node-on): Fix treesit-local-parsers-on. 2023-09-07 17:44:32 -07:00
Yuan Fu
30de869a3e
; * lisp/treesit.el (treesit-update-ranges): Fix use of parser-list. 2023-09-07 16:04:47 -07:00
Yuan Fu
a9a096ff8b
Add Ftreesit_parser_tag
* lisp/treesit.el (treesit-parser-tag): Add.
* src/treesit.c (Ftreesit_parser_tag): Add.
2023-09-07 16:04:47 -07:00
Yuan Fu
8aa9dc1c0c
Change treesit-local-parsers-in to treesit-local-parsers-on
To improve consistency. We already have treesit-node-at and
treesit-node-on.

* doc/lispref/parsing.texi (Multiple Languages): Update manual.
* lisp/treesit.el (treesit-local-parsers-on): Change to in.
(treesit-font-lock-fontify-region): Change to in.
2023-09-07 16:04:29 -07:00
Eli Zaretskii
28cb3a4413 ; Fix recent changes in treesit documentation
* lisp/treesit.el (treesit-local-parsers-at)
(treesit-local-parsers-in):
* doc/lispref/parsing.texi (Multiple Languages):
 (Using Parser): Fix wording of recently added docs.
2023-09-07 11:09:56 +03:00
Yuan Fu
d1f916b046
Support local parser in treesit-node-at/on
* lisp/treesit.el (treesit-node-at)
(treesit-node-on): Support local parser.
2023-09-05 21:03:38 -07:00
Yuan Fu
d05494a9ff
Support tree-sitter local parsers
* doc/lispref/parsing.texi (Multiple Languages): Update manual.
* lisp/treesit.el (treesit-range-settings): Add LOCAL-P to range
setting.
(treesit-range-rules): Support :local keyword.
(treesit-local-parsers-at)
(treesit-local-parsers-in)
(treesit--update-ranges-local): New functions.
(treesit-update-ranges)
(treesit-font-lock-fontify-region)
(treesit--indent-1): Support local parsers and prioritize it over
global parsers.
2023-09-05 21:03:38 -07:00
Yuan Fu
722daf6fff
Add tag to tree-sitter parsers
* doc/lispref/parsing.texi (Using Parser): Update manual.
* lisp/treesit.el (treesit-buffer-root-node)
* src/treesit.c (make_treesit_parser)
* src/treesit.c (Ftreesit_parser_create): Add TAG parameter.
(treesit_resolve_node): Create a parser with nil tag.
* src/treesit.h (Lisp_TS_Parser): Add TAG field.
2023-09-05 21:03:37 -07:00
Daniel Martín
cd6dcfad10 Improve completion of treesit-check-indent command
* lisp/treesit.el (treesit--read-major-mode): Helper function to
provide completion for most major modes.
(treesit-check-indent): Use the new interactive spec and improve the
docstring.  (Bug#60001)
2023-09-05 22:40:38 +02:00
Eli Zaretskii
ec3ea8c036 Merge from origin/emacs-29
648a5e33e8 Update to Org 9.6.8-3-g21171d
458442fe78 Escape percent character in treesit--inspect-name (bug#65...
bc0426ce8e Don't add an extraneous slash in remote PATH list in Eshell
34f7a47c9c Fix Tramp on MS Windows
ea5fd6c96b * Fix native disassemble on Windows platforms (bug#65455)
91d2d8439b * Handle missing eln file when trying to disassble (bug#6...
e7ac50a153 * lisp/emacs-lisp/comp.el (comp--native-compile): Fix OUT...
45cf3a0ced Update to Transient v0.4.3
31d3808fb9 Adapt Eshell manual
0c50af054f Fix applying patches with Git on MS-Windows

# Conflicts:
#	doc/misc/transient.texi
#	test/lisp/eshell/esh-util-tests.el
2023-09-02 04:28:17 -04:00
Eli Zaretskii
34414b06f2 ; Minor fixes of treesit docs
* src/treesit.c (treesit_traverse_validate_predicate)
(Ftreesit_search_subtree, Ftreesit_search_forward)
(Ftreesit_induce_sparse_tree, Ftreesit_node_match_p):
* lisp/treesit.el (treesit-beginning-of-thing)
(treesit-end-of-thing, treesit--things-around): Fix commentary and
doc strings.
2023-09-02 10:08:21 +03:00
Yuan Fu
50f21afd71
Fix treesit-thing-definition
* lisp/treesit.el (treesit-thing-definition): Add LANGUAGE parameter.
(treesit-major-mode-setup): Update treesit-thing-definition.  Don't
enable tree-sitter sexp transpose if sexp isn't defined.
2023-09-01 22:30:21 -07:00
Yuan Fu
e6340934d6
; * lisp/treesit.el (treesit-thing-settings): Declare in treesit.el. 2023-09-01 21:02:36 -07:00
Yuan Fu
7fc416d90b
Don't signal error when calling treesit-node-match-p in treesit.el
Specifically, don't signal error when the thing isn't defined.

* lisp/treesit.el (treesit-node-top-level)
(treesit-forward-sentence)
(treesit--things-around): Add IGNORE-MISSING argument.
2023-09-01 20:38:32 -07:00
Yuan Fu
ed152ccd1d
Rename PRED to THING in tree-sitter navigation functions
The primary way to use these functions should be to supply a thing
symbol. Change the parameter name to THING to reflect that.

* lisp/treesit.el (treesit-beginning-of-thing)
(treesit-end-of-thing)
(treesit--things-around)
(treesit--navigate-thing)
(treesit-thing-at-point): Change parameter.
2023-09-01 20:38:31 -07:00
Yuan Fu
2547fbe9c4
Obsolete treesit-block/sexp/sentence/text-type-regexp
And replace them with treesit-thing-settings.

* doc/lispref/positions.texi (List Motion): Remove mention of
treesit-sexp/sentence-type-regexp.

* lisp/progmodes/c-ts-mode.el (c-ts-base-mode)
* lisp/progmodes/dockerfile-ts-mode.el (dockerfile-ts-mode)
* lisp/progmodes/java-ts-mode.el (java-ts-mode)
* lisp/progmodes/js.el (js-ts-mode)
* lisp/progmodes/json-ts-mode.el (json-ts-mode)
* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode)
* lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode)
(tsx-ts-mode)
* lisp/progmodes/heex-ts-mode.el (heex-ts-mode)
* lisp/progmodes/sh-script.el (bash-ts-mode)
* lisp/progmodes/prog-mode.el (prog-fill-reindent-defun)
* lisp/textmodes/html-ts-mode.el (html-ts-mode): Replace
treesit-sexp/sentence/text-type-regexp with treesit-thing-settings.

* lisp/treesit.el (treesit-sexp-type-regexp)
(treesit-sentence-type-regexp): Mark obsolete.
(treesit-block-type-regexp): Remove.

* lisp/treesit.el (treesit-forward-sexp)
(treesit-transpose-sexps)
(treesit-beginning-of-defun)
(treesit-end-of-defun)
(treesit-forward-sentence)
(treesit-defun-at-point): Make use of treesit-thing-settings.

(treesit-thing-definition)
(treesit-thing-defined-p): New functions.

(treesit-major-mode-setup): Replace
treesit-sexp/sentence-type-regexp with treesit-thing-settings.
2023-09-01 20:38:25 -07:00
Yuan Fu
458442fe78
Escape percent character in treesit--inspect-name (bug#65540)
* lisp/treesit.el (treesit-inspect-node-at-point): Escape percent.
2023-08-27 14:50:43 -07:00
Basil L. Contovounesios
8ffe8422c5 Minor tree-sitter cleanups
* lisp/treesit.el (treesit-fontify-with-override): Fix docstring
grammar.  Remove redundant precondition (bug#64052).
* src/treesit.c (Ftreesit_parser_set_included_ranges): Fix typo in
commentary.
(treesit_predicate_equal, treesit_predicate_match)
(treesit_predicate_pred): Avoid fixnum roundtrip by using
list_length in place of Flength.  Make error messages more accurate.
(treesit_eval_predicates): Quote predicate names in error message.
2023-07-08 17:05:05 +01:00
Eli Zaretskii
0006245f1d Merge from origin/emacs-29
ef16339918 Make js-beginning-of-defun return non-nil on success
2c90ade09a Tree-sitter use with-silent-modifications like jit-lock (...
11cead0d73 Fix todo-mode.el Commentary and a doc string (bug#64298)
6ae83322d4 Prevent truncation of todo-mode categories sexp
ee41f07be5 Avoid making todo-mode buffers manually editable
53332bdf62 ; * doc/lispref/variables.texi: Fix define-obsolete-varia...
162c9c058e ; Document that 'named-let' needs lexical-binding
68028f0fa3 ; * etc/PROBLEMS: Fix typo.
2023-07-01 06:29:43 -04:00
Yuan Fu
361bf8a113
Use OUT-DIR in treesit-install-language-grammar (bug#64295)
* lisp/treesit.el (treesit-install-language-grammar): Use out-dir.
2023-06-29 11:28:18 -07:00
Yuan Fu
2c90ade09a
Tree-sitter use with-silent-modifications like jit-lock (bug#64321)
* lisp/treesit.el (treesit--font-lock-notifier): Use
with-silent-modifications when marking modified text to be fontified
by jit-lock.  This is what jit-lock itself does.
2023-06-27 20:58:34 -07:00
Eli Zaretskii
d1ddd1d5d9 Merge from origin/emacs-29
84d2da003e ; Fix example in the Flymake manual
0a1459f1d9 * doc/misc/calc.texi (Advanced Math Functions): Correct c...
92faf1f564 Consider 'dired-kill-when-opening-new-dired-buffer' in mo...
bafe71a69f ; Fix use-package.texi markup
018e4ca6c5 ; * doc/misc/calc.texi (Advanced Math Functions): Fix las...
1952dbd4c5 Fix Gamma function definition in calc.texi
f73f82d7e8 Fix subscripts in the Calc manual
70fc7c41ef Improve documentation of 'declare' forms
c835758238 ; * src/lread.c (bytecode_from_rev_list): Avoid C++ comment.
2847857496 Improve tree-sitter docs
0e9307eb2b Fix some Texinfo markup in manuals
8dc08333ee Fix bol/bos anchors in tree-sitter :match regexps
8225ade615 ; * src/xdisp.c (syms_of_xdisp) <display-line-numbers>: F...
1f0527a312 ; Fix last change in tex-mode.el
4da479920e * lisp/subr.el (with-restriction): Tweak indent rule
36aa9bd818 ; Fix previous change
aaeaf608d8 Fix setting region in the minibuffer
1383efe01d Fix setting $DBUS_SESSION_BUS_ADDRESS after Emacs has sta...
bdb0bc2b4e Fix tex-mode display-buffer issues
90047c38ce Add test for when 'completion-auto-help' is 'visible'
2c623e4feb Avoid errors in 'apropos-documentation' after 'eval-buffer'
dd3b98121c ; * doc/emacs/indent.texi (Indentation Commands): Fix las...
904edf1f07 Mention indent-rigidly in the Emacs manual
2023-06-17 05:02:55 -04:00
Yuan Fu
ad3ec429a1
Fix treesit-install-language-grammar (bug#63990)
* lisp/treesit.el:
(treesit-install-language-grammar): When called non-interactively,
out-dir should default to default-out-dir.
2023-06-15 01:22:53 -07:00
Basil L. Contovounesios
2847857496 Improve tree-sitter docs
* doc/lispref/positions.texi (List Motion): Incorporate more
accurate description of treesit-defun-type-regexp from
'(elisp) Tree-sitter Major Modes', replacing that duplicate
entry (bug#64018).

* doc/lispref/parsing.texi (Parsing Program Source)
(Language Grammar, Using Parser, Retrieving Nodes)
(Accessing Node Information, Pattern Matching, Multiple Languages):
(Tree-sitter Major Modes):
* doc/lispref/modes.texi (Parser-based Font Lock): Improve wording,
grammar, punctuation, and markup.  Fix typos.
(Parser-based Indentation): Ditto.  Document indent rule presets
field-is, catch-all, nth-sibling, grand-parent, and
great-grand-parent.

* lisp/treesit.el (treesit-simple-indent-presets): Mention field-is,
catch-all, nth-sibling, grand-parent, great-grand-parent in
docstring.
(treesit-major-mode-setup, treesit-explore-mode): Improve
docstring/commentary grammar.
2023-06-13 17:22:16 +01:00
Eli Zaretskii
85af52bacd Merge from origin/emacs-29
3f44152567 Save the tree-sitter grammar recipe when installing a gra...
c0c7b947ba Add instructions and test file for VS-15/VS-16
3be33aff96 A better fix for "Fix cancellation of Wdired"
756244c696 ; * lisp/minibuffer.el (completions-header-format): Doc fix.
5d844e129a Fix tmm-menubar when 'tmm-completion-prompt' is nil

# Conflicts:
#	lisp/treesit.el
2023-06-03 05:50:49 -04:00
Yuan Fu
3f44152567
Save the tree-sitter grammar recipe when installing a grammar
Raised in bug#63750, but not the main subject of it.

* lisp/treesit.el (treesit-install-language-grammar): Save the recipe
to treesit-language-source-alist when installation is successful.
2023-05-28 15:34:25 -07:00
Yuan Fu
156973639c
Implement treesit-forward-sexp correctly (bug#63487)
* lisp/treesit.el (treesit-forward-sexp): Signal scan-error when we
can't move across sexps further.
2023-05-19 00:20:33 -07:00
Eli Zaretskii
f518543aa4 Merge from origin/emacs-29
f8d9e40d2c Attempt to fix redisplay problems on macOS
4daa6f7049 ; * lisp/simple.el (async-shell-command): Add commentary ...
dc1a437d46 Clarify misleading comment in isearch.el
af3b0dc53f Improve documentation of package-menu commands
d879847cd4 Fix M-x completion-predicate under python-ts-mode
1e57b2b4c7 * Account for `byte-compile-warnings' during native compi...
b5bfd808c6 Avoid duplicate VC packages in 'package-selected-packages'
c18f9f155f * lisp/tab-bar.el (tab-bar-new-tab-to): Set 'window-side'...
33485fe8f7 ; Better warning message when loading tree-sitter fails
95a724abaa Update to Org 9.6.6
c665ca79ff ; * admin/make-tarball.txt: Minor copyedits.
3aef46e466 Merge branch 'emacs-29' of git.sv.gnu.org:/srv/git/emacs ...
229af8e4b3 ; * lisp/progmodes/csharp-mode.el (csharp-ts-mode--defun-...
2023-05-18 07:49:49 -04:00
Eli Zaretskii
33485fe8f7 ; Better warning message when loading tree-sitter fails
* lisp/treesit.el (treesit-ready-p): Improve diagnostics on
MS-Windows when the tree-sitter library cannot be loaded at run
time.
2023-05-15 18:39:49 +03:00
Stefan Monnier
e4c8ba6c05 Merge branch 'emacs-29' 2023-05-10 11:18:43 -04:00
Mattias Engdegård
a85609c22d ; * lisp/treesit.el (treesit-node-top-level): cleaner and faster 2023-05-09 13:28:20 +02:00
Yuan Fu
b625ccff87
Fix treesit-node-top-level (bug#63374)
* lisp/treesit.el (treesit-node-top-level): Fix the use of
rx-to-string.
2023-05-08 12:59:54 -07:00
Eli Zaretskii
910a7b30df Fix beginning/end-of-defun with tree-sitter
* lisp/treesit.el (treesit-beginning-of-defun)
(treesit-end-of-defun): Push mark, as other beginning/end-of-defun
functions do.
2023-05-07 09:13:10 +03:00
Eli Zaretskii
9b66a64d9c Fix interactive forms in some Lisp packages
* lisp/woman.el (woman-reset-emulation):
* lisp/treesit.el (treesit--explorer-jump):
* lisp/speedbar.el (speedbar-toggle-etags):
* lisp/filesets.el (filesets-convert-patterns):
* lisp/calculator.el (calculator-saved-move):
* lisp/progmodes/gud.el (gud-basic-call):
* lisp/progmodes/ebrowse.el (ebrowse-redraw-marks)
(ebrowse-view-file-other-frame):
* lisp/progmodes/dcl-mode.el (dcl-indent-to):
* lisp/net/socks.el (socks-open-connection):
* lisp/net/ntlm.el (ntlm-build-auth-request):
* lisp/emacs-lisp/backtrace.el (backtrace-expand-ellipsis):
* lisp/calc/calc-prog.el (calc-edit-macro-finish-edit):
* lisp/calc/calc-misc.el (calc-info-goto-node):
* lisp/net/dictionary.el (dictionary-new-search)
(dictionary-definition, dictionary-switch-tooltip-mode): Fix
interactive functions where the 'interactive' form did not supply
the mandatory arguments.  (Bug#62864)
2023-05-06 11:29:58 +03:00
Po Lu
a97c382682 Merge from origin/emacs-29
a40f181623 Fix two crashes upon startup
44ebd9cbd5 Eglot: explain how to update Eglot in manual (bug#62720)
941ef044f2 Eglot: fix edge case when deleting inlay hint overlays
a365984d9e package-upgrade[-all]: Expand docstrings to note the curr...
f965f35b33 Rename all functions called package-*-update-* to package...
31b58161bb Fix FOR_EACH_TAIL in c-ts-mode (bug#62951)
0cf6e0998b * Makefile.in (distclean): Remove the 'native-lisp' direc...
933705d61e Improve greek-ibycus4 input method

# Conflicts:
#	etc/NEWS
2023-04-28 11:51:01 +08:00
Eli Zaretskii
0cf6e0998b * Makefile.in (distclean): Remove the 'native-lisp' directory. 2023-04-27 21:39:33 +03:00
Yuan Fu
cc0f9389b8
Fix treesit-install-language-grammar for non-interactive call
A continuation of bug#62704.

* lisp/treesit.el (treesit-install-language-grammar): Differentiate
between interactive and non-interactive call, and don't prompt when
it's called non-interactively.
2023-04-19 16:25:48 -07:00