Po Lu [Mon, 21 Mar 2022 03:48:36 +0000 (11:48 +0800)]
Improve handling of input methods during drag-and-drop
* src/xterm.c (x_dnd_cleanup_drag_and_drop)
(x_dnd_begin_drag_and_drop): Stop removing IC and filter events
before dispatching them.
(x_filter_event): Actually filter events during DND.
(XTread_socket): Verify GenericEvents are actually input
extension events before ignoring them.
Augusto Stoffel [Sun, 20 Mar 2022 19:46:31 +0000 (20:46 +0100)]
Allow lazy highlight and match count while reading from minibuffer
* lisp/isearch.el (minibuffer-lazy-highlight-setup): New function, can
be added to 'minibuffer-setup-hook' to enable lazy highlight and count
while reading from minibuffer.
(minibuffer-lazy-count-format, minibuffer-lazy-highlight-transform,
minibuffer-lazy-highlight--overlay, minibuffer-lazy-highlight--count,
minibuffer-lazy-highlight--after-change,
minibuffer-lazy-highlight--exit): Auxiliary variables and functions
implementing the lazy highlight functionality while reading from
minibuffer.
Augusto Stoffel [Sun, 20 Mar 2022 19:43:10 +0000 (20:43 +0100)]
New hook, lazy-count-update-hook
* lisp/isearch.el (lazy-count-update-hook): New hook allowing to
display the lazy count in special ways.
(isearch-lazy-highlight-new-loop,
isearch-lazy-highlight-buffer-update): Run `lazy-count-update-hook' at
appropriate times.
* lisp/comint.el (comint-history-isearch-setup,
comint-history-isearch-end): Make sure no lazy count is displayed.
* lisp/simple.el (minibuffer-history-isearch-setup): Make sure no lazy
count is displayed.
Po Lu [Sun, 20 Mar 2022 01:53:52 +0000 (09:53 +0800)]
Improve behaviour of drag-n-drop during window manager operations
* src/xterm.c (x_dnd_begin_drag_and_drop): Select for some
events on the root window.
(x_dnd_update_state): New function.
(handle_one_xevent): Call that function when we get some events
from the root window substructure or the window manager.
(x_term_init): New atom `_NET_CLIENT_LIST_STACKING'.
* src/xterm.h (struct x_display_info): New atom
`_NET_CLIENT_LIST_STACKING'.
Paul Eggert [Sat, 19 Mar 2022 19:35:04 +0000 (12:35 -0700)]
valid_sp inline fix
* src/bytecode.c (valid_sp): static, not INLINE, as INLINE
should be used only in headers and between INLINE_HEADER_BEGIN
and INLINE_HEADER_END. No need for ‘inline’ here.
Paul Eggert [Sat, 19 Mar 2022 19:35:04 +0000 (12:35 -0700)]
Simplify alloc.c static function decls
* src/alloc.c: Omit unnecessary static function declarations.
Don’t use ‘inline static’ as the C standard says that keyword
order is obsolescent. Anyway, no need for ‘inline’ as compilers
inline without it well enough.
Paul Eggert [Sat, 19 Mar 2022 19:35:04 +0000 (12:35 -0700)]
Make native helper functions static
These don’t need to be extern, even with -flto, since
their addresses are taken.
* src/comp.c (helper_unwind_protect, helper_unbind_n)
(helper_save_restriction, helper_GET_SYMBOL_WITH_POSITION)
(helper_PSEUDOVECTOR_TYPEP_XUNTAG): Now static.
Paul Eggert [Sat, 19 Mar 2022 19:35:04 +0000 (12:35 -0700)]
Remove internal_condition_case_[345]
* src/comp.c (directory_files_matching) [WINDOWSNT]: New function.
(eln_load_path_final_clean_up) [WINDOWSNT]: Use it.
This removes the need for internal_condition_case_5.
* src/eval.c (internal_condition_case_3)
(internal_condition_case_4, internal_condition_case_5): Remove.
The first two were never used; the last only in now-removed code.
Make `command-modes' work for (native-compiled) subrs, too
* lisp/emacs-lisp/comp.el (comp-func): Add a command-modes slot.
(comp-spill-lap-function, comp-intern-func-in-ctxt): Fill it.
(comp-emit-for-top-level, comp-emit-lambda-for-top-level): Use it.
* src/alloc.c (mark_object): Mark the command_modes slot.
* src/comp.c (make_subr): Add a command_modes parameter.
(Fcomp__register_lambda): Use it.
(Fcomp__register_subr): Ditto.
* src/data.c (Fcommand_modes): Output the command_modes data for subrs
(bug#54437).
* src/lisp.h (GCALIGNED_STRUCT): Add a command_modes slot.
* src/pdumper.c (dump_subr): Update hash.
(dump_subr): Dump the command_modes slot.
Po Lu [Sat, 19 Mar 2022 10:46:50 +0000 (18:46 +0800)]
Improve protection against faulty clients during DND
* src/xterm.c (x_dnd_send_enter, x_dnd_send_position)
(xdnd_send_leave, x_dnd_send_drop): Catch errors around call to
XSendEvent. The target window could be gone.
Guy Gastineau [Sat, 29 Jan 2022 04:12:42 +0000 (23:12 -0500)]
Remove redundant checks in erc--switch-to-buffer
* lisp/erc/erc.el (erc--switch-to-buffer): Commit f925fc93bac41d7622d1af927e33b0e738ff55b0 "Add `predicate' arg to
`read-buffer' and use it for erc-iswitchb" meant to remove this, but
it was left behind. (Bug#53617)
Eli Zaretskii [Sat, 19 Mar 2022 07:19:53 +0000 (09:19 +0200)]
Fix region highlight in non-selected windows
* src/xdisp.c (prepare_menu_bars): Include in the windows passed
to pre-redisplay-functions windows whose point was moved from the
last recorded position. (Bug#54450)
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.