Commit graph

46461 commits

Author SHA1 Message Date
Po Lu
d94890404e Fix crashes displaying menu help text on NS
* src/nsterm.m (ns_flush_display): Run event loop manually,
avoiding a double free of an autorelease pool.
2022-05-31 16:25:20 +08:00
Po Lu
b7bbf88642 Fix processing of DND events on GTK
* src/xterm.c (x_dnd_begin_drag_and_drop): Clear `current_count'
and `current_hold_quit' after calling gtk_main_iteration.
2022-05-31 13:24:27 +08:00
Po Lu
75bf80e2b1 Fix unused variables on GTK
* src/xterm.c (x_wait_for_cell_change): Fix unused variables
on GTK builds.
2022-05-31 10:17:12 +08:00
Po Lu
dae936f504 Fix initialization of `hold_quit' during DND
* src/xterm.c (x_dnd_begin_drag_and_drop): Use `EVENT_INIT'
instead of just setting type to NO_EVENT.
2022-05-31 10:15:29 +08:00
Po Lu
81b174cace Prevent events from being lost waiting for selections on GTK
* src/xterm.c (x_wait_for_cell_change): Use GTK to iterate the
main loop so events reach the toolkit.
2022-05-31 08:47:30 +08:00
Eli Zaretskii
c9e5e79ac2 Fix 'debug-timer-check' on MS-Windows
* src/w32proc.c (w32_raise): New function.
* src/atimer.c (raise) [WINDOWSNT]: Redirect to 'w32_raise'.
2022-05-30 20:51:19 +03:00
Mattias Engdegård
b903507b36 Nonrecursive Lisp reader (bug#55676)
Restructure the reader to be nonrecursive so that it is not limited by
the C stack or crashes Emacs when reading deeply nested data.
This also improves performance.
A few minor bugs were fixed:

- (a .{NBSP}b) where {NBSP} is a non-breaking space (U+00A0) is now
  the dotted pair (a . b), not the 3-element list (a \. b), since U+00A0
  is treated as whitespace everywhere else.
- #_ with no symbol following is now equivalent to ## (empty interned
  symbol), not #: (empty uninterned symbol).

* src/alloc.c (garbage_collect): Call mark_lread.
* src/lread.c (readevalloop): Use read0 instead of read_list.
(stackbufsize): Increase to 1024, now that read0 isn't recursive.
(invalid_radix_integer): Buffer overflow check.
(read1, read_list, read_vector): Remove.
(read_char_literal, read_string_literal)
(hash_table_from_plist, record_from_list, vector_from_rev_list)
(bytecode_from_rev_list, char_table_from_rev_list)
(sub_char_table_from_rev_list, string_props_from_rev_list)
(read_bool_vector, skip_lazy_string, symbol_char_span)
(skip_space_and_comments)
(enum read_entry_type, struct read_stack_entry, struct read_stack)
(rdstack, mark_lread, read_stack_top, read_stack_pop)
(read_stack_empty_p, grow_read_stack, read_stack_push): New.
(read0): Rewrite to be nonrecursive.
* test/src/lread-tests.el (lread-deeply-nested, lread-misc): New tests.
2022-05-30 15:56:59 +02:00
Mattias Engdegård
169797a300 Fix atimer setting and overdue expiration (bug#55628)
* src/atimer.c (set_alarm): If the atimer has already expired, signal
it right away instead of postponing it further.  Previously this could
occur repeatedly, blocking atimers indefinitely.
Also only use `alarm` as fallback if `setitimer` is unavailable, not
both at the same time (which makes no sense, and they both typically
use the same mechanism behind the curtains).

* test/src/eval-tests.el (eval-tests/funcall-with-delayed-message):
New test, verifying proper functioning of funcall-with-delayed-message
which also serves as test for this bug (which also caused
debug-timer-check to fail, but that test is only run when Emacs is
built with enable-checking).
2022-05-30 15:52:02 +02:00
Po Lu
f81065a91b Fix `dnd-indicate-insertion-point' on Mac OS
* lisp/term/ns-win.el (ns-handle-drag-motion): Remove debugging
code.

* src/nsterm.m ([EmacsView draggingUpdated:]): Redisplay here
instead.
2022-05-30 16:03:11 +08:00
Po Lu
3eca30bc50 Update frame positions on Haiku after changing Z group
* src/haiku_support.cc (EmacsScreenChangeMonitor): Fix comment.
* src/haikufns.c (haiku_set_z_group): Ask for a position update,
since changing the Z group might change the feel of the window.
2022-05-30 07:55:13 +00:00
Po Lu
d8adce56a0 Fix cursor flushing inside minibuffers on NS
* src/nsterm.m (EV_TRAILER): Fix coding style.
(ns_flush_display): New function.
(ns_redisplay_interface): Register `flush_display'.
2022-05-30 15:06:55 +08:00
Po Lu
fd510f1239 Fix hangs when x-get-selection is called inside a popup menu
* src/xselect.c (wait_for_property_change):
(x_get_foreign_selection): Use `x_wait_for_cell_change' if input
is blocked.  (bug#22214)
* src/xterm.c (x_wait_for_cell_change): New function.
* src/xterm.h: Update prototypes.
2022-05-30 14:05:30 +08:00
Po Lu
48ef8ab15f Try to implement `dnd-indicate-insertion-point' on macOS
* lisp/term/ns-win.el (ns-handle-drag-motion): New function.
* src/nsterm.m ([EmacsView draggingUpdated:]): Call that
function instead.
(syms_of_nsterm): Clean up old style defvars and add new
defvar for the DND drag function.
2022-05-30 10:36:43 +08:00
Po Lu
5b770b60f4 Further clean up DND target handling
* src/xfns.c (Fx_begin_drag): Alloca target list.

* src/xterm.c (x_set_dnd_targets): Copy the given targets list.
(x_dnd_begin_drag_and_drop): Record freeing the targets list on
the specpdl.
(handle_one_xevent, x_dnd_cleanup_drag_and_drop)
(x_connection_closed, x_delete_terminal): Stop calling
`x_set_dnd_targets' manually to free the targets list.
2022-05-30 09:25:03 +08:00
Po Lu
e2e232933c Fix crash when loading Postscript images
* src/xterm.c (handle_one_xevent): Catch errors around
`x_kill_gs_process'.
2022-05-30 09:07:27 +08:00
Po Lu
b6a4766388 Use XDrawPoint to clear relief rect corners
* xterm.c (x_clear_point): New function.
(x_draw_relief_rect): Use that instead.
2022-05-30 08:49:24 +08:00
Po Lu
6f8e856ada Keep display mm width and height up to date after changes
* src/xfns.c (Fx_display_mm_width, Fx_display_mm_height): Use
new fields if they are set.
* src/xterm.c (handle_one_xevent): Set new fields on RRNotify if
the screen is correct.
* src/xterm.h (struct x_display_info): New fields
`screen_mm_width', `screen_mm_height'.
2022-05-29 15:49:48 +08:00
Po Lu
22a3e92dc6 Make DND target list lifecycle a little clearer
* src/xfns.c (Fx_begin_drag): Pass target atoms and ntargets to
x_dnd_begin_drag_and_drop instead.
* src/xterm.c (x_set_dnd_targets): Make static.
(x_clear_dnd_targets): Delete function.
(x_dnd_begin_drag_and_drop): Adjust to set targets here instead.
* src/xterm.h: Update prototypes.
2022-05-29 12:56:37 +08:00
Stefan Kangas
6303cb7e9f Merge from origin/emacs-28
f9ee83bfb9 do_switch_frame: before leaving mini-window, check other (...
908e2e09d0 Fix commands used to produce on-line HTML docs
fff770fb97 Fix a bad cross-reference in elisp.pdf
ebea3415b0 Fix documentation of 'string-pad'
2022-05-29 06:30:21 +02:00
Po Lu
c92d73d271 Fix pending window changes in haiku_set_window_size
* src/haikuterm.c (haiku_set_window_size): Wait for
FRAME_RESIZED events, then call `do_pending_window_change'.
(haiku_read_socket): Allow waiting for FRAME_RESIZED events.
2022-05-29 01:05:54 +00:00
Po Lu
28d4952d42 Improve error trapping on X
* xterm.c (x_uncatch_errors, x_had_errors_p): Don't sync if no
request was made since the error trap was installed.
2022-05-29 08:51:17 +08:00
Alan Mackenzie
f9ee83bfb9 do_switch_frame: before leaving mini-window, check other (mru) window is live
This fixes bug#55684.  There, with a minibuffer-only frame at start up,
Emacs tried to switch to this frame, whose selected window was the
mini-window.  There is no other active window in this frame, so the
attempt to swith to another window failed.

* src/frame.c (do_switch_frame): On switching to a frame whose selected
window is as above, before selecting the most recently used window, check
this ostensible window is an actual live window.  Otherwise leave the
mini-window selected.
2022-05-28 12:55:32 +00:00
Po Lu
f91e87cc8a Add more cursor bitmaps on Haiku
* src/haikufns.c (cursor_bitmaps_for_id): Add hourglass cursor.
2022-05-28 04:35:12 +00:00
Po Lu
79ae40c8e4 Improve documentation on what callers of `x-begin-drag' should do
* doc/lispref/frames.texi (Drag and Drop):
* src/xfns.c (Fx_begin_drag): Improve documentation of how the
chosen action should be performed.
2022-05-28 10:30:45 +08:00
Po Lu
b52f36a33d Improve documentation of `x-begin-drag'
* src/xfns.c (Fx_begin_drag): Fix typos and improve wording.
2022-05-28 10:21:52 +08:00
Po Lu
73237458ba Improve safety of various DND callbacks
* src/xterm.c (x_dnd_begin_drag_and_drop): Restore selection
events if DND is no longer in progress and don't call
x-dnd-movement-function.
2022-05-28 10:09:19 +08:00
Po Lu
ac13957b86 Fix frame destruction issues and misuse of x_get_atom_name
* src/frame.c (delete_frame): Prevent deleting the dnd frame
while waiting for finish as well.
* src/xselect.c (Fx_get_atom_name): Clean up code and fix
uninitialized use of need_sync.
* src/xterm.c (x_dnd_send_unsupported_drop, x_dnd_send_drop)
(handle_one_xevent): Clean up usage of x_get_atom_name.
(x_get_atom_name): Accept NULL for need_sync.

* src/xterm.h: Update declarations.
2022-05-28 09:37:29 +08:00
Po Lu
b2c8e8a299 ; * src/nsselect.m (ns_decode_data_to_pasteboard): Fix GNUstep build. 2022-05-28 09:21:40 +08:00
Po Lu
6d6d1adbe7 Fix build on earlier versions of Mac OS X
* src/nsselect.m (ns_decode_data_to_pasteboard): Respect
NS_USE_NSPasteboardTypeFileUrl.
2022-05-28 09:19:33 +08:00
Po Lu
ffab237cbf Add file dragging support to NS port
* lisp/dired.el (dired-mouse-drag-files): Document that
`dired-mouse-drag-files' now works on NS.

* lisp/term/ns-win.el (x-begin-drag): Handle FILE_NAME.
* src/nsselect.m (ns_decode_data_to_pasteboard): Handle file URL
type.
(ns_lisp_to_pasteboard, Fns_begin_drag): Handle new type `file'.
2022-05-28 09:18:09 +08:00
Po Lu
3c5fbfe4ac Improve DND documentation
* doc/lispref/frames.texi (Drag and Drop):
* src/xfns.c (Fx_begin_drag): Document that x-begin-drag may
return immediately if no mouse buttons are held down.
2022-05-28 09:03:29 +08:00
Po Lu
5c07aed894 Fix x_dnd_movement_frame detection on GTK builds
* src/xterm.c (x_dnd_begin_drag_and_drop): Make sure movement
frame is on the correct display.
2022-05-28 08:55:13 +08:00
Po Lu
26588e9594 ; * src/xterm.c (x_color_cache_bucket_size): Improve doc string. 2022-05-28 08:48:29 +08:00
Paul Eggert
3bbf047cd8 Remove stray decl of nonexistent var
* src/lisp.h (symbols_with_pos_enabled): Remove decl.
2022-05-27 16:34:54 -07:00
Paul Eggert
eb37e4814e Fix unlikely null pointer dereference
* src/xselect.c (Fx_get_atom_name): Fix unlikely core dump when
build_string is called on a null pointer.  Found by GCC -fanalyzer.
2022-05-27 11:45:01 -07:00
Paul Eggert
cb57db513b Add ATTRIBUTE_DEALLOC to extern functions
This can help static checking.  It’s not as important for static
functions, where GCC can figure this stuff out own its own.
* src/sysstdio.h (emacs_fopen): Add ATTRIBUTE_DEALLOC (fclose, 1).
* src/tparam.h (tparam): Add ATTRIBUTE_DEALLOC_FREE.
Include stdlib.h so that ‘free’ is declared.
* src/xterm.h (x_get_atom_name): Add ATTRIBUTE_DEALLOC_FREE.
2022-05-27 11:45:01 -07:00
Paul Eggert
7f3d781dab Pacify gcc -Wsuggest-attribute-malloc
* src/xterm.h (x_get_atom_name): Add ATTRIBUTE_MALLOC.
2022-05-27 11:45:01 -07:00
Eli Zaretskii
8399c6a821 Improve font selection on MS-Windows
The Arial Unicode MS font claims in its USB (Unicode Subset
Bitfields) values support for several scripts for which it
doesn't actually have glyphs.  This sometimes caused Emacs to
decide to use Arial Unicode MS for some script, only to
discover later that there are no glyphs for that script's
characters.  This change fixes the USB values according to
actual font coverage, as determined by BabelMap.
* src/w32font.c (add_font_entity_to_list): Fix USB values of Arial
Unicode MS font according to its actual coverage of scripts.
2022-05-27 15:12:09 +03:00
Po Lu
82b75a97ba Fix GNUstep build
* src/nsterm.h (NSPasteboardNameGeneral): Fix definition.
2022-05-27 17:11:59 +08:00
Po Lu
5d2523dcd0 Fix NS drag and drop on macOS
* lisp/term/ns-win.el (gui-backend-set-selection):
* src/nsselect.m (Fns_begin_drag): Fix deprecation warnings and
selection/value mixup.
2022-05-27 17:11:07 +08:00
Po Lu
27de58af8b Implement some drag and drop functions on NS
* lisp/term/ns-win.el (ns-selection-exists-p):
(gui-backend-set-selection):
(x-begin-drag): New functions and selection types.
* src/nsfns.m (Fns_get_resource):
(Fns_set_resource):
(Fx_server_max_request_size): Fix coding style.
* src/nsselect.m (ns_decode_data_to_pasteboard):
(ns_lisp_to_pasteboard):
(ns_dnd_action_to_operation):
(ns_dnd_action_from_operation):
(Fns_begin_drag): New functions.
(syms_of_nsselect): New subrs.
* src/nsterm.h (EmacsWindow): New fields and messages.
(NSPasteboardNameGeneral): New define.
* src/nsterm.m ([EmacsView mouseDown:]): Store last mouse event.
([EmacsWindow initWithEmacsFrame:fullscreen:screen:]): Clear that event.
([EmacsWindow dealloc]): Free last mouse event.
2022-05-27 16:33:12 +08:00
Po Lu
edd11a2c6e Update comments in some X code
* src/xterm.c (x_parse_color): Update comment.
(syms_of_xterm): Add new debugging option too.
2022-05-27 14:40:43 +08:00
Po Lu
bb0317442b Fix XI scroll valuator reset on X Toolkit builds
* src/xterm.c (handle_one_xevent): Reset valuators on XI_Leave
if leave->event is an edit widget as well.
2022-05-27 10:34:04 +08:00
Po Lu
c0807daedc Improve lookup efficiency of color cache and prevent leaking
* src/xterm.c (x_parse_color): Move recently used colors to the
start of the cache and free unused entries when there are too
many.
(x_term_init, x_delete_display): Initialize and free new fields.
* src/xterm.h (struct x_display_info): New field
`color_names_length'.
2022-05-27 09:40:40 +08:00
Po Lu
8dcebc9629 Handle allocation errors when creating menu items on Haiku
* src/haiku_support.cc (class EmacsMenuItem): Don't abort on
failed strdup.
2022-05-27 00:24:12 +00:00
Po Lu
061c2d683f Fix longjmp/siglongjmp mixup
* src/xterm.c (xm_drag_window_io_error_handler)
(x_dnd_io_error_handler): Use `siglongjmp'.  Reported by Ken
Brown <kbrown@cornell.edu>.
2022-05-27 08:13:09 +08:00
Stefan Monnier
80ba4c1707 eval.c: New functions defvar-1 and defconst-1 (bug#55156)
The bytecode interpreter can't directly call special forms, so
the byte-compiler usually converts special forms into some sequence of
byte codes (basically, providing a duplicate definition of the special
form).  There are still two exceptions to this: `defconst` and `defvar`,
where the compiler instead generates a convoluted chunk of code like:

    (funcall '(lambda (x) (defvar <sym> x <doc>)) <value>)

where the quote makes sure we keep the function non-compiled, so as
to end up running the special form at run time.

Get rid of this workaround by introducing `defvar-1` and `defconst-1`
which provide a *functional* interface to the functionality of the
corresponding special form.

* src/eval.c (defvar, Fdefvar_1, Fdefconst_1): New functions, extracted from
`Fdefvar` and `Fdefconst`.
(Fdefvar, Fdefconst): Use them.
(syms_of_eval): `defsubr` the new functions.

* lisp/emacs-lisp/bytecomp.el (byte-compile-tmp-var): Delete const.
(byte-compile-defvar): Simplify using the new functions.

* doc/lispref/variables.texi (Defining Variables): Adjust the doc of
`defvar` to reflect the actual semantics implemented.
2022-05-26 12:21:32 -04:00
Po Lu
e490b80a10 Handle alternate actions for Motif drop targets
* src/xterm.c (xm_side_effect_from_action): Handle
`XdndActionAsk'.
(xm_operations_from_actions): New function.
(xm_send_top_level_leave_message, x_dnd_cleanup_drag_and_drop)
(x_dnd_update_state, handle_one_xevent, x_connection_closed):
Use those actions when building a side effect.
(x_dnd_begin_drag_and_drop): Keep track of the set of
alternative drag-and-drop actions.
2022-05-26 21:00:35 +08:00
Po Lu
036b72575a Fix the `x_trace_wire' option
* src/xterm.c (x_trace_wire):
(x_term_init): Fix debugging code for modern C and Xlib.
2022-05-26 14:37:27 +08:00
Po Lu
c67c7ab53c Use x_get_atom_name for some more things
* src/xterm.c (x_dnd_send_unsupported_drop, x_dnd_send_drop):
Use x_get_atom_name instead of XGetAtomName.
2022-05-26 14:27:32 +08:00