1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-21 12:03:55 -08:00
Commit graph

47620 commits

Author SHA1 Message Date
Stefan Kangas
40539c7587 ; Fix typos 2022-11-22 02:24:20 +01:00
Yuan Fu
aaeaa310f0
Merge remote-tracking branch 'savannah/master' into feature/tree-sitter 2022-11-21 12:54:35 -08:00
Yuan Fu
aa6958c04e
; * src/treesit.c (treesit_load_language): Move call to eassume.
If handle is ever going to be NULL, it will be when error != NULL, so
we should only eassume handle != NULL after the check for error.
2022-11-21 09:31:14 -08:00
Mattias Engdegård
87c696b7a8 ; Repair build without tree-sitter 2022-11-21 15:41:28 +01:00
Po Lu
3069849bd4 * src/treesit.c (treesit_load_language): Fix uninitialized uses. 2022-11-21 14:10:21 +08:00
Po Lu
d452539966 Avoid usage of intern_c_string in treesit.c
* src/treesit.c (Ftreesit_pattern_expand): Use DEFSYM'd symbols
when the naming makes sense.
(syms_of_treesit): Add new defsyms QCanchor, QCequal, QCmatch.
2022-11-21 14:10:21 +08:00
Po Lu
43f25120c9 Stylistic fixes to treesit.c
* src/treesit.c (treesit_make_ranges):
(Ftreesit_parser_set_included_ranges): Fix coding style.
2022-11-21 14:10:21 +08:00
Juanma Barranquero
8ec8decd9f Avoid native compiler setting user-init-file to warnings.el (bug#59358)
* src/lread.c (maybe_swap_for_eln): Use a delayed warning
instead of `display-warning' to avoid a recursive call to
Fload while loading the init file that sets `user-init-file'
to a bogus value.
2022-11-20 21:40:08 +01:00
Po Lu
8874cd908c Coalesce duplicate scroll valuator handling code
Also, write more commentary.

* src/xterm.c (xi_populate_scroll_valuator): New function.
Describe the meaning of each field in xi_scroll_valuator_t.
(xi_populate_device_from_info, xi_handle_new_classes): Factor
out duplicate code to that function.
2022-11-20 21:03:18 +08:00
Stefan Kangas
16318bfb51 ; Fix typos 2022-11-20 12:59:39 +01:00
Eli Zaretskii
7b09ed28ba Advise against using too-high GC thresholds
* doc/lispref/internals.texi (Garbage Collection):
* src/alloc.c (syms_of_alloc) <gc-cons-threshold>
<gc-cons-percentage>: Advise against enlarging the GC thresholds
more than needed and for prolonged periods of time.
2022-11-20 13:10:08 +02:00
Po Lu
07127e9c29 Fix error trapping in x_set_mouse_color
* src/xfns.c (x_set_mouse_color): Use
x_uncatch_errors_after_check right after x_had_errors_p.  Then,
trap errors around FreeCursor requests, since some of the IDs
may not name valid cursors.
2022-11-19 18:47:28 +08:00
Po Lu
12e1e9c797 Fixes to fast mouse position reporting
* src/xterm.c (x_fast_mouse_position): New function.  Factor out
most of the fast mouse position code here.  Correctly port some
Haiku code to take into account multiple displays.  Report
scroll bar coordinates correctly.
(XTmouse_position): Call it.
2022-11-19 15:25:07 +08:00
Po Lu
b18d4dbe0d Fix automatic DPI adjustment and add workarounds for some systems
* lisp/faces.el (x-create-frame-with-faces): New field
`delayed-font'.  Set the `font-parameter' property to `font' in
the given parameter list after face-set-after-frame-default is
called.
* src/fontset.c (Fset_fontset_font): Avoid changing
`font-parameter' with the call to Fmodify_frame_parameters.
* src/frame.c (gui_set_frame_parameters_1): New function.
Factor out gui_set_frame_parameters here, and add an argument
DEFAULT_PARAMETER.  If the `font' parameter is set, and
`default_parameter' is not, then set the `font-parameter' frame
parameter to the `font' parameter as well, to keep track of
which user-specified `font' frame parameter set the default
face's font on the frame.
(gui_set_frame_parameters): Call gui_set_frame_parameters_1 with
new arg set to false.
(gui_set_font): Remove broken implementation of
`font-parameter'.
(gui_default_parameter): If the default value was used, then
call gui_set_frame_parameters_1 with the new argument set to
false.  This is because no font was specified as a frame
parameter by the user, so Freconsider_frame_fonts is free to do
anything it wants.
(Freconsider_frame_fonts): If `font-parameter' is set, then use
it.
(syms_of_frame): New defsym Qfont_parameter.

* src/frame.h: Update prototypes.

* src/haikuterm.c (haiku_default_font_parameter):
* src/pgtkfns.c (pgtk_default_font_parameter):
* src/w32fns.c (w32_default_font_parameter): Stop setting
`font-parameter' here.  This code resulted in decades of
automatic font rescaling not working correctly.

* src/xfaces.c (set_font_frame_param): Clear the
`font-parameter' frame parameter.
(Finternal_merge_in_global_face):
* src/xfns.c (x_default_font_parameter): Avoid changing
`font-parameter' in response to changes to face attributes.
* src/xsettings.c (apply_xft_settings): Add workaround for
Cairo.  (bug#59371, bug#59347, bug#59283, bug#59271, bug#59285,
bug#59306.)
2022-11-19 13:59:53 +08:00
Po Lu
10701635cf Fix bug#59371
* src/frame.c (Freconsider_frame_fonts): If a font parameter was
set, create a params alist with it.  Then, pass it to both
default_font_parameter and face-set-after-frame-default.
(bug#59371)
2022-11-19 11:19:41 +08:00
Po Lu
b23a4a1505 Fix earlier changes to keyboard.c
* src/keyboard.c (coords_in_menu_bar_window): New function.
(make_lispy_event): Do not process menu bar events on window
system frames if there is no menu bar window or the click lies
outside.
2022-11-19 11:13:15 +08:00
Po Lu
4921bd7bac Fix build with ext menu bar
* src/keyboard.c (make_lispy_event): Don't access
menu_bar_window when !HAVE_EXT_MENU_BAR.
2022-11-19 08:42:56 +08:00
Manuel Giraud
409f0430b6 Fix click position to menu bar entry with no-toolkit
* src/keyboard.c (make_lispy_event): Use x_y_to_hpos_vpos to
compute correct menu bar position should the menu face change.
* src/xdisp.c (x_y_to_hpos_vpos): Not static anymore.
* src/dispextern.h: Export x_y_to_hpos_vpos.
2022-11-19 08:22:45 +08:00
Stefan Monnier
5525bd3932 itree: Make sure a deleted overlay has NULL pointer fields
* src/buffer.c (delete_all_overlays): Use POST_ORDER to set the node's
pointers to NULL, as god intended.

* src/itree.c (itree_insert_node): Uncomment the assertion accordingly.
2022-11-18 11:11:46 -05:00
Stefan Kangas
ba485eb949 ; Fix typos 2022-11-18 16:02:19 +01:00
Stefan Kangas
f7ee6609ae ; Fix typos (prefer US spelling) 2022-11-18 13:06:55 +01:00
Po Lu
32e29afe64 Add knob to make `mouse-position' faster on X
* etc/PROBLEMS (Improving performance with slow X connections):
Add new advice.
* src/xterm.c (XTmouse_position): Add alternative
implementations for slow connections.
(syms_of_xterm): Add new variable to enable them.
* src/xterm.h (struct x_display_info): Update commentary.
2022-11-18 09:09:10 +08:00
Stefan Monnier
682b068ba7 Merge remote-tracking branch 'origin/scratch/noverlay' 2022-11-17 18:48:38 -05:00
Stefan Monnier
091e0f04ff itree.c: Get rid of the old iterator code
Only use the new iterator which relies on a fixed size (and small)
state in the iterator.
This makes non-local exits safe within ITREE_FOREACH loops.

* src/itree.c (make_nav, nav_nodeptr, nav_flag, itree_stack_clear)
(itree_stack_push_flagged): Delete functions.
(nodeptr_and_flag): Delete type.
(struct itree_stack): Make the array hold plain pointers instead.
(itree_stack_push): Inline the former code of `itree_stack_push_flagged`.
(itree_stack_pop): Change return type.
(itree_contains): Don't call `ITREE_FOREACH_ABORT` any more.
(itree_insert_gap): Simplify access to the stack of nodes.
(itree_delete_gap, itree_insert_gap): Adjust code to new return type of
`itree_stack_pop`.
(itree_iterator_finish): Delete function.
(itree_iterator_start): Don't setup the `stack` field any more.
(itree_iterator_next): Delete function.
(itree_iter_next): Rename to `itree_iterator_next` and make it non-static.
(itree_iterator_narrow): Don't check the `running` flag any more.

* src/itree.h (itree_iterator_finish): Remove declaration.
(struct itree_iterator): Remove the `stack` and `running` fields.
(ITREE_FOREACH_ABORT): Delete macro.
(ITREE_FOREACH): Don't call `itree_iterator_finish` any more.

* src/xdisp.c (strings_with_newlines):
* src/buffer.c (overlays_in, next_overlay_change, overlay_touches_p):
Don't call `ITREE_FOREACH_ABORT` any more.
2022-11-17 18:09:37 -05:00
Stefan Monnier
fb7f1864da itree.c: Make the iterator reentrant (bug#59183)
Get rid of the global iterator object and instead allocate
a separate iterator for every loop.  This still uses the "duplicate
iterator" code, including the old iterator which needs a stack,
make ITREE_FOREACH a bit more expensive than we'd like.

* src/itree.h (init_itree, forget_itree, itree_iterator_busy_p):
Delete declarations.
(itree_iterator_start): Add iterator arg and remove `line` and `file` args.
(struct itree_iterator): Move from `itree.c`.  Remove `line` and
`file` fields.
(ITREE_FOREACH): Stack allocate an iterator object and pass it to
`itree_iterator_start`.

* src/itree.c (struct itree_iterator): Move to itree.h.
(iter): Delete global variable.
(itree_iterator_create, init_itree, forget_itree, itree_iterator_busy_p):
Delete functions.
(itree_contains): Adjust assertion.
(itree_iterator_finish): Deallocate the iterator's stack.
(itree_iterator_start): Take the (uninitialized) iterator as argument.
Allocate a fresh new stack.  Remove `file` and `line` arguments.
Don't check `running` any more since the iterator is not expected to be
initialized at all.

* src/eval.c (signal_or_quit):
* src/alloc.c (garbage_collect): Don't check `itree_iterator_busy_p`
any more.

* src/emacs.c (main): No need to `init_itree` any more.
(Fdump_emacs): No need to `forget_itree` any more.
2022-11-17 17:00:22 -05:00
Stefan Monnier
13003105a8 itree.c: Add new "stateless" iterator code and post-order traversal
This still uses the old iterator code, but runs the new code
alongside to make sure they behave identically.

* src/itree.c (struct itree_iterator): New field `node`.
(itree_iterator_create): Give it a sane default value.
(itree_iterator_busy_p, itree_iterator_start, itree_iterator_finish):
Move down to the "iterator" section of the file.
(itree_iter_next_in_subtree, itree_iterator_first_node)
(itree_iter_next): New functions.
(itree_iterator_start): Initialize the new `node` field.
(itree_iterator_next): Add post-order case.
Call the new "stateless" `itree_iter_next` function and check that it
agrees.

* src/itree.h (enum itree_order): New value for post-order traversals.
2022-11-17 09:08:24 -05:00
Eli Zaretskii
62e37ecc40 Fix documentation of recent treesit changes
* src/treesit.c (Ftreesit_parser_notifiers)
(Ftreesit_parser_add_notifier, Ftreesit_parser_remove_notifier):
Doc string fixes.

* doc/lispref/parsing.texi (Accessing Node Information): Fix
wording and punctuation.
(Using Parser): Improve indexing and wording.
2022-11-17 15:03:40 +02:00
Eli Zaretskii
6678572110 Fix display of mode line when the right divider is used
* src/xdisp.c (init_iterator): For the mode-line, adjust
last_visible_x due to the right divider and the 'box' attribute,
if any, of the mode-line face.
(display_min_width): Update current_x after producing the stretch
glyph, to mimic PRODUCE_GLYPHS.
(display_mode_line): Widen the last glyph to account for adding
the right box line to it.  (Bug#5930)
2022-11-17 11:21:01 +02:00
Stefan Kangas
93036209fa ; Fix typos (duplicate words) 2022-11-17 09:34:24 +01:00
Po Lu
fa9777b174 Fix treatment of input focus on MPX setups
* src/xterm.c (x_ewmh_activate_frame): Use x_set_input_focus
instead of XSetInputFocus.
(x_set_input_focus): New function.  Take into account the
``client pointer'' chosen by Emacs.
(x_focus_frame): Use x_set_input_focus instead of
XSetInputFocus.
2022-11-17 15:14:27 +08:00
Juanma Barranquero
999027888c ; * src/comp.c (Fnative_elisp_load): Fix typo in docstring 2022-11-17 03:15:59 +01:00
Yuan Fu
902649a170
Fix treesit-search-forward not matching leaf nodes
* src/treesit.c: Match against NODE at start of the loop.
2022-11-16 15:48:07 -08:00
Yuan Fu
639821d49a
Allow checking for outdated nodes in tree-sitter
Now you can run (treesit-node-check node 'outdated).

* doc/lispref/parsing.texi (Accessing Node Information): Update
manual.
* src/treesit.c (Ftreesit_node_check): Add new property 'outdated'.
* test/src/treesit-tests.el (treesit-node-check): Add tests.
2022-11-16 14:40:41 -08:00
Yuan Fu
75b65b3f67
; Add documentation for tree-sitter parser after-change notifiers
* doc/lispref/parsing.texi (Using Parser): Update manual.
* lisp/treesit.el (treesit): Add shordocs.
* src/treesit.c: Augment docstrings.
2022-11-16 14:40:40 -08:00
Stefan Monnier
f696d27d1c * src/itree.c: Use more uniform names starting with itree_
(struct itree_stack, itree_stack_create, itree_stack_destroy)
(itree_stack_clear, itree_stack_push_flagged, interval_stack_push)
(itree_stack_pop): Rename from `interval_stack*`.
(itree_max_height, itree_update_limit, itree_inherit_offset)
(itree_propagate_limit, itree_validate, itree_init)
(itree_rotate_left, itree_rotate_right, itree_insert_fix)
(itree_contains, itree_subtree_min, itree_remove_fix)
(itree_replace_child, itree_transplant): Rename from `interval_tree_*`.
(itree_insert_node): Rename from `interval_tree_insert`.
(itree_node_intersects): Rename from `interval_node_insert`.
2022-11-16 16:35:10 -05:00
Po Lu
690f7ac86a Fix calculation of tab bar lines during automatic height adjustment
* src/haikufns.c (haiku_change_tab_bar_height):
* src/nsfns.m (ns_change_tab_bar_height):
* src/pgtkfns.c (pgtk_change_tab_bar_height):
* src/w32fns.c (w32_change_tab_bar_height):
* src/xfns.c (x_change_tab_bar_height): Do not round tab bar
height up.  (bug#59285, bug#59271)
2022-11-16 11:19:20 +08:00
Po Lu
0600065ff2 Fix error trapping in x_focus_frame
* src/xterm.c (x_focus_frame): Improve commentary.  Dno not trap
errors around x_get_server_time.
2022-11-16 10:37:14 +08:00
Yuan Fu
162c3da7a0
; * src/treesit.c: Minor stylistic changes. 2022-11-15 10:21:09 -08:00
Eli Zaretskii
ab70ab19be Fix the MS-Windows build due to use of a new TS function
* src/treesit.c (ts_tree_get_changed_ranges) [WINDOWSNT]: Define,
load from the library, and call through a function pointer.
2022-11-15 16:54:41 +02:00
Po Lu
c63d77ac6b Fix last change again
* src/frame.c (Freconsider_frame_fonts): Apply value of default
face again.  (bug#59283)
2022-11-15 21:42:59 +08:00
Po Lu
c6df541783 More fixes to last change
* lisp/dynamic-setting.el (font-setting-change-default-font):
Call `reconsider-frame-fonts'.
* src/frame.c (Freconsider_frame_fonts): New function.
(syms_of_frame): Add new function.
2022-11-15 19:48:39 +08:00
Po Lu
833e60ae1a Fix recent Cairo xsettings changes
* lisp/dynamic-setting.el (font-setting-change-default-font):
Instead of setting the font frame parameter, just clear the font
and face cache and redraw the display.  This will re-open all
fonts as well.
* src/ftcrfont.c (ftcrfont_get_default_font_options): New
function.
* src/ftfont.h: Export.
* src/xsettings.c (apply_xft_settings): Call that function to
obtain the default font settings on Cairo.  (bug#58912,
bug#59283, bug#59271)
2022-11-15 19:48:39 +08:00
Yuan Fu
34e50dc4a2
Allow tree-sitter to notify parse-tree changes
* src/treesit.c (treesit_call_after_change_functions): New function.
(treesit_ensure_parsed): Call treesit_call_after_change_functions
right after re-parse.
(make_treesit_parser): Initialize after_change_functions.
(Ftreesit_parser_notifiers)
(Ftreesit_parser_add_notifier)
(Ftreesit_parser_remove_notifier): New functions.
* src/treesit.h (Lisp_TS_Parser): New field after_change_functions.
2022-11-15 02:16:11 -08:00
Yuan Fu
06db8015ea
Extract out treesit_make_ranges
* src/treesit.c (treesit_make_ranges): New function.
(Ftreesit_parser_included_ranges): Use treesit_make_ranges.
2022-11-15 00:31:42 -08:00
Po Lu
723ceaca1d Make C-x 5 o work on GNOME Shell-like Wayland compositors
* src/pgtkterm.c (pgtk_free_frame_resources)
(fill_background_by_face)
(pgtk_draw_glyphless_glyph_string_foreground)
(pgtk_draw_window_cursor): Fix coding style.
(pgtk_focus_frame): Use gtk_window_present_with_time whenever
possible.
(key_press_event): Set the last user time.
(pgtk_display_info_for_display): New function.
(key_release_event, construct_mouse_click, button_event): Set
the last user time.
(scroll_event, pgtk_parse_color, syms_of_pgtkterm)
(pgtk_begin_cr_clip): Fix coding style.
* src/pgtkterm.h (struct pgtk_output): New field
`last_user_time'.
2022-11-14 19:06:37 +08:00
Yuan Fu
3a0c94ac0b
Remove feature that checks whether tree-sitter node "has changes"
First of all, we signal error on using an outdated node, so if a node
has changes, calling treesit-node-check would only raise an error.
Besides, in order to properly answer whether a node has changed, we
would have to update the node as the buffer is edited, which we don't
do right now.

* doc/lispref/parsing.texi (Accessing Node Information): Remove
relevant manual text.
* src/treesit.c (Ftreesit_node_check): Remove docstring mentions,
remove the branch for "has-changes".
(syms_of_treesit): Remove has-changes.
2022-11-14 00:51:54 -08:00
Po Lu
83a497ee87 Prevent crashes upon trying to focus a child frame on click
* src/xterm.c (handle_one_xevent): Do not try to activate
override-redirect frames.  Explain why.
(x_focus_frame): Catch errors around XSetInputFocus.
2022-11-14 14:07:04 +08:00
Po Lu
7a9beac461 Fix bug#59075
* src/nsimage.m (ns_can_use_native_image_api): Do not use native
image APIs for SVG images when RSVG is present.  (bug#59075)
2022-11-13 17:30:49 +08:00
Eli Zaretskii
3a5c4bdc0c Fix crash on MS-Windows due to memory-allocation problem in treesit.c
* src/treesit.c (treesit_load_language): Use 'xstrdup'/'xfree'
instead of 'strdup'/'free', to prevent crashes on MS-Windows,
where we must use our own implementation of 'malloc'/'free',
whereas 'strdup' uses the default implementation in the MS-Windows
C runtime library.
2022-11-13 10:51:42 +02:00
Po Lu
756373a772 Fix warnings without XCB or XFixes
* src/xterm.c (x_term_init): Don't USE_SAFE_ALLOCA or call
SAFE_FREE outside of where it is actually used.  For some reason
the compiler still emitted warnings despite the ((void)
SAFE_ALLOCA (0)) statement.
2022-11-13 15:35:02 +08:00