Eli Zaretskii [Sat, 1 Mar 2025 14:04:52 +0000 (16:04 +0200)]
Fix 'M-q' in 'makefile-mode'
* lisp/progmodes/make-mode.el (makefile-mode-map): Bind 'M-q' to
'fill-paragraph', as 'prog-mode's default binding is not
appropriate for Makefile's syntax. (Bug#76641)
Eli Zaretskii [Sat, 1 Mar 2025 13:45:57 +0000 (15:45 +0200)]
; Improve documentation of 'rmail-movemail-program'
* lisp/mail/rmail.el (rmail-movemail-program):
* doc/emacs/rmail.texi (Movemail): Document how to change the
value of 'rmail-movemail-program' safely. (Bug#76595)
Tassilo Horn [Sun, 23 Feb 2025 08:46:54 +0000 (09:46 +0100)]
doc-view: Fix error during revert in editing mode
When in editing mode in a doc-view buffer and then reverting (which can
happen automatically when editing OpenDocument contents), we errored in
the advide function doc-view--revert-buffer because the local
doc-view--buffer-file-name has been killed when switching to the editing
mode.
Also restore doc-view-minor-mode after reverting during being in the
editing mode.
* lisp/doc-view.el (doc-view--revert-buffer): Check that
'doc-view--buffer-file-name' is non-nil.
(doc-view-minor-mode): Add re-enabling function to
'revert-buffer-restore-functions'.
Trevor Murphy [Wed, 12 Feb 2025 01:26:55 +0000 (17:26 -0800)]
Ignore dedicated windows in 'display-buffer-reuse-mode-window'
Ignore the dedicated windows unless the dedicated window is
already displaying the buffer-to-be-displayed. In that case,
the window may be reused, according to the setting of
'inhibit-same-window'.
* lisp/window.el (display-buffer-reuse-mode-window): Check
'window-dedicated-p' before pushing the candidate window onto
the stack. (Bug#76216)
Eli Zaretskii [Sat, 1 Mar 2025 10:59:32 +0000 (12:59 +0200)]
; Document what happens when 'display' and 'invisible' props clash
* doc/lispref/display.texi (Replacing Specs, Overlay Properties)
(Invisible Text): Document that 'invisible' is ignored when
'display' property covers the same text. (Bug#76658)
Eli Zaretskii [Sat, 1 Mar 2025 08:27:17 +0000 (10:27 +0200)]
Save IELM input history on "C-c C-c"
* lisp/ielm.el (ielm--write-history-on-interrupt): New function.
(inferior-emacs-lisp-mode): Install it as buffer-local value of
the 'interrupt-process-functions' hook. (Bug#76585)
Łukasz Stelmach [Wed, 7 Feb 2024 13:37:39 +0000 (14:37 +0100)]
Fix handling of delta values with negative month field
* lisp/calendar/time-date.el (decoded-time-add): If the new
variable is less then zero, the year needs to be decremented
by quotient of new and 12 increased by one.
* test/lisp/calendar/time-date-tests.el (test-decoded-add):
Add applicable test cases. (Bug#68969)
Stefan Kangas [Sat, 1 Mar 2025 02:22:30 +0000 (03:22 +0100)]
grep: Signal error if unable to access directory
* lisp/progmodes/grep.el (lgrep, rgrep): grep: Signal error if unable to
access directory, instead of just trying to use default-directory,
because that level of DWIMishness is confusing. (Bug#71078)
Stefan Kangas [Fri, 28 Feb 2025 18:59:12 +0000 (19:59 +0100)]
; Grammar fixes for "native-compiled"
1. Prefer "native-compiled" to "native compiled".
The adjective "native-compiled" with the hyphen is generally more
consistent with the typical pattern in English, especially when the
compound modifies a noun (e.g., "native-compiled code").
2. Prefer "natively compiled" to "natively-compiled".
The adverb "natively" modifies "compiled", and it is standard not
to hyphenate an adverb + adjective combination when the adverb ends
in -ly (e.g., "code that is natively compiled").
For example, note that we say "high-speed internet" but "highly
performant code".
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)