This adds support for animations with heterogeneous frame durations
without sacrificing CPU (bug#47895), and plugs a memory leak in and
speeds up WebP animations (bug#66221).
* lisp/image.el (image-animate): No need to stash
image-multi-frame-p data here, as image-animate-timeout now
refetches it for each animation frame.
(image-show-frame): Fetch image-multi-frame-p anew when checking
bounds; a cached value risks going stale. This is not on the hot
path for animations, and is mainly used when framewise stepping
through an animation interactively.
(image-animate-timeout): Fetch current frame duration anew but do so
before image-show-frame to ensure an image cache hit (bug#47895,
bug#66221). Include time taken by local arithmetic in
'time-to-load-image'. Update commentary.
* src/image.c (parse_image_spec): Simplify using FIXNATP.
(filter_image_spec): Remove check for :animate-multi-frame-data as
it is no longer used by image.el.
[HAVE_ANIMATION && HAVE_GIF] (struct gif_anim_handle):
[HAVE_ANIMATION && HAVE_WEBP] (struct webp_anim_handle): New
structures formalizing animation cache handles, and allowing for
more than two custom fields per image type.
(struct anim_cache): Replace generic handle and temp pointers with a
union of gif_anim_handle and webp_anim_handle. All uses updated.
Update destructor signature accordingly.
(anim_create_cache): Use xzalloc to zero-initialize both integer and
pointer fields. Initialize frames, width, height to -1 for
consistency with index. Mark as ATTRIBUTE_MALLOC.
(anim_prune_animation_cache): Check whether destructor (not handle)
is null before calling it.
(gif_clear_image): Note in commentary that WebP also uses it.
(gif_destroy): Free pixmap here now that prune_anim_cache no longer
does it automatically. Remove unused gif_err variable.
(gif_load): Avoid UB from casting destructor to a different type.
Don't redundantly check for null before xfree. Change default frame
delay from 15fps to t, which image-multi-frame-p will translate into
image-default-frame-delay, which the user can control.
[HAVE_WEBP && WINDOWSNT] (init_webp_functions): Reconcile library
definitions with current webp_load implementation.
(webp_destroy): Free owned copy of input WebP bitstream contents.
(webp_load): Ownership of both input and decoded memory is a
function of :data vs :file and animated vs still. Make this and
transfers of ownership to animation cache clearer by using distinct
copy/view variables. Also make resource freeing clearer by using a
single unconditional cleanup and exit path. Check animation cache
early to avoid rereading bitstream and reparsing headers on each
call. Remove redundant call to WebPGetInfo since WebPGetFeatures
does the same thing. Check more libwebpdemux return values for
failure and fix file name reported in error messages. Remove unset
local variable 'file'. If requested :index is ahead, fast-forward
instead of restarting from first frame. If requested :index is
behind, reset animation decoder to first frame instead of deleting
and recreating it. Reuse animation decoder's own WebPAnimInfo and
WebPDemuxer instance instead of creating and deleting a separate
WebPDemuxer. Fix leak when copying :data to animation cache. Fix
frame duration calculation, and return each frame's own duration now
that image.el supports it. Return t as a default frame duration, as
per gif_load. Consistently use WebPBitstreamFeatures to simplify
control flow. Don't pollute lisp_data image-metadata for still
images with animation-related properties.
(image_types) [HAVE_WEBP]: Use gif_clear_image to clear lisp_data
for consistency with GIF code.
(syms_of_image): Remove QCanimate_multi_frame_data; no longer used.
* doc/lispref/display.texi (Image Cache): Document animation cache
argument that clear-image-cache gained in Emacs 29 (bug#56546,
bug#66221).
* lisp/image.el (image-animate-timeout): Note limitation of
clear-image-cache with ImageMagick.
* src/image.c (Fclear_image_cache): Rename animation-cache argument
to animation-filter and expand its description for clarity.
(struct anim_cache, anim_create_cache, image_prune_animation_caches):
Improve commentary.
(mark_image_cache): Replace stale commentary that referred to
forall_images_in_image_cache with description of mark_image_cache.
[HAVE_IMAGEMAGICK] (struct animation_cache): Mention lack of
clear-image-cache support in commentary.
* etc/NEWS: Announce the change.
* src/dispextern.h (struct glyph_row): Add
'extra_line_spacing_above' member.
(struct it): Add 'extra_line_spacing_above' member.
* src/frame.h (struct frame): Add 'extra_line_spacing_above'
member. Update comment for 'extra_line_spacing.'
* src/buffer.c (syms_of_buffer): Update the docstring of
'line-spacing' to describe the cons cell usage.
* src/buffer.h (struct buffer): Update comment for
'extra_line_spacing'.
* src/frame.c (gui_set_line_spacing): Handle cons cell value for
'line-spacing'. Calculate and set 'extra_line_spacing_above'
for both integer and float pairs.
* src/xdisp.c (init_iterator): Initialize 'extra_line_spacing_above'
from buffer or frame 'line-spacing', handling cons cells for both
integer and float values.
(gui_produce_glyphs): Use 'extra_line_spacing_above' to distribute
spacing between ascent and descent. Update 'max_extra_line_spacing'
calculation.
(resize_mini_window): Take line spacing into account when resizing the
mini window. Pass height of a single line to 'grow_mini_window' and
'shrink_mini_window'.
* src/window.c (grow_mini_window, shrink_mini_window): Add unit
argument which defines height of a single line.
* src/window.h (grow_mini_window, shrink_mini_window): Adjust function
prototypes accordingly with unit argument.
* lisp/subr.el (total-line-spacing): New function to calculate total
spacing from a number or cons cell.
(posn-col-row): Use total-line-spacing.
* lisp/simple.el (default-line-height): Use 'total-line-spacing'.
* lisp/textmodes/picture.el (picture-mouse-set-point): Use
'total-line-spacing'.
* lisp/window.el (window-default-line-height): Use
'total-line-spacing'.
(window--resize-mini-window): Take 'line-spacing' into account.
* test/lisp/subr-tests.el (total-line-spacing): New test.
* test/src/buffer-tests.el (test-line-spacing): New test.
* doc/emacs/display.texi (Display Custom): Document that
'line-spacing' can be a cons cell.
(Line Height): Document the new cons cell format for 'line-spacing'
to allow vertical centering.
Co-authored-by: Przemysław Alexander Kamiński <alexander@kaminski.se>
Co-authored-by: Daniel Mendler <mail@daniel-mendler.de>
* src/xfns.c (Fx_display_monitor_attributes_list): Don't access
more elements in monitor_frames than there are monitors reported
by 'gdk_display_get_n_monitors' or 'gdk_screen_get_n_monitors'.
(Bug#79941)
* nt/inc/ms-w32.h (strerror): Redirect to sys_strerror after
including <string.h>, to prevent the linker from thinking it
should be imported from some DLL. Reported by Richard Copley
<rcopley@gmail.com>.
* src/w32.c: Remove now unneeded prototype of sys_strerror.
The info returned from `garbage-collect` is really handy to
track the evolution of the heap size, but sadly it's available only
at the cost of running a full GC, which has two big downsides:
it's slow, it affects what we're measuring, and it can't be used
in `post-gc-hook`.
So, this patch makes it available without running the GC.
* src/alloc.c (Fgarbage_collect_heapsize): New function, extracted from
`Fgarbage_collect`.
(Fgarbage_collect): Use it.
(syms_of_alloc): defsubr it.
* doc/lispref/internals.texi (Garbage Collection): Extract
documentation for it from that of `garbage-collect`.
* src/pdumper.c (pdumper_set_emacs_execdir):
Don’t use basename; simply use the pointer we already have.
If we ever need a basename-like function in the future, we should
use Gnulib’s basename-lgpl module, as POSIX basename modifies its
argument string and is incompatible with glibc/Android basename; see
<https://www.gnu.org/software/gnulib/manual/html_node/basename.html>.
* src/nsterm.m (ns_select_1): Return thread_select if current
thread is not the main thread or timeout is zero; otherwise call
'thread_select' with a minimal timeout to allow other Lisp
threads to run. (Bug#80110, Bug#80112)
Problem reported by Basil L. Contovounesios (bug#66221#89).
* src/image.c (image_size_in_bytes, image_frame_cache_size):
Use intptr_t for sizes of collections of objects.
(struct anim_cache.byte_size, gif_load, Fimage_cache_size):
Use intmax_t for sizes of either files or objects.
* src/pdumper.c (pdumper_set_emacs_execdir): Add workaround for
!NS_SELF_CONTAINED so that launching Emacs from the app bundle
works flawlessly when built with native compilation.
* configure.ac: Define BINDIR. (Bug#80094)
* src/nsimage.m (ns_can_use_native_image_api): Handle HEIF, SVG
and WEBP image types on GNUstep.
* src/image.c (syms_of_image): Add conditional native image
support for HEIF, SVG and WEBP on GNUstep. (Bug#80101)
* doc/misc/dbus.texi (Top): Add "Inhibitor Locks" submenu.
Remove trailing period from chapter and section titles.
(Inhibitor Locks): New node.
* etc/NEWS: New D-Bus functions to support systemd inhibitor locks.
Presentational fixes and improvements.
* src/dbusbind.c (xd_registered_inhibitor_locks): New variable.
(Fdbus_make_inhibitor_lock, Fdbus_close_inhibitor_lock)
(Fdbus_registered_inhibitor_locks): New DEFUNs. (Bug#79963)
(syms_of_dbusbind_for_pdumper): Initialize
`xd_registered_inhibitor_locks'.
(syms_of_dbusbind): Declare subroutines
`Sdbus_make_inhibitor_lock', `Sdbus_close_inhibitor_lock' and
`Sdbus_registered_inhibitor_locks'. Declare symbol `Qdbus_call_method'.
staticpro `xd_registered_inhibitor_locks'.
* test/lisp/net/dbus-tests.el (dbus--test-systemd-service)
(dbus--test-systemd-path, dbus--test-systemd-manager-interface):
New defconsts.
(dbus-test10-inhibitor-locks): New test.
* doc/lispref/display.texi (Customizing Bitmaps): Fix grammar.
(XBM Images): Fix reference to incorrect number of properties.
(Multi-Frame Images, Other Image Types): Mention multi-frame WebP
support.
* src/image.c: Don't include pdumper.h; it hasn't been needed since
commit of 2019-05-17 "Clean up and simplify image-type setup". Fix
some commentary.
(image_pix_container_create_from_bitmap_data): Remove no longer used
frame parameter (bug#80191); this continues from commit of
2022-11-25 "Remove unused parameter from
image_create_pix_container". All callers updated.
(x_create_xrender_picture, initialize_image_type): Simplify.
(xbm_image_p): Remove redundant conditional branch. Update
commentary.
* src/image.c (native_image_format): Make array size explicit, to
help keep it consistent with its later fmt descriptor copy.
(native_image_p): Parse the correct number of keywords (bug#80191).
* doc/misc/dbus.texi (Signals): All registered signal handlers are
called.
(Synchronous Methods, Signals, Monitoring Messages): Add function
result in examples.
* src/dbusbind.c (xd_store_event): New function.
(xd_read_message_1): Use it. Call all registered handlers per
signal. (Bug#80168)
* test/lisp/net/dbus-tests.el (dbus--test-signal-handler): Adapt defun.
(dbus--test-signal-handler1, dbus--test-signal-handler2): New defuns.
(dbus-test05-register-signal-several-handlers): New test.
(dbus-test04-register-method)
(dbus-test04-call-method-authorizable)
(dbus-test05-register-signal)
(dbus-test05-register-signal-with-nils)
(dbus-test06-register-property-emits-signal): Adapt tests.
A unique frame id is assigned to a new or cloned frame, and
reused on an undeleted frame.
The id facilitates unambiguous identification among frames that
share identical names or titles, deleted frames where a live
frame object no longer exists that we can resurrect by id, for
example via 'tab-bar-undo-close-tab'. It also aids debugging at
the C level using the frame struct member id.
Rewrite 'clone-frame' and 'undelete-frame' to not let bind
variables that 'make-frame' uses to avoid conflicts with nested
'make-frame' calls, for example via
'after-make-frame-functions'.
* lisp/frame.el (clone-frame, undelete-frame): Use
'frame--purify-parameters' to supply parameters explicitly.
(undelete-frame--save-deleted-frame): Save frame id for
restoration.
(undelete-frame): Restore frame id.
(frame--purify-parameters): New defun.
(make-frame): Assign a new id for a new or cloned frame, reuse
for undeleted frame.
* src/frame.h (struct frame): Add id member.
(frame_next_id): New extern.
* src/frame.c (frame_next_id): New global counter.
(frame_set_id, frame_set_id_from_params): New function.
(Fframe_id): New DEFUN.
(syms_of_frame <Sframe_id>): New defsubr.
(syms_of_frame <Qinternal_id>): New DEFSYM.
(syms_of_frame <frame_internal_parameters>): Add 'Qinternal_id'.
* src/androidfns.c (Fx_create_frame):
* src/haikufns.c (Fx_create_frame):
* src/nsfns.m (Fx_create_frame):
* src/pgtkfns.c (Fx_create_frame):
* src/w32fns.c (Fx_create_frame):
* src/xfns.c (Fx_create_frame): Call 'frame_set_id_from_params'.
* doc/lispref/frames.texi: Add documentation.
* etc/NEWS: Announce frame id.
* configure.ac: Check for 'NSImageNameCaution' declaration when
building on GNUstep.
* src/nsterm.m ([EmacsBell init]): Use fallback implementation on
GNUstep only if 'NSImageNameCaution' is not declared. (Bug#80107)
* src/eval.c (call_debugger, signal_or_quit):
Raise extra headroom to 200 levels. The debugger is sometimes entered
via handler-bind so we raise the bar there as well (bug#80154).
* src/window.c (Fwindow_cursor_info): New function.
(syms_of_window): Defsubr it.
* doc/lispref/windows.texi (Window Point): Document it.
* etc/NEWS: Announce new function. (Bug#80023)
* lisp/frame.el (clone-frame): Set the frame parameter
'cloned-from'.
(undelete-frame): Set the frame parameter 'undeleted'.
* src/frame.c (syms_of_frame): <Qcloned_from> <Qundeleted>: New
DEFSYM.
(syms_of_frame): Add 'Qcloned_from' and 'Qundeleted' to
'frame_internal_parameters'.
* doc/lispref/frames.texi: Document these frame parameters.
* etc/NEWS: Announce the new frame parameters.
The direct cause of the problem in the bug report is that when
user runs treesit-font-lock-recompute-features to add the
emacs-devel feature in c-ts-mode's mode hook, the added query
for emacs-devel aren't compiled.
This change consists of two parts:
1. The immediate fix: validate and compile queries in
treesit-font-lock-recompute-features.
2. To make it more fool-proof, change treesit-font-lock-rules
back to compile the queries and make
treesit--compile-query-with-cache support compiled queries. This
way, as long as the query goes through treesit-font-lock-rules,
it'll be compiled eventually and not cause slow-down. I had to
add some c-level functions, but they're kind of overdue anyway,
so I don't have any problem adding them to the API.
* lisp/treesit.el (treesit--compile-query-with-cache): Support
compiled queries.
(treesit-font-lock-rules): Compile the queries (but not
eagerly).
(treesit-font-lock-recompute-features): Validate and compile
queries.
(treesit-major-mode-setup): Remove call to
treesit-validate-and-compile-font-lock-rules since it's now
called in treesit-font-lock-recompute-features.
* src/treesit.c (Ftreesit_query_eagerly_compiled_p):
(Ftreesit_query_source): New functions.
* doc/lispref/parsing.texi (Pattern Matching): Add manual
entries for the new functions.
* src/xdisp.c (redisplay_window): Don't call resize_mini_window
when the minibuffer is active and minibuffer-only frames shall
be resized automatically since that can loop infinitely (Bug#80017).
Some of the fixes are to continue to use American
rather than British spelling.
* doc/misc/modus-themes.org (my-modus-themes-engraved-faces):
Fix misspelled ‘:foreground’s.
* etc/themes/modus-themes.el (modus-themes-faces):
Fix misspelled ‘modus-themes-bold’.
* lisp/emacs-lisp/rx.el (rx--normalize-char-pattern):
Rename from rx--normalise-char-pattern.
(rx--optimize-or-args): Rename from rx--optimise-or-args.
* lisp/frame.el (frame--special-parameters):
Fix misspelled "right-divider-width".
* lisp/net/tramp.el (tramp-fingerprint-prompt-regexp):
Use American spelling “centered”, to match current libfprintf.
* lisp/org/org-fold-core.el (org-fold-core--optimize-for-huge-buffers):
Rename from org-fold-core--optimise-for-huge-buffers.
(org-fold-core-update-optimization):
Rename from org-fold-core-update-optimisation,
leaving an alias behind.
(org-fold-core-remove-optimization):
Rename from org-fold-core-remove-optimisation,
leaving an alias behind.
* lisp/org/org.el (org-advertized-archive-subtree):
This alias is now obsolete.
* lisp/play/zone.el (zone-ignored-buffers):
Fix misspelling of ‘zone--buffer-encrypted-p’.
* lisp/progmodes/csharp-mode.el (csharp-ts-mode-faces):
Fix misspelling of ‘csharp’ group.
* lisp/vc/vc.el (vc-clonable-backends-custom-type):
Rename from vc-cloneable-backends-custom-type,
leaving an alias behind.
* test/lisp/emacs-lisp/bytecomp-tests.el:
(bytecomp-tests--warn-arity-non-compiled-callee):
Rename from bytecomp-tests--warn-arity-noncompiled-callee.
(bytecomp-test-defface-spec): Reword a deliberate misspelling
of “default” that is so common I don’t want it to pollute the
spelling dictionary.
* test/lisp/emacs-lisp/package-vc-tests.el:
(package-vc-tests-preserve-artifacts):
Rename from package-vc-tests-preserve-artifacts.
* test/lisp/eshell/em-prompt-tests.el:
(em-prompt-test/forward-backward-paragraph-1):
Reword a deliberate misspelling of “goodbye” that is so common I
don’t want it to pollute the spelling dictionary.
* src/frame.c (Fset_frame_size_and_position_pixelwise): Correct
docstring typo.
* src/nsterm.m (compute_offset): New function of common code.
(ns_set_offset): Call compute_offset.
(ns_set_window_size_and_position): New function.
(ns_create_terminal): Add new function to the hook.
* java/org/gnu/emacs/EmacsWindow.java (moveResizeWindow): New
method, which alters all of the bounding box of a window at
once.
* src/android.c (android_init_emacs_window): Load method
`move_resize_window'.
(android_move_resize_window): Invoke this method, rather than a
sequence of operations that will produce two ConfigureNotify
events.
* src/androidterm.c (android_set_window_size_and_position_1)
(android_set_window_size_and_position): New functions; ported
from X.
(android_create_terminal): Register the same.