1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-13 23:10:26 -08:00
Commit graph

47333 commits

Author SHA1 Message Date
Yuan Fu
1cd42bfb8a
Fix memory leak in ts_load_language
* src/treesit.c (ts_load_language): Move initialization of c_name down
and free it right after use.
2022-10-17 13:52:31 -07:00
Eli Zaretskii
5a2c1a743b Make sure the treesit path variables are lists
* src/treesit.c: (treesit_load_language)
(treesit_find_override_name): Make sure the lists we use are
really lists.
2022-10-17 20:39:23 +03:00
Eli Zaretskii
02f78c09b0 ; Rename ts_* symbols in treesit.c
* src/treesit.c: Rename all ts_* functions and variables to
treesit_*; all references changed.  Fix whitespace.
2022-10-17 13:11:13 +03:00
Yuan Fu
85d0c11119
; * src/treesit.c (ts_search_dfs): Fix tab inline.
Introduced by c6dce90d7e which is a format-fix so I think it's fine
to fix this as a standalone change?
2022-10-17 01:48:50 -07:00
Yuan Fu
2349ecb321
; * src/treesit.c: Change commentary to reflect recent changes. 2022-10-17 01:48:50 -07:00
Eli Zaretskii
260e47e9a3 ; Fix doc strings in treesit.c
* src/treesit.c (Ftreesit_language_version)
(Ftreesit_parser_create, Ftreesit_parser_delete)
(Ftreesit_parser_language, Ftreesit_parser_set_included_ranges)
(Ftreesit_parser_included_ranges, Ftreesit_node_start)
(Ftreesit_node_end, Ftreesit_node_parent, Ftreesit_node_child)
(Ftreesit_node_check, Ftreesit_node_field_name_for_child)
(Ftreesit_node_child_by_field_name, Ftreesit_node_next_sibling)
(Ftreesit_node_prev_sibling, Ftreesit_node_first_child_for_pos)
(Ftreesit_node_descendant_for_range, Ftreesit_pattern_expand)
(Ftreesit_query_expand, Ftreesit_query_compile)
(Ftreesit_query_capture, Ftreesit_search_subtree)
(Ftreesit_search_forward, Ftreesit_induce_sparse_tree)
(syms_of_treesit): Doc string fixes.
2022-10-17 10:54:55 +03:00
Eli Zaretskii
c6dce90d7e ; * src/treesit.c: Fix some indentation problems and doc strings. 2022-10-16 18:09:01 +03: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
bc66ff9875
* src/treesit.c (Ftreesit_query_language): New function. 2022-10-13 14:39:51 -07:00
Yuan Fu
0b3f785c4a
Better signal data for treesit-load-language-error
* src/treesit.c (ts_load_language): Better formatted signal data,
(Ftreesit_langauge_available_p): Optionally return the signal data if
language not available.
* doc/lispref/parsing.texi: Document the signal data in detail.
2022-10-12 10:38:35 -07:00
Yuan Fu
c2ecb08775
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.
2022-10-11 09:30:42 -07:00
Daniel Martín
57e37e9128
Fix typo in Makefile.in
* src/Makefile.in (TREE_SITTER_CFLAGS): Set the correct C flags.
2022-10-10 14:08:53 -07:00
Yuan Fu
b755f45f65
* src/treesit.c (syms_of_treesit): Add Streesit_language_version. 2022-10-06 15:46:01 -07:00
Yuan Fu
cea1e95d38
Merge branch 'master' into feature/tree-sitter 2022-10-06 11:06:07 -07:00
Gerd Möllmann
d9b026d464 Add missing staticpro (bug#58327)
* src/window.c (init_window_once): staticpro old_selected_window.
2022-10-06 10:18:59 +02:00
Gerd Möllmann
a112e3f017 Inhibit GC in probably_quit (bug#58042) 2022-10-06 09:10:17 +02:00
Po Lu
e2027d60ba ; * src/xterm.c (x_term_init): Fix typo. 2022-10-06 10:57:43 +08: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
Po Lu
c690d1f15d Fix nsmenu crash when exiting popup dialog
* src/nsmenu.m (pop_down_menu): Do not discard menu items here.
(ns_popup_dialog): Call discard_menu_items after
unuse_menu_items.  (bug#58296)
2022-10-06 10:52:34 +08:00
Yuan Fu
7ebbd4efc3
Merge branch 'master' into feature/tree-sitter 2022-10-05 14:22:03 -07:00
Stefan Kangas
9449e0740c 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.
2022-10-05 15:23:39 +02:00
Po Lu
6430c4c44f 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>.
2022-10-05 08:32:00 +08:00
Yuan Fu
96d44c4321
Add treesit-language-version
* doc/lispref/parsing.texi (Language Definitions): Update manual.
* src/treesit.c (Ftreesit_language_version): New function
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
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
Vibhav Pant
219cbccb9a
Add comment explaining gcc_jit_context_new_bitcast usage. 2022-10-05 01:20:07 +05:30
Vibhav Pant
df5cb9b2a3
Address styling comments. 2022-10-05 01:20:07 +05:30
Vibhav Pant
c7048b8406
comp.c: Add declaration for gcc_jit_type_is_pointer. 2022-10-05 01:20:06 +05:30
Vibhav Pant
92d75e5c53
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.
2022-10-05 01:20:06 +05:30
Stefan Kangas
c464113049 Merge from origin/emacs-28
a78af3018e * src/emacs.c (load_pdump): Propery handle case when execu...

# Conflicts:
#	src/emacs.c
2022-10-04 20:04:19 +02:00
Andreas Schwab
a78af3018e * src/emacs.c (load_pdump): Propery handle case when executable
wasn't found.
2022-10-04 18:32:53 +02:00
Eli Zaretskii
b560ce3560 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 d52d6e1e10)
2022-10-04 14:24:46 +03:00
Eli Zaretskii
d52d6e1e10 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'.
2022-10-04 14:23:20 +03:00
Po Lu
3583f6184d 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)
2022-10-04 09:26:14 +08:00
Stefan Kangas
6a5169e747 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'

# Conflicts:
#	src/emacs.c
2022-10-04 00:07:22 +02:00
Lars Ingebrigtsen
f97993ee66 Rename to inhibit-automatic-native-compilation
* src/comp.c (maybe_defer_native_compilation):
(syms_of_comp):
* lisp/subr.el (native-comp-deferred-compilation):
* lisp/startup.el (inhibit-native-compilation):
(normal-top-level):
* lisp/progmodes/elisp-mode.el (emacs-lisp-native-compile-and-load):
* lisp/emacs-lisp/comp.el (comp-trampoline-compile):
* etc/NEWS:
* doc/lispref/compile.texi (Native-Compilation Variables): Rename
inhibit-native-compilation to inhibit-automatic-native-compilation.
2022-10-03 19:50:03 +02:00
Manuel Giraud
81003b53f8 ; * src/menu.c: remove unused lwlib include
* src/menu.c: remove unused lwlib include (bug#58275).
2022-10-03 19:15:12 +02:00
Lars Ingebrigtsen
5fec9182db Add new variable 'inhibit-native-compilation'
* doc/lispref/compile.texi (Native-Compilation Variables):
Document it.

* lisp/startup.el (normal-top-level): Set
inhibit-native-compilation from environment variable.

* lisp/subr.el (native-comp-deferred-compilation): Make obsolete.

* lisp/emacs-lisp/comp.el (comp-trampoline-compile): Don't write
trampolines to disk.

* lisp/progmodes/elisp-mode.el
(emacs-lisp-native-compile-and-load): Adjust.

* src/comp.c (syms_of_comp): New variable
inhibit-native-compilation.
(maybe_defer_native_compilation): Use it.
2022-10-03 15:26:13 +02:00
Po Lu
da02b9edad Fix coding systems used for X input methods
* doc/emacs/mule.texi (International): Refer to X Coding as
well.
(Communication Coding): Document that locale-coding-system is
not always used on X to decode keyboard input.
(X Coding): New node.
* etc/NEWS: Announce change to input method coding resolution.
* lisp/term/x-win.el (x-get-input-coding-system): New function.
* src/coding.c (syms_of_coding): Update doc string of
locale-coding-system.
* src/xfns.c (struct x_xim_text_conversion_data)
(x_xim_text_to_utf8_unix_1, x_xim_text_to_utf8_unix_2)
(x_xim_text_to_utf8_unix): Accept dpyinfo.  Use the coding
system specified inside if possible.
(xic_preedit_draw_callback): Pass dpyinfo.
* src/xterm.c (handle_one_xevent): Use XIM coding system for IM
input.
(xim_open_dpy): Try to determine the input method coding system.
(mark_xterm): Mark `xim_coding'.
(syms_of_xterm): New variable `x-input-coding-system'.
* src/xterm.h (struct x_display_info): New field `xim_coding'.
(FRAME_X_XIM_CODING): New macro.
2022-10-03 20:18:37 +08:00
Alan Mackenzie
3cc1706c63 Suppress irritating/misleading message in make bootstrap about old .elc files
These are the "compile-first" .elc files, artificially given an old timestamp
to cause them later to be native compiled.  This fixes bug #58224.

* lisp/Makefile.in (compile-first .el.elc): Give these .elc's the UTC epoch.
Amend the comment.

* src/lread.c (Fload): New variable, epoch_timestamp, initialized to binary
zero.  Compare with this the timestamp of .elc's being loaded, and if they
match, don't output the message about the source file being newer than the
file being loaded.
2022-10-02 20:31:12 +00:00
Andreas Schwab
e5a49f44ff * src/emacs.c (load_pdump): Fix use of xpalloc. 2022-10-02 12:20:09 +02:00
Eli Zaretskii
7ff5207624 Avoid assertion violation in 'xpalloc'
* src/emacs.c (load_pdump): Ensure the 3rd argument of xpalloc is
always positive.  (Bug#58232)
2022-10-02 12:58:04 +03:00
Po Lu
3924fbd025 Only rely on EWMH window activation if possible
* xterm.c (x_ewmh_activate_frame): Remove unnecessary
x_wm_supports check.
(x_focus_frame): When the window manager supports
_NET_ACTIVE_WINDOW, just use it; anything else may confuse the
window manager.
2022-10-02 08:28:56 +08:00
Eli Zaretskii
3bd9606922 ; Another fix for vertical motion
* src/xdisp.c (move_it_vertically_backward): Undo recent changes for
bidi-reordered text.  (Bug#58210)
2022-10-01 17:56:58 +03:00
Eli Zaretskii
ff43fd07b7 Fix vertical motion in some rare bidi situations
* src/xdisp.c (move_it_by_lines): Handle the case where we
didn't move vertically at all.
2022-10-01 17:01:15 +03:00
Eli Zaretskii
82860cb7f7 ; (move_it_vertically_backward): Yet another fix of bug#58210. 2022-10-01 15:44:23 +03:00
Eli Zaretskii
372cc9e88c Fix 'C-a' and 'C-e' under 'visual-line-mode'
* src/xdisp.c (move_it_vertically_backward): Fix last change.
(Bug#58210)
2022-10-01 09:24:04 +03:00
Mattias Engdegård
123506f9ca Speed up string-lessp further
* src/fns.c (Fstring_lessp): Use the memcmp fast path for ASCII-only
multibyte strings as well.  Specialise loops on argument
multibyteness.
2022-09-30 16:24:44 +02:00
Eli Zaretskii
3553904a90 Fix some issues with vertical-motion in bidi-reordered text
This fixes some uses of vertical-motion when a screen line
starts withcharacters of directionality that is opposite to
the current paragraph's base direction.
* src/xdisp.c (move_it_vertically_backward): Adjust NLINES to
compensate for its increasing when DY == 0.
2022-09-30 15:38:22 +03:00
Po Lu
12a78711c9 Fix calculation of frame times when X server time overflows
* etc/TODO: Add TODO about frame synchronization and animations.
* src/xterm.c (x_display_set_last_user_time): Handle cases when
the monotonic time is not the server time due to the latter
overflowing.
2022-09-30 14:54:24 +08:00