Po Lu [Sat, 19 Mar 2022 07:00:11 +0000 (07:00 +0000)]
Ignore drag source frame on Haiku in line with documentation
* src/haiku_support.cc (class EmacsWindow): New field
`window_id'.
(MessageReceived): Ignore dropped messages with same window id.
(be_drag_message): Add source frame's window ID to message.
Po Lu [Sat, 19 Mar 2022 01:11:09 +0000 (09:11 +0800)]
Handle composite overlay window during drag and drop sessions
* configure.ac: Test for the composite extension and use it if
available.
* msdos/sed1v2.inp: Update.
* src/Makefile.in (XCOMPOSITE_LIBS, XCOMPOSITE_CFLAGS): New
variables.
(EMACS_CFLAGS, LIBES): Add new libs and cflags.
* src/xterm.c (x_dnd_get_target_window): Look for proxy on
composite overlay window if mapped.
(x_term_init): Test if the composite extension is available.
* src/xterm.h (struct x_display_info): New fields for composite
extension presence.
Po Lu [Fri, 18 Mar 2022 23:45:14 +0000 (07:45 +0800)]
Fix some XIM servers getting confused during drag-and-drop
* src/xterm.c (x_dnd_begin_drag_and_drop): Clear XIC while event
loop is in progress.
(x_filter_event): Return 0 if DND is in progress.
(xim_instantiate_callback): Likewise.
Functions on `completion-at-point-functions` should not modify
the buffer. Pcomplete itself mostly abides by this but Eshell's
use of it doesn't. Try and catch those cases. Also fix one of
those cases.
* lisp/pcomplete.el (pcomplete-allow-modifications): New var.
(pcomplete-completions-at-point): Enforce it.
(pcomplete, pcomplete-expand-and-complete, pcomplete-expand):
Rebind it since these commands expect the extra side effects.
* lisp/eshell/em-cmpl.el (eshell--pcomplete-insert-tab): New function,
extracted from `eshell-complete-parse-arguments`.
(eshell-complete-parse-arguments): Use it and obey
`pcomplete-allow-modifications`.
Do the binary-to-decimal conversion by hand for fixnums instead of
calling sprintf. This results in a noticeable speed increase (on my
machine, 2.2× faster excluding GC).
* src/data.c (Fnumber_to_string): Don't use sprintf for fixnums.
Po Lu [Fri, 18 Mar 2022 09:21:39 +0000 (09:21 +0000)]
Implement drag-and-drop of files on Haiku
* lisp/term/haiku-win.el (haiku-dnd-selection-converters): Add
new selection converter.
(haiku-dnd-convert-uri-list): New function.
(x-begin-drag): Allow selection converters to change message
field type.
* src/haikuselect.c (haiku_lisp_to_message): Perform more error
checking.
Po Lu [Fri, 18 Mar 2022 05:17:19 +0000 (13:17 +0800)]
Allow dragging files from Dired to other programs
* etc/NEWS: Announce new user option `dired-mouse-drag-files'.
* lisp/dired.el (dired-mouse-drag-files): New user option.
(dired-mouse-drag): New command.
(dired-mouse-drag-files-map): New variable.
(dired-insert-set-properties): Add additional keymap if mouse
dragging is enabled.
* lisp/select.el (xselect-convert-to-targets): Handle new
form of selection converters.
(xselect-convert-to-username):
(xselect-convert-to-text-uri-list):
(xselect-uri-list-available-p): New functions.
(selection-converter-alist): Add them as selection converters.
* src/xselect.c (x_get_local_selection): Handle new form of
selection converters.
(syms_of_xselect): Update doc strings.
Stefan Monnier [Thu, 17 Mar 2022 23:07:59 +0000 (19:07 -0400)]
Remove some early-bootstrap dependencies for `advice`
The dependencies between `advice`, cl-generic`, `bytecomp`, `cl-lib`,
`simple`, `help`, ... were becoming unmanageable.
Break the reliance on `advice` (which includes making sure the
compiler is not needed during the early bootstrap).
* lisp/simple.el (pre-redisplay-function): Set without using `add-function`.
* lisp/loadup.el (advice, simple): Move to after `cl-generic`.
* lisp/help.el (command-error-function): Set without using `add-function`.
(help-command-error-confusable-suggestions): Explicitly call
`command-error-default-function` instead.
* lisp/emacs-lisp/cl-macs.el (pcase--mutually-exclusive-p): Don't
optimize during early-bootstrap.
* lisp/emacs-lisp/cl-generic.el (cl--generic-lambda): Tiny simplification.
(cl-defmethod): Label the obsolescence warning as it should.
(cl--generic-compiler): New variable.
(cl--generic-get-dispatcher): Use it.
(cl--generic-prefill-dispatchers): Make freshly made dispatchers.
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.