Commit graph

87174 commits

Author SHA1 Message Date
Yuan Fu
170924e945
Fix js/ts tree-sitter template_string font-lock
* lisp/progmodes/js.el (js--treesit-settings): Fontify
template_strings with js--fontify-template-string.
(js--fontify-template-string): New function.
(js--json-treesit-settings): Add missing :feature flag.
* lisp/progmodes/ts-mode.el (ts-mode--settings): Fontify
template_strings with js--fontify-template-string.
2022-10-17 01:48:50 -07:00
Yuan Fu
bd13ce184b
* lisp/treesit.el (treesit-font-lock-rules): Warn about :feature. 2022-10-17 01:48:50 -07:00
Eli Zaretskii
9d3f8912b4 Support MinGW build on MS-Windows
* src/treesit.c [WINDOWSNT]: Add MS-Windows boilerplate for
dynamically-loaded optional libraries.
(init_treesit_functions) [WINDOWSNT]: New function.
(load_tree_sitter_if_necessary): New function.
(ts_initialize): Call 'load_tree_sitter_if_necessary'.
(ts_delete_parser, ts_delete_query, ts_named_node_p): Wrapper
functions for TS calls from outside treesit.c.
(Ftreesit_parser_root_node, Ftreesit_parser_set_included_ranges)
(Ftreesit_parser_included_ranges, Ftreesit_node_type)
(Ftreesit_node_start, Ftreesit_node_end, Ftreesit_node_string)
(Ftreesit_node_parent, Ftreesit_node_child, Ftreesit_node_check)
(Ftreesit_node_field_name_for_child, Ftreesit_node_child_count)
(Ftreesit_node_next_sibling, Ftreesit_node_prev_sibling)
(Ftreesit_node_first_child_for_pos)
(Ftreesit_node_descendant_for_range, Ftreesit_node_eq)
(Ftreesit_query_compile, Ftreesit_query_capture)
(Ftreesit_search_subtree, Ftreesit_search_forward)
(Ftreesit_induce_sparse_tree): Call 'ts_initialize' before any
other TS functions.
(Ftreesit_available_p): 'treesit-available-p' implemented in C, so
that on WINDOWSNT the library could be loaded dynamically.
* src/treesit.h (ts_delete_parser, ts_delete_query)
(ts_named_node_p): Add prototypes.
* src/print.c (print_vectorlike):
* src/alloc.c (cleanup_vector): Call tree-sitter function via
wrappers defined in treesit.c, not directly, because WINDOWSNT
redefines the TS functions to be called via function pointers.
* src/Makefile.in (base_obj): Add treesit.o
(TREE_SITTER_OBJ): Remove.

* lisp/treesit.el (treesit-available-p): Remove: now implemented
in C.
* lisp/term/w32-win.el (dynamic-library-alist): Add libtree-sitter
DLLs.

* configure.ac (TREE_SITTER): Support the MinGW build.
(TREE_SITTER_OBJ): Remove.
2022-10-16 16:22:09 +03:00
Yuan Fu
f1e058d46b
Update ts-mode font-lock to work with tree-sitter's :feature
* lisp/progmodes/ts-mode.el (ts-mode--settings): Add :feature flag.
(ts-mode): Set treesit-font-lock-feature-list.
2022-10-15 16:09:35 -07:00
Yuan Fu
af288d813b
Rework tree-sitter font-lock
Remove :toggle and :level, add :feature.

* lisp/progmodes/js.el (js--treesit-settings): Add :feature.
(js--treesit-enable): Set treesit-font-lock-feature-list.
* lisp/progmodes/python.el: Replace :level with :feature.
(python-mode): Set treesit-font-lock-feature-list.
* lisp/treesit.el (treesit-font-lock-feature-list): New variable.
(treesit-font-lock-settings): Change format.
(treesit-font-lock-rules): Remove :toggle and :level, add :feature.
(treesit-font-lock-recompute-features): New function.
(treesit-font-lock-fontify-region): Change to work with the new
format.
(treesit-font-lock-enable): Add call to
treesit-font-lock-recompute-features.  And improve the font-lock-mode
workaround.
2022-10-13 14:44:42 -07:00
Yuan Fu
77f1533ccb
; Comment and docstring fixup in ts-mode.el
* lisp/progmodes/ts-mode.el: Add comment section and docstrings.
2022-10-11 23:49:04 -07:00
Theodor Thornhill
45b8204e09
Add TypeScript support with tree-sitter
* lisp/progmodes/ts-mode.el (ts-mode): New major mode for TypeScript
with support for tree-sitter.  It uses the TSX parser, so that we get
support for TSX as well as TypeScript.  If we cannot find tree-sitter,
we default to using js-mode.
2022-10-11 23:41:53 -07:00
Theodor Thornhill
c4179117af
Fix byte-compile warning for js--treesit-defun-type-regexp
* lisp/progmodes/js.el (js--treesit-defun-type-regexp): Move before
js--treesit-beginning-of-defun.
2022-10-11 11:45:50 -07:00
Yuan Fu
1bb7b43e1c
Make treesit-node-at faster
* lisp/treesit.el (treesit-node-at): We only need to use
treesit-node-first-child-for-pos.  This is both faster for large
buffers and simpler.  Also remove the TODO comment.
2022-10-10 11:57:24 -07:00
Theodor Thornhill
c8909fa368
Fix typo in treesit--check-manual-covarage
* lisp/treesit.el (treesit--check-manual-coverage): Fix typo in
function name and also lookup the correct library in
`find-library-name'
2022-10-10 11:31:20 -07:00
Yuan Fu
b341864d90
Improve treesit-search-forward-goto so it doens't stuck at EOF
* lisp/treesit.el (treesit-search-forward-goto): Handle the edge case.
2022-10-10 11:14:35 -07:00
Yuan Fu
2a762336da
Fix js--treesit-beginning/end-of-defun
* lisp/progmodes/js.el (require): Add rx.
(js--treesit-move-to-node): Remove function.
(js--treesit-beginning-of-defun)
(js--treesit-end-of-defun): Change to use treesit-search-forward-goto.
(js-treesit--defun-query): Remove variable.
(js--treesit-defun-type-regexp): Add variable.
2022-10-10 10:46:47 -07:00
Theodor Thornhill
ceb9591e5d
Add tree-sitter functionality to js-mode
The diff for js-mode, js-json-mode, js-jsx-mode are a bit strange, but
all we did is to wrap some the old code in

(if tree-sitter
  (tree-sitter-enable)
 ...some old-code)

...other old-code (that’s tree-sitter-agnostic)

* lisp/progmodes/js.el (treesit): Add tree-sitter dependency
(js-use-treesitter)
(js-json-use-treesitter): New custom options.

(js--treesit-keywords)
(js--treesit-settings)
(js--treesit-indent-rules)
(js--json-treesit-settings)
(js--json-treesit-indent-rules): New variables.

(js--treesit-backward-up-list)
(js-treesit-current-defun)
(js--treesit-move-to-node)
(js--treesit-beginning-of-defun, js--treesit-end-of-defun)
(js--treesit-enable)
(js--json-treesit-enable): New functions.

(js-mode, js-json-mode, js-jsx-mode): Add support for tree-sitter
functionalities.
2022-10-10 10:25:50 -07:00
Yuan Fu
b6568c1389
Rename custom group treesit to tree-sitter
* lisp/treesit.el (treesit): Rename.
2022-10-09 20:59:59 -07:00
Yuan Fu
aaaa4ca77e
Add :version tag for new tree-sitter custom options
* lisp/progmodes/python.el (python-use-tree-sitter): Add version tag.
* lisp/treesit.el (treesit):
(treesit-max-buffer-size): Add version tag.
2022-10-09 20:54:19 -07:00
Yuan Fu
bb8376145a
Make python tree-sitter font-lock support decoration levels
* lisp/progmodes/python.el (python--treesit-settings): Stratify into
three levels.
2022-10-09 17:20:40 -07:00
Yuan Fu
c88a1631e3
Make tree-sitter font-lock support decoration levels
* admin/notes/tree-sitter/html-manual/Parser_002dbased-Font-Lock.html:
Update.
* admin/notes/tree-sitter/html-manual/Parsing-Program-Source.html:
Update.
* doc/lispref/modes.texi: Mention the new :level option.
* lisp/treesit.el (treesit-font-lock-settings): Update docstring.
(treesit-font-lock-rules): Support :level.  Relayout the let form.
(treesit-font-lock-fontify-region): Support :level.
2022-10-09 17:20:28 -07:00
Yuan Fu
8bc6e31502
Add a :toggle option for tree-sitter font-lock
* admin/notes/tree-sitter/html-manual/Parser_002dbased-Font-Lock.html:
Update html manual.
* admin/notes/tree-sitter/html-manual/build-manual.sh: Fix manual
path.
* admin/notes/tree-sitter/starter-guide: Mention :toggle.
* doc/lispref/modes.texi: Mention :toggle.
* lisp/treesit.el (treesit-font-lock-settings): Update docstring.
(treesit-font-lock-rules): Handle :toggle.  Also change
some wrong-type-argument signal to treesit-font-lock-error which is
easier to understand.
(treesit-font-lock-fontify-region): Handle :toggle.
2022-10-07 01:21:09 -07:00
Yuan Fu
cea1e95d38
Merge branch 'master' into feature/tree-sitter 2022-10-06 11:06:07 -07:00
Arash Esbati
0c65c9dfb3 Pass correct environment name to `reftex-label'
* lisp/textmodes/tex-mode.el (latex-block-body-alist): Pass
"figure" to `reftex-label' when inserting a figure float.
(bug#58329)
2022-10-06 19:45:44 +02:00
Justus Winter
82388dff8e Fix epg's reliance on an implicit GnuPG command.
Previously, epg invoked GnuPG without an explicit command to verify
signatures.  Make that operation explicit.  Happily, this aligns how
gpg and gpgsm is invoked, so it actually makes the code simpler.
2022-10-06 14:53:36 +02:00
Manuel Giraud
07b2e9b909 Fix BSD battery mode over TRAMP (bug#58307)
* lisp/battery.el (battery--call-process-to-string): Simple wrapper
to `call-process' that outputs to a string.
(battery-bsd-apm): Use it instead of `shell-command-to-string'
(bug#58307).
2022-10-06 14:46:39 +02:00
Matt Armstrong
e24f276f8a Fix calling `package-reinstall' just after quick initialization.
* lisp/emacs-lisp/package.el (package-reinstall): call
`package--archives-initialize', just like `package-install' does.
This populates `package-alist', and so fixes calling
`package-reinstall' as the first thing done after package "quick
init" (Bug#53527).
2022-10-06 14:08:20 +02:00
Po Lu
8e8d37aa32 Minor fixes to IM locale handling
* lisp/term/x-win.el (x-get-input-coding-system): Translate locales.
* src/xterm.c (x_term_init): If the X library doesn't support
the current locale, don't set up input methods.
2022-10-06 10:56:27 +08:00
Yuan Fu
7ebbd4efc3
Merge branch 'master' into feature/tree-sitter 2022-10-05 14:22:03 -07:00
Juri Linkov
95efafb726 * lisp/repeat.el (repeat-exit): Add autoload cookie. 2022-10-05 22:47:42 +03:00
Stefan Kangas
10ec1a4d7e New command 'world-clock-copy-time-as-kill'
* lisp/time.el (world-clock-copy-time-as-kill): New command.
(world-clock-mode-map): Bind above new command to "w".
2022-10-05 16:33:23 +02:00
Stefan Kangas
1720ebecc7 ; * lisp/files.el (find-file-noselect): Minor simplification. 2022-10-05 15:08:01 +02:00
Filipp Gunbin
a259d0dda3 Add tramp-kubernetes integration
* doc/misc/tramp.texi (Inline methods): Add kubernetes.
(Customizing Methods): Remove kubernetes-tramp.
* etc/NEWS: Mention new Tramp method "kubernetes".
* lisp/net/tramp-compat.el (kubernetes-tramp): Warn if that package is
used.
* lisp/net/tramp-container.el (tramp-kubernetes-program): New
defcustom.
(tramp-kubernetes-method): New defconst.
(tramp-kubernetes--completion-function): New function.
2022-10-05 03:10:06 +03:00
Filipp Gunbin
e4e9cb265c Rename lisp/net/tramp-docker.el to lisp/net/tramp-container.el 2022-10-05 02:16:36 +03:00
Yuan Fu
1ea503ed4b
Add :override flag for python tree-sitter font-lock settings
* lisp/progmodes/python.el (python--treesit-settings): Add :override.
2022-10-04 13:30:56 -07:00
Yuan Fu
23bb724c92
Add :override flag for tree-sitter font-lock
* doc/lispref/modes.texi (Parser-based Font Lock): Update manual.
* lisp/treesit.el (treesit-font-lock-settings): Update docstring.
(treesit-font-lock-rules): Handle :override.
(treesit-font-lock-fontify-region): Handle :override.  Also set
inhibit-point-motion-hooks to t.
2022-10-04 13:30:56 -07:00
Yuan Fu
253126bf33
Fix python tree-sitter font-lock
Add fontification for lhs attribute and some operators.

* lisp/progmodes/python.el (python--treesit-keywords): Add operators.
(python--treesit-settings): Add lhs attribute.
2022-10-04 13:30:56 -07:00
Yuan Fu
10f96a8c57
Improve documentation of tree-sitter search functions
* doc/lispref/parsing.texi (Retrieving Node): Update manual.
* src/treesit.c (treesit-search-subtree)
(treesit-search-forwardn)
(treesit-induce-sparse-tree): Mention case-insensitivity.
* lisp/treesit.el (treesit-simple-indent): Mention case-insensitivity.
2022-10-04 13:30:56 -07:00
Yuan Fu
9b5ecffeb0
Ignore some capture name in treesit-font-lock-fontify-region
* doc/lispref/modes.texi (Parser-based Font Lock): Update manual.
* lisp/treesit.el: (treesit-font-lock-fontify-region): Ignore names
that are not face nor function.
(treesit-font-lock-rules): Update docstring.
2022-10-04 13:30:55 -07:00
Yuan Fu
6a3caeab58
Remove treesit-query-in
Because treesit-query-capture can now do everything it does.

* doc/lispref/parsing.texi (Pattern Matching): Update manual.
* lisp/treesit.el (treesit-query-in): Remove function.
* src/treesit.c (Ftreesit_query_capture): Accept parser and language
symbol as NODE.
2022-10-04 13:30:52 -07:00
Lars Ingebrigtsen
92df7cd923 Add 'seq-keep'
* doc/lispref/sequences.texi (Sequence Functions): Document it.
* lisp/emacs-lisp/seq.el (seq-keep): New function (bug#58278).
2022-10-04 21:44:52 +02:00
Eli Zaretskii
1d3d87cd67 ; * lisp/simple.el (cursor-face-highlight-mode): Doc fix. 2022-10-04 22:25:20 +03:00
Stefan Kangas
9eda89da55 Merge from origin/emacs-28
78c262e1c2 ; * lisp/progmodes/glasses.el (glasses-face): Expand the d...
2022-10-04 19:23:24 +02:00
Alan Mackenzie
9107176511 CC Mode: A new operator and some new keywords for C++20
* lisp/progmodes/cc-langs.el (c-operators, c-overloadable-operators)
(c-arithmetic-operators): Add the "spaceship" operator for C++.
(c-primitive-type-kwds): Add char8_t for C++.
(c-decl-hangon-kwds, c-paren-nontype-kwds): Add alignas for C++.
2022-10-04 17:19:33 +00:00
Brian Cully
4998d5bdf3 Provide Podman containers on their own method in Tramp
* lisp/net/tramp-docker.el (tramp-podman-program): New defcustom.
(tramp-podman-method): New defconst.
(tramp-docker-program): Remove "podman" from option list.
(top): Update comments to refer to Docker-alike where necessary.
Add description for how to use the podman method.
2022-10-04 18:56:23 +02:00
Alan Mackenzie
4bd8ad2bc5 CC Mode: Optimize c-fontify-new-found-type and amend a debug spec
* lisp/progmodes/cc-fonts.el (c-fontify-new-found-type): Write the `face'
property directly, rather than removing `fontified' properties and letting
font-lock do the work.

* lisp/progmodes/cc-defs.el (cc-eval-when-compile): Amend the debug spec from
t to (&rest body), in line with the fix to bug #16184.
2022-10-04 16:19:33 +00:00
Stefan Kangas
a36ecc408a * lisp/subr.el (y-or-n-p): Use substitute-command-keys. 2022-10-04 17:39:28 +02:00
Stefan Kangas
d9bd14975b image-dired: Shorten several long names
* lisp/image/image-dired.el (image-dired-image-mode-map)
(image-dired-image-mode): Rename from
'image-dired-display-image-mode-map' and
'image-dired-display-image-mode'.  Update all uses and make old
names into obsolete aliases.
(image-dired-display-this, image-dired-display-next)
(image-dired-display-previous): Rename from
'image-dired-display-thumbnail-original-image',
'image-dired-display-next-thumbnail-original', and
'image-dired-display-previous-thumbnail-original'.  Update all uses
and make old names into obsolete aliases.
* doc/emacs/dired.texi (Image-Dired): Update documentation for the
above changes, and improve indexing.
2022-10-04 17:36:09 +02:00
Stefan Kangas
f4252f3171 image-dired: Fix arrow keys in thumbs buffer
* lisp/image/image-dired.el (image-dired-thumbnail-mode-map): Also
remap 'left-char' and 'right-char'.
2022-10-04 16:18:20 +02:00
Eli Zaretskii
f0ee4c68f1 Fix recent changes for Ukrainian language
* etc/HELLO:
* lisp/language/cyrillic.el ("Ukrainian"): Fix greetings and
remove redundant Ukrainian entry in cyrillic.el.
2022-10-04 17:15:47 +03:00
Lars Ingebrigtsen
682662202d Make cropping of images work in message-mode
* lisp/gnus/message.el (message-mode): Set the image cropping function.
(message--yank-media-image-handler): Factor out...
(message--image-part-string): ... here for reuse.
(message--update-image-crop): Update the cropped data.
2022-10-04 15:41:02 +02:00
Alan Mackenzie
121c3d44be CC Mode: Make c-forward-declarator move over a suffix after parens, e.g. const
Also tidy up several inaccuracies in the code.

* lisp/progmodes/cc-engine.el (c-forward-decl-arglist): Move point for modes
other than C++ Mode.
(c-forward-declarator): Move over a suffix following arglist parens
(e.g. const).  Set the ARGLIST element of the return value to non-nil on
encountering an unbalanced open parenthesis.  Don't move forward out of
enclosing parens.

* lisp/progmodes/cc-mode.el (c-fl-decl-end): Handle being in a multi-line
string.  Move forward over token after declarator.
2022-10-04 13:22:32 +00:00
Lars Ingebrigtsen
9565f45876 Move image commands to the 'i' sub map
* doc/lispref/display.texi (Showing Images): Adjust.
* lisp/image.el (image-map): Move all keys under the "i" prefix.
(image--repeat-map): New map.
(image-increase-size, image-rotate, image-decrease-size): Make
repeatable.
(image--delayed-change-size): New function.
2022-10-04 15:09:33 +02:00
Lars Ingebrigtsen
07257ac4ee Fix the arguments in tags--compat-initialize
* lisp/progmodes/etags.el (tags--compat-initialize): Fix argument
order -- swap the last two arguments (bug#58272).
2022-10-04 14:32:11 +02:00