1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-05 05:41:40 -07:00
Commit graph

47962 commits

Author SHA1 Message Date
Eli Zaretskii
82626e62ab Allow aborting redisplay stuck in 'parse-partial-sexp'
* src/xdisp.c (display_working_on_window_p): New global variable.
(unwind_display_working_on_window): New function.
* src/keyboard.c (command_loop_1): Reset
'display_working_on_window_p' before and after executing commands.
* src/window.c (Frecenter, window_scroll, displayed_window_lines):
* src/indent.c (Fvertical_motion): Set
'display_working_on_window_p' before calling 'start_display'.
* src/syntax.c (scan_sexps_forward): Call 'update_redisplay_ticks'
after finishing the loop.
2022-06-18 13:07:20 +03:00
Po Lu
6c0caf65af Remove unused Haiku code
* src/haiku_select.cc (be_get_clipboard_targets_1)
(be_get_clipboard_targets): Delete functions.
(init_haiku_select): Rename to `be_clipboard_init'.  Avoid
duplicate definition with haikuterm.h.

* src/haikuselect.c (init_haiku_select): New function.
* src/haikuselect.h: Update prototypes.
2022-06-18 07:11:19 +00:00
Po Lu
183a1b6c6d Fix type mixup in haikuselect.c
* src/haikuselect.c (haiku_lisp_to_message): Fix variable mixup.
Found with --enable-check-lisp-object-type.
2022-06-18 06:04:44 +00:00
Po Lu
06576d6a16 Prevent Lisp code or synthetic events from ruining the user time
* src/xterm.c (x_display_set_last_user_time): New parameter
`send_event'.  Make sure user time is newer unless !send_event.

(x_set_last_user_time_from_lisp): Remove redundant check.
(XTmouse_position):
(handle_one_xevent): Pass `send_event' whenever appropriate.
2022-06-18 11:19:01 +08:00
Po Lu
95370484d4 Fix specifying named action lists in `x-begin-drag'
* src/xfns.c (Fx_begin_drag): Record original value of `targets'
separately.  Pass that as the selection targets list instead.

* src/xterm.c (x_dnd_delete_action_list): New function.
(x_dnd_begin_drag_and_drop): Bind it if there are multiple
actions.
2022-06-18 10:14:24 +08:00
Yuan Fu
7544e9ab5d Fix double-free in treesit.c
* src/treesit.c (Ftreesit_query_capture): Remove free at the end.
2022-06-17 17:04:00 -07:00
Eli Zaretskii
94672c2936 Handle too long syntactic fontifications
* src/syntax.c (scan_sexps_forward): Call 'update_redisplay_ticks'
after finishing the loop.

* src/dispnew.c (make_current): Make sure enabled rows of the
current matrix have a valid hash, even if redisplay of a window
was aborted due to slowness.  This avoids assertion violations in
'scrolling_window' due to the wrong hash value.
2022-06-17 18:24:33 +03:00
Lars Ingebrigtsen
6db5c7f8c4 Improve time parsing documentation
* doc/lispref/os.texi (Time Parsing): Clarify which functions
take/return timestamps and which ones take decoded time structures.
* src/timefns.c (Fdecode_time): Clarify TIME argument (bug#46505).
2022-06-17 16:03:48 +02:00
Po Lu
5e567af8e0 Reduce code duplication when setting user time window
* src/xterm.c (x_make_frame_visible): Use
`x_update_frame_user_time_window'.
2022-06-17 20:19:27 +08:00
Po Lu
3eb47077d3 Clarify doc of `x-display-set-last-user-time'
* src/xfns.c (Fx_display_last_user_time): Explain in more detail
the meaning of TERMINAL.
2022-06-17 19:04:19 +08:00
Mattias Engdegård
39826148d6 * src/fns.c (Fmapconcat): Better empty-string-or-nil detection. 2022-06-17 11:41:34 +02:00
Po Lu
10d23f4ed4 Fix computation of screen width and height on Haiku
* src/haiku_support.cc (be_get_screen_dimensions): Use correct
macros to extract width and height.
2022-06-17 06:58:20 +00:00
Po Lu
cce197c630 Fix instances of not using a usable Motif drag atom
* src/xterm.c (xm_get_drag_atom_1): If another frame owns an
atom, use it anyway.
2022-06-17 12:58:41 +08:00
Po Lu
a8cf6567dd Improve window manager user time reporting mode switching
* src/xterm.c (x_display_set_last_user_time): Stop periodically
checking for user time window support.
(x_update_frame_user_time_window): New function.
(handle_one_xevent): Call it on toplevel ReparentNotify if the
frame has been visible at least once.

* src/xterm.h (struct x_display_info): Remove
`last_user_check_time'.
2022-06-17 10:57:42 +08:00
Po Lu
61a312ba0c Update last event time during DND operations
* lisp/x-dnd.el (x-dnd-handle-xdnd, x-dnd-handle-motif): Set
last user time to provided timestamp.
* src/xfns.c (Fx_display_last_user_time): New function.
(syms_of_xfns): New defsubr.

* src/xterm.c (x_set_last_user_time_from_lisp): New function.
* src/xterm.h: Update prototypes.
2022-06-17 10:24:11 +08:00
Yuan Fu
246dbb540a Change treesit-parser-list from variable to function
Effectively making the list internal.  Now Emacs user cannot shoot
themselves in the foot by removing a parser from the list, make
chaanges to buffer and add that parser back to the list.

* doc/lispref/parsing.texi (Language Definitions, Using Parser)
(Retrieving Node, Multiple Languages): Change variable to function.
* lisp/treesit.el (treesit-language-at, treesit-node-on)
(treesit-buffer-root-node, treesit-indent, treesit-check-indent)
(treesit-search-forward, treesit-search-beginning)
(treesit-end-of-defun, treesit-inspect-mode): Change variable to
function.
* src/buffer.c (bset_ts_parser_list, reset_buffer, init_buffer_once):
Add ts_parser_list.
* src/buffer.h (struct buffer): Add ts_parser_list.
* src/treesit.c (ts_record_change, Ftreesit_parser_create): Use the
buffer field instead of the old buffer local variable.
(Ftreesit_parser_delete, Ftreesit_parser_list): New functions.
(syms_of_treesit): Remove treesit-parser-list.
* test/src/treesit-tests.el (treesit-basic-parsing): Use the new
function.
2022-06-16 17:55:07 -07:00
Stefan Monnier
e75ce9ca38 * src/fns.c (Fmapconcat): Optimize the case where separator=="" 2022-06-16 16:30:44 -04:00
Yuan Fu
dd65d1c396 Consolidate treesit parser create functions
Merge treesit-parser-create, treesit-get-parser,
treesit-get-parser-create into one: treesit-parser-create.

* src/treesit.c (Ftreesit_parser_language): make BUFFER parameter
optional, add new parameter NO-REUSE.  Optionally reuse parser.
* test/src/treesit-tests.el: Change all parser creation to use
treesit-parser-create.  Remove tests for the removed functions.
* lisp/treesit.el (treesit-get-parser, treesit-get-parser-create):
Remove.
* lisp/treesit.el (treesit-set-ranges, treesit-get-ranges)
(treesit-buffer-root-node, treesit-query-string)
(treesit-font-lock-fontify-region, treesit-search-forward)
(treesit-query-validate): Change to use treesit-parser-create.
2022-06-16 11:52:04 -07:00
Yuan Fu
7cee82a91d Fix treesit function ts_record_change and friends
In ts_record_change, the way we calculate tree-sitter change was
wrong:

    ptrdiff_t affected_start =
      max (visible_beg, start_byte) - visible_beg;
    ptrdiff_t affected_old_end =
      min (visible_end, affected_start + bytes_del);
    ptrdiff_t affected_new_end =
      affected_start + bytes_ins;

I changed it to below (also renamed variables)

    ptrdiff_t start_offset =
      min (visible_end,
           max (visible_beg, start_byte)) - visible_beg;
    ptrdiff_t old_end_offset =
      min (visible_end,
           max (visible_beg, old_end_byte)) - visible_beg;
    ptrdiff_t new_end_offset =
      min (visible_end,
           max (visible_beg, new_end_byte)) - visible_beg;

Also previously only visible_end is changed (in a wrong way)

    XTS_PARSER (lisp_parser)->visible_end = affected_new_end;

Now we have a whole new bunch of code that makes the right change.

* src/treesit.c (ts_tree_edit_1): Add assertion.
(ts_record_change): See above.
(ts_ensure_position_synced): Add assertion.
(ts_ensure_parsed): Only free if non-NULL.
(make_ts_parser): Add assertion.
(Ftreesit_parser_set_included_ranges): Ensure parsed before setting ranges.
(Ftreesit_parser_included_ranges): Add assertion.
2022-06-16 11:52:04 -07:00
Yuan Fu
bd1b27b7c7 ; Minor optimization in treesit range function
* src/treesit.c (Ftreesit_parser_set_included_ranges): Lift
assignment out of the loop.
2022-06-16 11:52:04 -07:00
Yuan Fu
a4d7bcccba ; * src/treesit.c: Add comment to explain design decisions. 2022-06-16 11:52:03 -07:00
Eli Zaretskii
5eb9383ccc Fix disruption of windows' display by shr.el
* src/window.c (struct saved_window): New member 'vscroll'.
(Fset_window_configuration, save_window_save): Save and restore
the window's vscroll value.

* lisp/net/shr.el (shr-insert-document): Restore the original
window's hscroll, in case we are rendering in a window other than
where the document will be eventually displayed.  This avoids
resetting hscroll of windows we use temporarily for shr's
rendering job.  (Bug#56008)
2022-06-16 19:53:45 +03:00
Mattias Engdegård
a0f7d81a8d * src/fns.c (mapcar1): Test types in rough order of likelyhood. 2022-06-16 16:04:48 +02:00
Mattias Engdegård
946d70a891 Use BASE_EQ instead of EQ where obviously safe
* src/alloc.c (deadp):
* src/buffer.c (reset_buffer_local_variables, candidate_buffer)
(Fkill_buffer, Fbuffer_swap_text, Fmake_overlay, Fmove_overlay):
* src/callint.c (Fcall_interactively):
* src/coding.c (decode_coding_object, encode_coding_object)
(code_convert_region, Ffind_operation_coding_system):
* src/comp.c (Fcomp_el_to_eln_rel_filename):
* src/conf_post.h (RE_TRANSLATE_P):
* src/data.c (Fkill_local_variable, Fash, expt_integer):
* src/dired.c (file_name_completion):
* src/dispnew.c (set_window_cursor_after_update, update_frame_1)
(Fframe_or_buffer_changed_p):
* src/doc.c (Fdocumentation, Fdocumentation_property)
(default_to_grave_quoting_style):
* src/editfns.c (Fconstrain_to_field, save_excursion_save)
(save_excursion_restore, Fngettext):
* src/eval.c (Fautoload, un_autoload, specbind):
* src/fileio.c (Fmake_temp_file_internal):
* src/fns.c (string_char_to_byte, string_byte_to_char)
(Fnthcdr, Fnreverse):
* src/indent.c (vmotion):
* src/inotify.c (add_watch):
* src/keyboard.c (command_loop_1, read_char)
(read_char_minibuf_menu_prompt):
* src/lread.c (oblookup):
* src/macfont.m (macfont_descriptor_entity, macfont_open):
* src/minibuf.c (Finnermost_minibuffer_p, Ftry_completion)
(Ftest_completion):
* src/nsfns.m (ns_set_icon_name):
* src/pdumper.c (dump_queue_dequeue):
* src/pgtkfns.c (pgtk_set_icon_type, pgtk_set_icon_name):
* src/process.c (Faccept_process_output):
* src/textprop.c (set_text_properties):
* src/w32fns.c (w32_set_icon_type, w32_set_icon_name):
* src/w32select.c (validate_coding_system):
* src/window.c (decode_next_window_args, window_loop)
(save_window_save):
* src/xdisp.c (wset_redisplay):
* src/xfaces.c (Fx_family_fonts, resolve_face_name)
(gui_supports_face_attributes_p):
* src/xfns.c (x_set_icon_type, x_set_icon_name):
* src/xselect.c (clean_local_selection_data):
Use BASE_EQ instead of EQ where it is obvious that neither argument
can be a symbol with properties or at least one argument is a
non-symbol.
2022-06-16 14:49:58 +02:00
Po Lu
b2b939e5a1 Fix byte-swapping of Motif DND tables
* src/xterm.c (xm_read_targets_table_rec): Swap nitems first
before checking the length.
2022-06-16 15:30:21 +08:00
Po Lu
55e9d729ca Fix Motif DND after atom ownership is lost due to frame destruction
* src/xterm.c (xm_get_drag_atom_1): Record owner.
(x_free_frame_resources): Clear drag atom if owner was freed.
* src/xterm.h (struct x_display_info): New field
`motif_drag_atom_owner'.
2022-06-16 14:00:27 +08:00
Stefan Kangas
054832c9e1 Merge from origin/emacs-28
4d7a936ac2 ; * src/fileio.c (Fset_file_modes): Improve previous change
32cff740e2 Describe 'set-file-modes' argument prompting
2022-06-16 06:52:01 +02:00
Po Lu
6dd4c5b953 Improve drag atom computation
* src/xterm.c (xm_get_drag_window): Avoid leak if error occured
creating drag window.  Also use StructureNotifyMask instead of
ButtonPressMask.
(xm_get_drag_atom_1): Update.  Make EMACS_DRAG_ATOM a list of
atoms and use the first one that isn't currently owned.
(xm_get_drag_atom): Stop owning selection here.
(xm_setup_drag_info): Record chosen atom.
(x_dnd_cleanup_drag_and_drop, x_dnd_begin_drag_and_drop)
(x_dnd_update_state, handle_one_xevent, x_connection_closed):
Use chosen atom.
* src/xterm.h (struct x_display_info): New field
`motif_drag_atom_time'.
2022-06-16 12:49:52 +08:00
Paul Eggert
343482d641 Streamline time decoding and conversion
* src/lisp.h (lisp_h_BASE2_EQ, BASE2_EQ): New macros and functions.
* src/timefns.c (tzlookup, Fdecode_time): Use them.
(Ftime_convert): Convert to symbol once, instead of many times.
2022-06-15 23:27:08 -05:00
Paul Eggert
9bce1f3d70 Prefer BASE_EQ in time-sensitive ops
* src/timefns.c (tzlookup, lisp_time_hz_ticks)
(decode_time_components, lisp_to_timespec, lispint_arith)
(time_arith, time_cmp, Fdecode_time, Fencode_time)
(Ftime_convert): Prefer BASE_EQ to EQ where either will do.
2022-06-15 23:27:07 -05:00
Po Lu
9accc800a7 Comply with the Motif requirement for unique drag atoms
* src/xselect.c (x_handle_selection_request)
(Fx_get_selection_internal, syms_of_xselect): New variable
`x-selection-alias-alist'.  Respect that alist of aliases.

* src/xterm.c (x_atom_refs): Intern _EMACS_DRAG_ATOM.
(xm_get_drag_atom_1, xm_get_drag_atom): New functions.
(xm_setup_drag_info, x_dnd_cleanup_drag_and_drop)
(x_dnd_begin_drag_and_drop, x_dnd_update_state, handle_one_xevent)
(x_connection_closed, x_intern_cached_atom): Alias the drag atom
to XdndSelection.  Use it instead of XdndSelection to set the
Motif index atom.
(x_get_atom_name): Handle new atoms.
(syms_of_xterm): New defsym.
* src/xterm.h (struct x_display_info): New fields for new atoms
and their names.
2022-06-16 10:08:12 +08:00
Yuan Fu
0332b8e2c5 ; * src/treesit.c (ts_check_buffer_size): Improve error message. 2022-06-15 12:14:54 -07:00
Yuan Fu
d6b00f7ed9 ; * src/treesit.c (ts_read_buffer): Clarify comments. 2022-06-15 12:14:26 -07:00
Yuan Fu
d729e3e3fc * src/treesit.c (ts_check_range_argument): Check for point-min/max. 2022-06-15 11:33:35 -07:00
Robert Pluim
4d7a936ac2 ; * src/fileio.c (Fset_file_modes): Improve previous change 2022-06-15 15:16:47 +02:00
Po Lu
9b053968ef Implement using the OffiX protocol for dropping
* lisp/x-dnd.el (x-dnd-use-offix-drop): New user option.
(x-dnd-handle-unsupported-drop): Return t if the OffiX protocol
was used.
(x-treat-local-requests-remotely): New defvar.
(x-dnd-convert-to-offix, x-dnd-do-offix-drop): New functions.

* src/xterm.c: Update commentary.
(x_term_init): Extend number of DND atoms allocated by default.
2022-06-15 21:03:31 +08:00
Robert Pluim
32cff740e2 Describe 'set-file-modes' argument prompting
* src/fileio.c (Fset_file_modes): Document that FILENAME is prompted
for.  (Bug#55984)
2022-06-15 14:27:28 +02:00
Po Lu
36f96c351a Handle coordinates for the old KDE drop protocol
* src/xterm.c (x_atom_refs): Add DndProtocol and _DND_PROTOCOL.
(x_coords_from_dnd_message): Handle the old KDE protocol.
* src/xterm.h (struct x_display_info): New atoms.
2022-06-15 14:47:11 +08:00
Yuan Fu
b162faba0b Fix compile warnings and errors in treesit.c
* src/treesit.c (ts_initialize): Fix.
(Ftreesit_parser_set_included_ranges): Fix.
(Ftreesit_query_compile): Fix.
2022-06-14 21:04:52 -07:00
Po Lu
1302c329eb Fix link action handling with Motif DND
* src/xterm.c (enum xm_drag_operation): New alternate
definition.
(XM_DRAG_OPERATION_IS_LINK): New macro.
(handle_one_xevent): Use it instead.
2022-06-15 11:37:39 +08:00
Po Lu
2e2913654b Handle coordinates from XM_DRAG_REASON_DRAG_MOTION replies
* src/xterm.c (struct xm_drag_motion_reply): New struct.
(xm_read_drag_motion_reply): New function.
(x_coords_from_dnd_message): Handle those messages as well.
2022-06-15 09:26:46 +08:00
Yuan Fu
98bfb24081
Merge remote-tracking branch 'savannah/master' into feature/tree-sitter 2022-06-14 15:59:46 -07:00
Yuan Fu
a7288594f4
Change treesit-check-query and mention it in documentation
* doc/lispref/parsing.texi (Pattern Matching): Mention it.
* lisp/treesit.el (treesit-check-query): Rename to
treesit-query-validate.
* src/treesit.c (Ftreesit_query_capture, Ftreesit_query_compile):
Mention it.
2022-06-14 14:30:39 -07:00
Eli Zaretskii
94e1185369 Support callers which sometimes run unrelated to display code
* src/xdisp.c (update_redisplay_ticks): Don't abort callers
with w == NULL if we are called outside of display engine code,
and don't update the tick count in that case.
2022-06-14 22:13:49 +03:00
Yuan Fu
e171ef933f
Support compiled queries in treesit-query-capture
Last commit added this new type, this commit adds functionalities.
treesit.el only has documentation changes.

* lisp/treesit.el (treesit-query-in, treesit-font-lock-settings,
treesit-defun-query): Update docstring.
* src/treesit.c (make_ts_query): New function.
(Ftreesit_query_compile): New function.
(Ftreesit_query_capture): Remove code that creates a query object and
instead either use make_ts_query or use the give compiled query.  Free
the query object conditonally.
(syms_of_treesit): New symbol.
2022-06-14 11:50:24 -07:00
Yuan Fu
a8428b917d
* src/treesit.c (Ftreesit_query_p): New function. 2022-06-14 11:50:10 -07:00
Yuan Fu
8f3b872e30
Add new type treesit-compiled-query
No intergration/interaction with the new type, just adding it.

* lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): Add new type.
* src/alloc.c (cleanup_vector): Add gc for the new type.
* src/data.c (Ftype_of): Add switch case for the new type.
(syms_of_data): Add symbols for the new type.
* src/lisp.h (DEFINE_GDB_SYMBOL_BEGIN): Add new type.
* src/treesit.c (Ftreesit_compiled_query_p): New function.
(syms_of_treesit): Add symbol for the new type.
* src/treesit.h (struct Lisp_TS_Query): New struct.
(TS_COMPILED_QUERY_P, XTS_COMPILED_QUERY, CHECK_TS_COMPILED_QUERY):
New macros.
* src/print.c (print_vectorlike): Add printing for the new type.
2022-06-14 11:44:04 -07:00
Eli Zaretskii
264472a507 Handle W = NULL in 'update_redisplay_ticks'
* src/xdisp.c (update_redisplay_ticks): If W == NULL, assume we
are iterating the current buffer.
2022-06-14 20:27:12 +03:00
Eli Zaretskii
bd44f39d6d Restart tick counting every command
* src/keyboard.c (command_loop_1): Reinitialize the tick count
before executing each command in the loop.
* src/xdisp.c (update_redisplay_ticks): Be more defensive to W
being NULL and to its buffer being nil.  Set
'windows_or_buffers_changed' to avoid trusting stale window data
like w->window_end_valid.
2022-06-14 19:05:38 +03:00
Po Lu
8fa1cdc1fa ; Improve doc of `x-dnd-native-test-function'
* src/xterm.c (syms_of_xterm): Improve doc.  Suggested by Eli
Zaretskii <eliz@gnu.org>.
2022-06-14 19:50:31 +08:00