* 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.
Yuan Fu [Tue, 11 Oct 2022 16:30:42 +0000 (09:30 -0700)]
Lazily compile tree-sitter query
See comment on struct Lisp_TS_Query for why. Previous commits adding
python and js support for tree-sitter breaks Emacs build if language
definitions aren't available at build time. This commit fixes that.
Now query object don't compile the query upon creation, but stores the
query source and language symbol, and compiles upon first use (in
treesit-query-capture).
I want ts_ensure_query_compiled to return signal symbol and data
rather than signaling itself, because it's a helper function not lisp
function. But because it calls ts_load_language, I had to update
ts_load_language to also use the signal symbol/data interface.
* src/treesit.h (struct Lisp_TS_Query): Add two new field.
* src/treesit.c (ts_load_language): Return signal symbol and data
rather than signaling itself.
(Ftreesit_langauge_available_p)
(Ftreesit_parser_create): Update usage of ts_load_language
(make_ts_query): Now returns a lisp object.
(ts_query_error_to_string): Moved because it's used by
ts_compose_query_signal_data.
(ts_compose_query_signal_data)
(ts_ensure_query_compiled): New functions.
(Ftreesit_query_compile): Delay compiling the query.
(Ftreesit_query_capture): Instead of creating a query object which
compiles the query, now goes two routes: if QUERY is a query object,
make sure it is compiled and use the TSQuery; if QUERY is a cons or
string, compile directly to TSQuery, and free it after use. Creating
a lisp query requires the language symbol, but in this function we
only have TSLanguage.
Yuan Fu [Mon, 10 Oct 2022 18:56:12 +0000 (11:56 -0700)]
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.
Yuan Fu [Sun, 9 Oct 2022 22:17:11 +0000 (15:17 -0700)]
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.
Justus Winter [Wed, 5 Oct 2022 10:36:39 +0000 (12:36 +0200)]
Replace aging OpenPGP artifacts in gnus' mml-sec tests.
This replaces the old OpenPGPv4 keys that are used in the test suite
with more modern OpenPGPv4 keys.
Having old cryptographic artifacts in the test suite presents a
problem once the old algorithms are rejected by contemporary
implementations (bug#58301).
Replace aging OpenPGP artifacts in the package-resources tests.
This replaces the old OpenPGPv4 key that is used in the test suite
with a more modern OpenPGPv4 key. The key is the Alice key from
https://datatracker.ietf.org/doc/draft-bre-openpgp-samples/. All
cryptographic artifacts in the test suite are updated accordingly.
Having old cryptographic artifacts in the test suite presents a
problem once the old algorithms are rejected by contemporary
implementations.
This replaces the old OpenPGPv4 key that is used in the test suite
with a more modern OpenPGPv4 key. The key is the Alice key from
https://datatracker.ietf.org/doc/draft-bre-openpgp-samples/. All
cryptographic artifacts in the test suite are updated accordingly.
Having old cryptographic artifacts in the test suite presents a
problem once the old algorithms are rejected by contemporary
implementations.
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.
Manuel Giraud [Thu, 6 Oct 2022 12:46:39 +0000 (14:46 +0200)]
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).
Matt Armstrong [Thu, 6 Oct 2022 12:08:20 +0000 (14:08 +0200)]
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).
Po Lu [Thu, 6 Oct 2022 02:55:25 +0000 (10:55 +0800)]
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.
Yuan Fu [Wed, 5 Oct 2022 21:11:33 +0000 (14:11 -0700)]
Add tree-sitter admin notes
starter-guide: Guide on writing major mode features.
build-module: Script for building official language definitions.
html-manual: HTML version of the manual for easy access.
* admin/notes/tree-sitter/build-module/README: New file.
* admin/notes/tree-sitter/build-module/batch.sh: New file.
* admin/notes/tree-sitter/build-module/build.sh: New file.
* admin/notes/tree-sitter/starter-guide: New file.
* admin/notes/tree-sitter/html-manual/Accessing-Node.html: New file.
* admin/notes/tree-sitter/html-manual/Language-Definitions.html: New file.
* admin/notes/tree-sitter/html-manual/Multiple-Languages.html: New file.
* admin/notes/tree-sitter/html-manual/Parser_002dbased-Font-Lock.html:
New file.
* admin/notes/tree-sitter/html-manual/Parser_002dbased-Indentation.html:
New file.
* admin/notes/tree-sitter/html-manual/Parsing-Program-Source.html: New
file.
* admin/notes/tree-sitter/html-manual/Pattern-Matching.html: New file.
* admin/notes/tree-sitter/html-manual/Retrieving-Node.html: New file.
* admin/notes/tree-sitter/html-manual/Tree_002dsitter-C-API.html: New
file.
* admin/notes/tree-sitter/html-manual/Using-Parser.html: New file.
* admin/notes/tree-sitter/html-manual/build-manual.sh: New file.
* admin/notes/tree-sitter/html-manual/manual.css: New file.
Stefan Kangas [Wed, 5 Oct 2022 13:23:39 +0000 (15:23 +0200)]
Add face help-key-binding in help-char echo
* src/keyboard.c (echo_add_key): Add help-key-binding face to the
"?" key in 'help-char' echo. (Bug#57906)
(syms_of_keyboard) <Qhelp_key_binding>: New DEFSYM.
Po Lu [Wed, 5 Oct 2022 00:31:44 +0000 (08:31 +0800)]
Fix bug in "macintization" of x_draw_glyph_string
* src/nsterm.m (ns_draw_stretch_glyph_string): Restore text decoration
drawing code ommitted during "macintization" to convert the X function
into NS code. Reported by Qiantan Hong <qthong@stanford.edu>.
Yuan Fu [Tue, 4 Oct 2022 20:28:46 +0000 (13:28 -0700)]
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.
Yuan Fu [Sun, 2 Oct 2022 03:25:25 +0000 (20:25 -0700)]
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.
src/comp.c: Use libgccjit's bitcast API for type coercion, when available.
* (type_to_cast_index, define_type_punning, define_cast_from_to,
define_cast_functions): Define functions when
gcc_jit_context_new_bitcast is not available.
* (emit_coerce): Use gcc_jit_context_new_bitcast to coerce types, when
available.
Brian Cully [Tue, 4 Oct 2022 16:56:23 +0000 (18:56 +0200)]
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.
Alan Mackenzie [Tue, 4 Oct 2022 16:19:33 +0000 (16:19 +0000)]
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.
Stefan Kangas [Tue, 4 Oct 2022 15:36:09 +0000 (17:36 +0200)]
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.
Improve manual display tests of undisplayable chars (bug#58168)
Test display of multibyte raw bytes, as well as undisplayable
multibyte chars (C1 controls and other values).
The test still assumes that raw bytes should be displayed identically
to undisplayable characters (such as C1 controls) because that is how
the display code currently works.
* test/manual/redisplay-testsuite.el (test-redisplay-5-toggle)
(test-redisplay-5): Fix likely typo (#x3fffc) of raw byte value.
(test-redisplay-6): New.
* 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.
Alan Mackenzie [Tue, 4 Oct 2022 13:22:32 +0000 (13:22 +0000)]
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.
* 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.
Denys Nykula [Tue, 4 Oct 2022 12:17:38 +0000 (14:17 +0200)]
Add Ukrainian tutorial
* etc/tutorials/TUTORIAL.uk: Create the translation.
* lisp/language/cyrillic.el: Link "Emacs Tutorial"
to the translation if the system is Ukrainian, and
add our modern greeting as a sample text.
* etc/NEWS:
* etc/tutorials/TUTORIAL.translators: Attribute my work (bug#55250).
Po Lu [Tue, 4 Oct 2022 01:25:06 +0000 (09:25 +0800)]
Fix deiconification handling on FVWM and possibly other window managers
I can't believe we weren't doing this before.
* src/xterm.c (x_handle_wm_state): New function.
(handle_one_xevent): Handle window state changes in WM_STATE
messages, and use them for signalling deiconification.
(bug#58164)
Stefan Kangas [Mon, 3 Oct 2022 22:07:22 +0000 (00:07 +0200)]
Merge from origin/emacs-28
992611b10a Fix documentation of 'TAB' in cc-mode 08e485a2a5 Fix 'org-export-dispatch' command name in manual e5a49f44ff * src/emacs.c (load_pdump): Fix use of xpalloc. 7ff5207624 Avoid assertion violation in 'xpalloc'
Juri Linkov [Mon, 3 Oct 2022 19:54:16 +0000 (22:54 +0300)]
* lisp/repeat.el (repeat-exit-key): Replace type 'key-sequence' with 'key'.
(repeat-post-hook, repeat-echo-message-string): Add backward-compatibility
code for repeat-exit-key to keep support for 'key-sequence' type (bug#55986).
Juri Linkov [Mon, 3 Oct 2022 19:51:33 +0000 (22:51 +0300)]
* lisp/repeat.el (repeat-exit): New command.
(repeat-exit-function): New variable.
(repeat-post-hook): Set repeat-exit-function.
Call repeat-exit from run-with-idle-timer.
Also use repeat--exit.
(repeat--exit): New internal function.