Using a plain C struct instead of type-punning Lisp_Object stack slots
makes the bytecode interpreter code more type-safe and potentially
faster (from better alias analysis), and the special-purpose accessors
are no longer needed. It also reduces the stack requirements when
using 64-bit Lisp_Object on 32-bit platforms.
* src/bytecode.c (enum stack_frame_index)
(sf_get_ptr, sf_set_ptr, sf_get_lisp_ptr, sf_set_lisp_ptr,
sf_get_saved_pc, sf_set_saved_pc): Remove.
(BC_STACK_SIZE): Now in bytes, not Lisp words.
(struct bc_frame): New.
(init_bc_thread, mark_bytecode, Finternal_stack_stats, valid_sp)
(exec_byte_code):
* src/lisp.h (struct handler, get_act_rec, set_act_rec):
Adapt to new struct bc_frame.
Po Lu [Thu, 17 Mar 2022 09:41:41 +0000 (17:41 +0800)]
Prevent invisible frames from acting as drag sources
* src/xterm.c (x_dnd_begin_drag_and_drop): Error out if f is
invisible. It makes no sense for an invisible frame to be a
drag source, so the function just hangs.
Po Lu [Thu, 17 Mar 2022 08:51:32 +0000 (08:51 +0000)]
Fix creating frames with an initial value of `fullscreen' on Haiku
* src/haikufns.c (haiku_create_frame): Set configury_done and do
pending fullscreen change if any.
* src/haikuterm.c (haiku_fullscreen): Defer actually setting
fullscreen until configury_done is set.
* src/haikuterm.h (struct haiku_output): New field
`configury_done'.
Po Lu [Thu, 17 Mar 2022 07:12:23 +0000 (15:12 +0800)]
Display drag-and-drop messages in echo area on non-graphics displays
* lisp/mouse.el (mouse-drag-and-drop-region-display-tooltip)
(mouse-drag-and-drop-region-hide-tooltip): New functions.
(mouse-drag-and-drop-region): Use them instead of calling
`x-hide-tip' and `x-show-tip' directly.
Po Lu [Thu, 17 Mar 2022 05:31:03 +0000 (05:31 +0000)]
Prevent delivery of duplicate events when window is grabbed on Haiku
* src/haiku_support.cc (grab_view, grab_view_locker): New
variables.
(MouseMoved, MouseDown, MouseUp): Keep track of the grab and
don't deliver motion events to any other view.
Po Lu [Thu, 17 Mar 2022 03:42:19 +0000 (03:42 +0000)]
Implement cross-program drag-and-drop on Haiku
* doc/lispref/frames.texi (Drag and Drop): Fix documentation of
`x-begin-drag' to match actual function arity.
* lisp/term/haiku-win.el (haiku-dnd-selection-value): New
variable.
(haiku-dnd-selection-converters): New variable.
(haiku-dnd-convert-string): New function.
(gui-backend-get-selection, gui-backend-set-selection): Handle
XdndSelection specially.
(x-begin-drag): New function.
* src/haiku_select.cc (be_create_simple_message)
(be_add_message_data): New functions.
* src/haiku_support.cc (WAIT_FOR_RELEASE): New message type.
(class EmacsView, MouseUp): If waiting for release, reply and
drop event.
(be_drag_message, be_drag_message_thread_entry): New functions.
* src/haiku_support.h: Update prototypes.
* src/haikuselect.c (lisp_to_type_code, haiku_lisp_to_message)
(Fhaiku_drag_message): New functions.
(syms_of_haikuselect): Define new subr.
Paul Eggert [Thu, 17 Mar 2022 00:21:55 +0000 (17:21 -0700)]
Improve random bignum generation
* src/bignum.c (get_random_limb, get_random_limb_lim)
(get_random_bignum): New functions, for more-efficient
generation of random bignums without using Frem etc.
* src/fns.c (get_random_fixnum): New function.
(Frandom): Use it, and get_random_bignum.
Be consistent about signalling nonpositive integer arguments;
since zero is invalid, Qnatnump is not quite right here.
* src/sysdep.c (get_random_ulong): New function.
Alan Mackenzie [Wed, 16 Mar 2022 19:23:24 +0000 (19:23 +0000)]
Strip positions from symbols before the eval in eval-{when,and}-compile.
This fixes bug #54079.
* lisp/emacs-lisp/bytecomp.el (byte-compile-initial-macro-environment): Change
the position of 'byte-run-strip-symbol-positions' in the eval-when-compile
entry. Add a call to `byte-run-strip-symbol-positions' in the
eval-and-compile entry.
Robert Pluim [Sat, 26 Feb 2022 10:46:32 +0000 (11:46 +0100)]
Guard against custom entries that can contain NULs
There are custom entries that contain lambda's as values by default,
which can result in them containing embedded NULs after
byte-compilation, which wreaks havoc when they are saved to .emacs and
later read in. (Bug#52554)
* lisp/cus-edit.el (custom-save-all): Bind
print-escape-control-characters to t.
* lisp/startup.el (startup--load-user-init-file): Bind
inhibit-null-byte-detection to t.
Robert Pluim [Wed, 9 Feb 2022 09:01:36 +0000 (10:01 +0100)]
Improve error message for 'not running' processes
The current error message is simply 'not running', but
'status_message' can give information about why the process is in that
state, such as network errors, so return that as well. (Bug#53762)
* src/process.c (send_process, Fprocess_send_eof): Add the output of
'status_message' to the error string.
Po Lu [Wed, 16 Mar 2022 13:18:12 +0000 (13:18 +0000)]
Redo Haiku DND support
* lisp/term/haiku-win.el (haiku-dnd-handle-drag-n-drop-event):
Update for new DND event format.
* src/haiku_io.c (haiku_len): Handle DRAG_AND_DROP_EVENTs.
* src/haiku_select.cc (be_enum_message, be_get_refs_data)
(be_get_message_data): New function.
* src/haiku_support.cc (class Emacs): Remove `RefsReceived'.
(MessageReceived): Generate new kind of drag-n-drop events.
* src/haiku_support.h (enum haiku_event_type): Rename
`REFS_EVENT' to `DRAG_AND_DROP_EVENT'.
(struct haiku_refs_event): Delete struct.
(struct haiku_drag_and_drop_event): New struct.
* src/haikuselect.c (haiku_message_to_lisp): New function.
(syms_of_haikuselect): New symbols.
* src/haikuselect.h: Update prototypes.
* src/haikuterm.c (haiku_read_socket): Handle new type of
drag-and-drop events by serializing drop message to Lisp and
letting Lisp code do the processing.
* src/haikuterm.h: Update prototypes.
Po Lu [Wed, 16 Mar 2022 11:43:06 +0000 (19:43 +0800)]
Pacify compiler warning in handle_one_xevent
* src/xterm.c (x_dnd_get_target_window): Set proto_out even if
it won't be used because target is None. Reported by Lars
Ingebrigtsen <larsi@gnus.org>.
Po Lu [Wed, 16 Mar 2022 09:03:19 +0000 (17:03 +0800)]
Fix minor bugs with XDND support
* lisp/mouse.el (mouse-drag-and-drop-region): Report more
selection targets for the benefit of Qt and Mozilla.
* lisp/select.el (xselect--encode-string)
(selection-converter-alist): Add new selection targets.
* src/xterm.c (x_dnd_get_window_proxy): New function.
(x_dnd_get_target_window): New argument proto_out, and return
first window with XdndAware instead of bottommost window.
(handle_one_xevent): Use new argument `proto_out'.
Po Lu [Wed, 16 Mar 2022 04:33:15 +0000 (12:33 +0800)]
Better handle drag-and-drop from one Emacs frame to another
* doc/lispref/frames.texi (Drag and Drop): Document new
parameter `return-frame' to `x-begin-drag'.
* lisp/mouse.el (mouse-drag-and-drop-region): Utilize new
feature.
* src/xfns.c (Fx_begin_drag): New parameter `return-frame'.
* src/xterm.c (x_dnd_begin_drag_and_drop): New parameter
return_frame_p.
(handle_one_xevent): Set new flags and return frame whenever
appropriate.
* src/xterm.h: Update prototypes.
Po Lu [Wed, 16 Mar 2022 03:29:36 +0000 (11:29 +0800)]
Add support for dragging text from Emacs to other programs
This still probably needs some more protection from
malfunctioning clients which delete windows at random, but I
don't know if that's a problem in practice.
* doc/emacs/frames.texi (Drag and Drop):
* doc/lispref/frames.texi (Drag and Drop): Document new
features.
* etc/NEWS: Announce new function `x-begin-drag' and new user
option `mouse-drag-and-drop-region-cross-program'.
* lisp/mouse.el (mouse-drag-and-drop-region-cross-program): New
user option.
(x-begin-drag): New variable declaration.
(mouse-drag-and-drop-region): If the mouse moves out of an Emacs
frame, begin a window system drag.
* lisp/x-dnd.el (x-dnd-handle-xdnd): Remove left-over debugging
code.
* src/xfns.c (Fx_set_mouse_absolute_pixel_position): Fix
indentation of opening paren.
(Fx_begin_drag): New function.
(syms_of_xfns): Define new subr.
* src/xselect.c (x_timestamp_for_selection): New function.
* src/xterm.c (X_DND_SUPPORTED_VERSION): New preprocessor
declaration.
(x_dnd_get_window_proto, x_dnd_send_enter, x_dnd_send_position)
(x_dnd_send_leave, x_dnd_send_drop, x_set_dnd_targets)
(x_dnd_begin_drag_and_drop): New functions.
(handle_one_xevent): Handle drag-and-drop motion and button
events when active.
(x_free_frame_resources): If f is the DND source, stop
drag-and-drop.
(x_term_init): Intern new atoms.
(syms_of_xterm): New symbol QXdndSelection.
Stefan Monnier [Tue, 15 Mar 2022 14:12:46 +0000 (10:12 -0400)]
doctex-mode: Try and fix bug#35140
* lisp/textmodes/tex-mode.el (doctex-syntax-propertize-rules):
Add support for the new ^^X and consider the first ^ of ^^A to be the
closing char for the previous comment.
(doctex-font-lock-^^A): Simplify accordingly.
Paul Eggert [Mon, 14 Mar 2022 20:14:23 +0000 (13:14 -0700)]
Another fix for the no-toolkit build
This should be better in the long run.
* oldXMenu/Activate.c (XMenuActivate): Revert previous change,
eliminating the goto it introduced.
* oldXMenu/XMenuInt.h: Include <attribute.h>, for FALLTHROUGH.
Paul Eggert [Mon, 14 Mar 2022 15:55:46 +0000 (08:55 -0700)]
Prefer CALLN
* src/bytecode.c (Fbyte_code):
* src/composite.c (Fclear_composition_cache):
Prefer CALLN to doing it by hand.
* src/fns.c (ccall2): Remove. All uses replaced by CALLN.
Sam Steingold [Fri, 11 Mar 2022 18:59:46 +0000 (13:59 -0500)]
New command `gnus-summary-browse-all-urls' bound to "v"
* lisp/gnus-sum.el (gnus-collect-urls-from-article): New function,
extracted from `gnus-summary-browse-url'.
(gnus-summary-browse-url): Use it; also use `browse-url-button-open-url'
to handle the prefix argument.
(gnus-summary-browse-all-urls): New command.
(gnus-summary-mode-map): Bind `gnus-summary-browse-all-urls' to "v".
Philipp Stephani [Mon, 14 Mar 2022 09:59:03 +0000 (10:59 +0100)]
Make Edebug specification for 'cl-defstruct' more lenient.
For example, 'xref-item' uses the list form of ':noinline'.
* lisp/emacs-lisp/cl-macs.el (cl-defstruct): Accept ':noinline' and
':named' with an argument.
* test/lisp/emacs-lisp/cl-macs-tests.el (cl-defstruct/edebug): New
unit test.
Po Lu [Mon, 14 Mar 2022 06:48:34 +0000 (06:48 +0000)]
Clean up some Haiku toolkit code
* src/haiku_io.c (haiku_read_with_timeout): Accept `bigtime_t'
instead of `time_t' for values which are cast to bigtime_t
anyway.
* src/haiku_support.cc (BMenu_run): Read all help events instead
of just one.
* src/haiku_support.h: Update prototypes.
Po Lu [Mon, 14 Mar 2022 02:45:55 +0000 (02:45 +0000)]
Fix extraneous overscroll activation on Haiku
* src/haiku_support.cc (class EmacsScrollBar): New field
`maybe_overscroll'.
(MouseDown): Set that field.
(MouseUp): Clear that field.
(MouseMoved): Also test `maybe_overscroll' to ensure that a grab
started inside the scroll bar.
Use a dedicated stack for bytecode, instead of using the C stack.
Stack frames are managed explicitly and we stay in the same
exec_byte_code activation throughout bytecode function calls and
returns. In other words, exec_byte_code no longer uses recursion
for calling bytecode functions.
This results in better performance, and bytecode recursion is no
longer limited by the size of the C stack. The bytecode stack is
currently of fixed size but overflow is handled gracefully by
signalling a Lisp error instead of the hard crash that we get now.
In addition, GC marking of the stack is now faster and more precise.
Full precision could be attained if desired.
Pass the function object and encoded arity, not the other components.
This speeds up several call paths and is necessary for improvements to
come.
* src/bytecode.c (Fbyte_code): Make a new byte code object for
execution. This is slower but performance isn't critical here.
(exec_byte_code): Retrieve components from the passed function.
* src/eval.c (fetch_and_exec_byte_code):
* src/lisp.h (exec_byte_code): Update signature.
* test/lisp/eshell/esh-proc-tests.el (esh-proc-test/kill-pipeline):
Add pattern matching output when killing a process on macOS (and
possibly other BSDs).