Stefan Kangas [Fri, 28 Feb 2025 17:28:58 +0000 (18:28 +0100)]
Lift widget functions from C to Lisp
In the mid-1990s, these functions were moved from Lisp to C to
"improve performance". However, Moore's Law, and perhaps other
improvements too, has made this rationale irrelevant.
On this machine, with --native-compilation=no, I observed only a
slight ~4% performance difference. For example, displaying a buffer
full of widgets (e.g., 'M-x customize RET browse-url RET') takes 4ms
here, meaning the performance gap is under 0.1ms. Even on less
powerful machines, this difference would remain imperceptible. Given
this, let's lift these functions back to to Lisp, which offers the
usual benefits.
We already have solid test coverage, but let's add a more focused test
for 'widget-get' and 'widget-put' to be thorough.
* lisp/wid-edit.el (widget-put, widget-get, widget-apply): Move to
Lisp from...
* src/fns.c (Fwidget_put, Fwidget_get, Fwidget_apply): ...here.
(syms_of_fns): Remove defsubrs for the above functions.
* test/lisp/wid-edit-tests.el
(widget-test-editable-field-widget-get/put): New test.
Eli Zaretskii [Fri, 28 Feb 2025 12:45:39 +0000 (14:45 +0200)]
Fix 'internal--c-header-file-path'
* lisp/subr.el (internal--c-header-file-path): Fix for MS-Windows:
don't prepend the (usually non-existent) "/usr/include", and run
each directory through 'expand-file-name' to remove the many ".."
elements and mirror any backslashes. Invoke "clang" if "gcc" is
not available or is actually clang.
* test/lisp/subr-tests.el
(subr-tests-internal--c-header-file-path): Fix for MS-Windows:
test the path by looking for stdio.h, and expand all directory
names to compare to expected results.
Po Lu [Fri, 28 Feb 2025 11:49:34 +0000 (19:49 +0800)]
Fully support Lisp threads on Android
* src/android.c (struct android_thread_event_queue): New
structure. Move global pselect arguments, mutexes, and
semaphores, and pipes here.
(struct android_event_queue) <select_mutex, select_thread>:
Remove to the above-named struct.
(android_init_thread_events, android_finalize_thread_events)
(android_get_poll_thread): New functions.
(android_run_select_thread): Accept a set of mutexes and
thread-local data as the first argument, and operate with them
rather than globals.
(android_handle_sigusr1): Rename to
`android_handle_poll_signal'. Set thread-specific cancellation
indicator.
(android_init_events): Properly abort after a fatal condition.
Enable interruptible polling on Android 5.1 and later, not 4.2.
(android_select): Never check for queries here, but in
thread_select, if threads are enabled. Adapt to per-thread
polling threads and only enable interruptible polling on Android
5.1 and later.
(android_before_select): New function.
* src/android.h (android_before_select): New declaration.
* src/thread.c (thread_select): Call `android_before_select'
before the global lock is released.
Paul Eggert [Thu, 27 Feb 2025 18:57:19 +0000 (10:57 -0800)]
Fix fns-tests-collate-strings failure with musl
* test/src/fns-tests.el (fns-tests-collate-strings):
Don’t assume "en_XY.UTF-8", or any particular string,
is an invalid locale, as they all seem to be valid in musl.
Instead, simply test that a non-string is invalid.
(Bug#76550)
Eshel Yaron [Thu, 27 Feb 2025 14:34:24 +0000 (15:34 +0100)]
; (completion-preview-complete): Fix bug#76606
* lisp/completion-preview.el (completion-preview-complete):
Dismiss completion preview before calling ':exit-function'.
This eliminates potential flicker with slow exit functions
and avoids the broken preview update reported in bug#76606.
Stefan Kangas [Wed, 26 Feb 2025 02:31:57 +0000 (03:31 +0100)]
; Fix up emacs-lisp-mode docstring
* lisp/progmodes/elisp-mode.el (emacs-lisp-mode, lisp-interaction-mode):
Fix up docstring slightly by removing redundant and misplaced word
"Commands", and prefix list with dashes.
* doc/misc/ert.texi (Syntax Highlighting Tests):
* test/lisp/emacs-lisp/ert-font-lock-tests.el
(test-line-comment-p--emacs-lisp, test-line-comment-p--shell-script)
(test-line-comment-p--javascript, test-line-comment-p--python)
(test-line-comment-p--c, test-macro-test--correct-highlighting)
(test-macro-test--docstring, test-macro-test--failing)
(test-macro-test--file, test-macro-test--file-no-asserts)
(test-macro-test--file-failing): Reindent macro calls.
(with-temp-buffer-str-mode): Evaluate macro arguments left-to-right.
(ert-font-lock--wrap-begin-end): Use rx for more robust composition.
(test-line-comment-p--php): Require that php-mode is callable, not
already loaded.
* lisp/emacs-lisp/ert-font-lock.el (ert-font-lock-deftest)
(ert-font-lock-deftest-file): NAME is not followed by an empty list
like in ert-deftest, so the optional DOCSTRING is actually the
second argument. Adapt calling convention in docstring, and debug,
doc-string, and indent properties accordingly (bug#76372). Fix
docstring grammar, document MAJOR-MODE, and avoid referring to a
file name as a path.
Stefan Kangas [Sat, 22 Feb 2025 03:16:21 +0000 (04:16 +0100)]
Don't document deleted xwidget functions
* doc/lispref/display.texi (Xwidgets): Don't document deleted function
xwidget-webkit-execute-script-rv. Fix name of deleted and then re-added
function xwidget-webkit-title.
Yuan Fu [Sun, 23 Feb 2025 07:24:38 +0000 (23:24 -0800)]
Use character position for ranges in treesit_sync_visible_region
* src/treesit.c (treesit_sync_visible_region): Use character position
instead of byte position when comparing to ranges, because the
ranges are in character position.
Yuan Fu [Fri, 28 Feb 2025 01:18:28 +0000 (17:18 -0800)]
Support alternative range function for tree-sitter range settings
Some embedded parser needs to exclude child nodes from the
range, like markdown-inline. So I added this keyword that
allows users to customize the range for the embedded parser.
This can also be potentially useful for markdown comments in
rust, for example, because we want to exclude the comment
starters (//) from the embedded markdown parser.
* lisp/treesit.el (treesit-query-range):
(treesit-query-range-by-language): Add new parameter RANGE-FN.
(treesit-range-settings): Add new field RANGE-FN.
(treesit-range-rules): Add new keyword RANGE-FN.
(treesit-range-fn-exclude-children): New function.
(treesit--update-ranges-non-local):
(treesit--update-ranges-local):
(treesit--update-range-1): Support the RANGE-FN field.
Yuan Fu [Thu, 27 Feb 2025 11:10:47 +0000 (03:10 -0800)]
Rework range facility in treesit.el to support arbitrary nesting
Make use of the newly added embed-level parser property, we now
iterativeLy create/update embedded parsers at each embed level,
allowing arbitrary levels of nesting.
At the beginning, we start with the primary parser. We query it
with each range settings, gets some ranges and their
corresponding language. Then we create the first level of
embedded parsers using the ranges and language we got. This is
one iteration. For the next iteration/level, we start with the
embedded parsers we create/updated in the previous
iteration/level, and query each of them with each of the range
settings, creating/updating the next level of embedded parsers.
And we keep doing this until we don't get more matches from the
queries.
We now also support the :embed keyword in 'treesit-range-rules'
to be a function that returns a language. This allows major
modes like markdown and org mode to support code blocks of which
the language isn't known ahead of time.
* lisp/treesit.el (treesit-primary-parser): Move to front.
(treesit-query-range-by-language): New function.
(treesit-range-rules): Allow :embed to be a function, update docstring.
(treesit-local-parsers-on): Update docstring.
(treesit--parser-at-level):
(treesit--update-ranges-non-local): New functions.
(treesit--update-ranges-local): Use the new logic, support
:embed being a function.
(treesit--update-range-1): New function, has the meat of
original treesit-update-ranges.
(treesit-update-ranges): Implements the iteration logic using
treesit--update-range-1 to do the actual work.
Yuan Fu [Thu, 27 Feb 2025 11:07:34 +0000 (03:07 -0800)]
Enable treesit-query-capture to return grouped captures
This is needed for creating embedded parsers for embedded code
blocks of which language cannot be known ahead of time. E.g.,
markdown and org mode's code block.
Yuan Fu [Thu, 27 Feb 2025 11:05:26 +0000 (03:05 -0800)]
Add tree-sitter-parser-embed-level and parent-node
Add parser properties embed-level and parent-node. They'll be
help us implement arbitrarily nested embeded parser, and
navigation across embedded and host parsers, respectively.
* src/treesit.c:
(Ftreesit_parser_embed_level):
(Ftreesit_parser_set_embed_level):
(Ftreesit_parser_parent_node):
(Ftreesit_parser_set_parent_node): New functions.
Philipp Stephani [Thu, 30 Jan 2025 15:12:49 +0000 (16:12 +0100)]
Don't overwrite non-local exit symbol and data (Bug#65796).
The previous approach would incorrectly invalidate the returned module
values if another non-local exit occurred while dealing with a non-local
exit. See Bug#65796. Instead, allocate the values from the usual
environment storage, and return statically-allocated objects if that
fails.
* src/emacs-module.c (struct emacs_env_private): Turn non-local exit
symbol and data into normal Lisp objects.
(initialize_environment): Initialize them.
(mark_module_environment): Prevent them from being garbage-collected.
(module_signal_or_throw, module_non_local_exit_signal_1)
(module_non_local_exit_throw_1): Adapt uses.
(value_to_lisp): No longer scan for them with module assertions enabled.
(module_out_of_memory_signal, module_out_of_memory_data): New
statically-allocated module values to return in case of allocation
failure.
(syms_of_module): Initialize them.
(module_non_local_exit_get): Allocate module values normally. If that
fails, return statically-allocated values.
* doc/lispref/internals.texi (Module Nonlocal): Document new behavior.
Visuwesh [Thu, 20 Feb 2025 14:49:32 +0000 (20:19 +0530)]
Recommend 'tab-bar-history-mode' over 'winner-mode'
* lisp/winner.el (winner-mode):
* lisp/tab-bar.el (tab-bar-mode): Update the docstring to
suggest 'tab-bar-history-mode' instead of 'winner-mode' when
using 'tab-bar-mode' instead. (Bug#76439)
Stephen Berman [Thu, 27 Feb 2025 11:13:26 +0000 (12:13 +0100)]
Prevent a todo-mode test from running with 'make check'
* test/lisp/calendar/todo-mode-tests.el
(todo-test-add-and-delete-file): Tag this test as unstable, since
it has been reported to fail unreproducibly (bug#58473) or
reproducibly only on the ZFS filesystem (bug#76381) and the causes
are still unknown.
Stephen Berman [Thu, 27 Feb 2025 11:03:24 +0000 (12:03 +0100)]
Prevent a todo-mode test from running with 'make check'
* test/lisp/calendar/todo-mode-tests.el
(todo-test-add-and-delete-file): Tag this test as unstable, since
it has been reported to fail unreproducibly (bug#58473) or
reproducibly only on the ZFS filesystem (bug#76381) and the causes
are still unknown.
Stephen Berman [Thu, 27 Feb 2025 10:51:22 +0000 (11:51 +0100)]
Prevent a todo-mode test from running with 'make check'
* test/lisp/calendar/todo-mode-tests.el
(todo-test-add-and-delete-file): Tag this test as unstable, since
it has been reported to fail unreproducibly (bug#58473) or
reproducibly only on the ZFS filesystem (bug#76381) and the causes
are still unknown.
Po Lu [Thu, 27 Feb 2025 01:53:41 +0000 (09:53 +0800)]
Fix drag-and-drop treatment of reused tooltip frames
* src/androidfns.c (Fx_show_tip): Set `tip_window' to that of
any reused tooltip frame.
* src/haikufns.c (unwind_create_frame): Return whether the frame
was destroyed, as on X.
(unwind_create_tip_frame, haiku_create_frame, Fx_show_tip):
Synchronize with X.
(do_unwind_create_frame): New function.
(tip_window): Remove unused variable.
* src/pgtkfns.c (pgtk_create_tip_frame): Rename to
pgtk_create_tip_frame.
(Fx_show_tip): Adjust accordingly. Set `tip_window' to that of
any reused tooltip frame.
* src/w32fns.c (Fx_show_tip):
* src/xfns.c (Fx_show_tip): Set `tip_window' to that of any
reused tooltip frame.
Stefan Monnier [Wed, 26 Feb 2025 14:13:04 +0000 (09:13 -0500)]
(define-ibuffer-op): Minor tweak to Shipmints's patch
* lisp/ibuf-macs.el (define-ibuffer-op): Evaluate `(active-)opstring`
args when defining the operation rather than every time the operation
is used. Move the `:autoload-end` marker back to the level of `progn`.
Mauro Aranda [Wed, 26 Feb 2025 11:06:14 +0000 (08:06 -0300)]
Avoid display bugs after editable-field widgets
* lisp/wid-edit.el (widget-specify-button): Don't add an
invisible space before the button to avoid bugs that surface
with the widget-field face. The Widget library is not
the one that puts a :box attribute for the button face, and we
can't control what library users put after editable-field
widgets.
(widget-specify-field): Rather, add the invisible space here,
after the newline. That way, we protect whatever comes after
the editable-field widget. (Bug#51550)
Eshel Yaron [Wed, 26 Feb 2025 19:41:09 +0000 (20:41 +0100)]
Add 'help-echo' hint to completion preview
* lisp/completion-preview.el
(completion-preview--propertize-for-mouse): New function.
* lisp/completion-preview.el (completion-preview--update)
(completion-preview--show)
(completion-preview-partial-insert)
(completion-preview-complete)
(completion-preview-next-candidate): Use it to propertize
completion preview text with mouse-related properties,
including a new 'help-echo' hint.
* lisp/completion-preview.el (completion-preview-insert)
(completion-preview-insert-word)
(completion-preview-insert-sexp)
(completion-preview-complete)
(completion-preview-prev-candidate)
(completion-preview-next-candidate): Use 'interactive' to
associate command with 'completion-preview-active-mode'
instead of using a bespoke 'completion-predicate' property.
(completion-preview-active-p): Declare obsolete.
Stefan Kangas [Wed, 26 Feb 2025 05:37:52 +0000 (06:37 +0100)]
Make define-global-minor-mode alias obsolete
* lisp/emacs-lisp/easy-mmode.el (define-global-minor-mode): Make alias
for old name obsolete, just in time for its 20th anniversary.
* test/lisp/emacs-lisp/lisp-mode-tests.el (test-font-lock-keywords):
* lisp/progmodes/subword.el (global-subword-mode)
(global-superword-mode): Don't use above obsolete name.
* lisp/emacs-lisp/lisp-mode.el (lisp-imenu-generic-expression)
(lisp-fdefs): Remove syntax highlighting for obsolete name.
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate--make-autoload):
Add comment mentioning the obsolete status of above alias.
* doc/lispref/loading.texi (Autoload): Don't document obsolete name.
Stefan Kangas [Wed, 26 Feb 2025 03:36:51 +0000 (04:36 +0100)]
Don't enable minor modes in diff-add-log-current-defuns
* lisp/vc/diff-mode.el (diff-add-log-current-defuns): Don't run mode
hooks when enabling major mode hooks. That fails if, for example,
paredit-mode is on emacs-lisp-mode-hook and it signaled due to
unbalanced parens.
* test/lisp/emacs-lisp/rmc-tests.el
(test-rmc--add-key-description)
(test-rmc--add-key-description/with-attributes)
(test-rmc--add-key-description/non-graphical-display)
(test-read-multiple-choice, test-read-multiple-choice-help):
Skip on Android in some wise or another.
Po Lu [Wed, 26 Feb 2025 02:35:00 +0000 (10:35 +0800)]
; Improve Android testing facilities
* test/infra/android/test-controller.el (ats-eval): Don't block
other processes.
(ats-run-test): Bind ert-remote-temporary-file-directory to nil
and always print messages into the output buffer.
(ats-upload-all-tests): New function.
(ats-run-all-tests): New argument SELECTOR. Only execute
already uploaded tests.
Po Lu [Wed, 26 Feb 2025 02:33:30 +0000 (10:33 +0800)]
Enable auto-revert-tests to pass on Android
* lisp/emacs-lisp/ert-x.el
(ert-remote-temporary-file-directory): Define to null-device on
Android.
* test/lisp/autorevert-tests.el
(auto-revert-test02-auto-revert-deleted-file): Provide for
situations where the watch descriptor is recreated by the
polling timer after a file notification is received.
Po Lu [Wed, 26 Feb 2025 01:56:46 +0000 (09:56 +0800)]
Guarantee delivery of inotify special events
* src/inotify.c (inotifyevent_to_event): Always match events
that are not encompassed by IN_ALL_EVENTS and which the
documentation implies are always delivered to callbacks.
* test/src/inotify-tests.el (inotify-file-watch-stop-delivery):
New test.