F. Jason Park [Mon, 11 Mar 2024 06:09:59 +0000 (23:09 -0700)]
Reuse command-indicator code for script lines in ERC
* lisp/erc/erc-goodies.el (erc-load-irc-script-lines): Move here from
main file and rework to always use `command-indicator' instead of only
partially, when available. Also use internal "send-action" and
"send-message" interfaces to defer command-handler output until
command lines have been inserted.
* lisp/erc/erc.el (erc-process-input-line): Redo doc string.
(erc-process-script-line): Fold exceptionally overlong line.
(erc-load-irc-script-lines): Move to erc-goodies.el. (Bug#67032)
F. Jason Park [Mon, 11 Mar 2024 06:09:59 +0000 (23:09 -0700)]
Restore leading space to right-margin stamps in ERC
* lisp/erc/erc-stamp.el (erc-insert-timestamp-right): Insert a single
space character immediately before right-side stamps managed by
`erc-stamp--display-margin-mode'. Include it as part of the
`timestamp' field. This behavior was originally present in an earlier
draft of the changes for bug#60936, mainly to favor symmetry between
hard-wrapped fill styles and fill-wrap with regard to stamps. It was
subsequently removed to simplify management, so that the `field' and
`display' intervals aligned.
* test/lisp/erc/erc-stamp-tests.el
(erc-stamp--display-margin-mode--right): Update expected output.
Partially revert those portions of 7b4ca9e609e "Leverage inverse-video
for erc-inverse-face" that introduced and managed explicit faces for
the "default" 99 color code.
* lisp/erc/erc-goodies.el (erc-control-default-fg)
(erc-control-default-bg): Remove unused faces originally meant to be
new in ERC 5.6.
(erc-get-fg-color-face, erc-get-bg-color-face): Return nil for n=99.
(erc-controls-interpret, erc-controls-highlight): Preserve an
interval's existing background so "if only the foreground color is
set, the background color stays the same," as explained by
https://modern.ircdocs.horse/formatting#color. (Bug#69860)
F. Jason Park [Wed, 20 Mar 2024 06:51:46 +0000 (23:51 -0700)]
Remove unused faces from various erc-goodies tests
; A note to anyone running ERC's test suite while bisecting and
; unlucky enough to land on this commit: apologies for the
; inconvenience. It fails because it includes adjustments for fixes
; only introduced by the subsequent commit. This is obviously
; objectionable but was done knowingly in order to duck the
; copyright-exemption threshold for new contributors.
* test/lisp/erc/erc-goodies-tests.el
(erc-controls-highlight--spoilers)
(erc-controls-highlight--inverse): Remove all mention of stricken
faces `erc-control-default-fg' and `erc-control-default-bg'.
(erc-controls-highlight/default-foreground)
(erc-controls-highlight/default-background): New tests.
(Bug#69860)
Joseph Turner [Fri, 8 Mar 2024 05:55:00 +0000 (21:55 -0800)]
Recompute :map when image :scale, :rotation, or :flip changes
Now, when transforming an image, its :map is recomputed to fit.
Image map coordinates are integers, so when computing :map,
coordinates are rounded. To prevent an image from drifting from
its map after repeated transformations, 'create-image' now adds
a new image property :original-map, which is combined with the
image's transformation parameters to recompute :map.
* lisp/image.el (image-recompute-map-p): Add user option to
control whether :map is recomputed when an image is transformed.
(create-image): Create :map from :original-map and vice versa.
(image--delayed-change-size): Fix comment.
(image--change-size, image-rotate, image-flip-horizontally,
image-flip-vertically): Recompute image map after transformation
and mention 'image-recompute-map-p' in docstring.
(image--compute-map): Add function to compute a map from original
map.
(image--compute-original-map): Add function to compute an
original map from map.
(image--scale-map): Add function to scale a map based on :scale.
(image--rotate-map): Add function to rotate a map based on
:rotation.
(image--rotate-coord): Add function to rotate a map coordinate
pair.
(image--flip-map): Add function to flip a map based on :flip.
(image-increase-size, image-decrease-size, image-mouse-increase-size)
(image-mouse-decrease-size): Mention 'image-recompute-map-p' in
docstrings.
* etc/NEWS: Add NEWS entry.
* doc/lispref/display.texi (Image Descriptors): Document :original-map
and new user option 'image-recompute-map-p'.
* test/lisp/image-tests.el (image--compute-map-and-original-map):
Test 'image--compute-map' and 'image--compute-original-map'.
(image-tests--map-equal): Add equality predicate to compare image maps.
(image-create-image-with-map): Test that 'create-image' adds :map
and/or :original-map as appropriate.
(image-transform-map): Test functions related to transforming maps.
(Bug#69602)
Jim Porter [Sun, 17 Mar 2024 19:01:59 +0000 (12:01 -0700)]
Allow toggling "readable" mode in EWW
Additionally, add an option to prevent adding a new history entry for
each call of 'eww-readable' (bug#68254).
* lisp/net/eww.el (eww-retrieve):
* lisp/net/eww.el (eww-readable-adds-to-history): New option.
(eww-retrieve): Make sure we call CALLBACK in all configurations.
(eww-render): Simplify how to pass encoding.
(eww--parse-html-region, eww-display-document): New functions, extracted
from...
(eww-display-html): ... here.
(eww-document-base): New function.
(eww-readable): Toggle "readable" mode interactively, like with a minor
mode. Consult 'eww-readable-adds-to-history'.
(eww-reload): Use 'eshell-display-document'.
* test/lisp/net/eww-tests.el (eww-test--with-mock-retrieve): Fix indent.
(eww-test/display/html, eww-test/readable/toggle-display): New tests.
* doc/misc/eww.texi (Basics): Describe the new behavior.
Po Lu [Sat, 23 Mar 2024 10:14:12 +0000 (18:14 +0800)]
Enable calling decode_coding_object with both SRC and DST_OBJECT Qnil
* src/coding.c (growable_destination): A C destination is also
reallocable.
(produce_chars): Don't consider source and destination identical
if they are EQ but Qnil.
Eli Zaretskii [Sat, 23 Mar 2024 09:09:57 +0000 (11:09 +0200)]
Improve support for preprocessor macros in 'c/c++-ts-mode'
* lisp/progmodes/c-ts-mode.el (c-ts-mode--defun-name)
(c-ts-base-mode): Support preprocessor macros as defuns. This
fixes both navigation by defuns and add-log when cpp macros are at
point.
Add BasedPyright LSP server alternative for Eglot's 'python-mode'
* lisp/progmodes/eglot.el (eglot-server-programs): Add
BasedPyright, a new server for python, forked from the
unmaintained 'pyright' LSP server. (Bug#69925)
Po Lu [Sat, 23 Mar 2024 07:37:43 +0000 (15:37 +0800)]
Correctly handle non-BMP characters in Android content file names
* lisp/term/android-win.el (android-encode-jni)
(android-decode-jni, android-jni): New coding system, for
Android file names and runtime data.
* src/androidterm.h (syms_of_androidvfs): New function.
* src/androidvfs.c (struct android_special_vnode): New field
special_coding_system.
(android_saf_tree_readdir): Decode the file name using the
android-jni coding system.
(special_vnodes): <contents>: Specify a file name coding system.
(android_vfs_convert_name): New function.
(android_root_name): If a special coding system be specified for
a special vnode, convert components to it before invoking its
name function.
(syms_of_androidvfs): New symbol Qandroid_jni.
Stefan Monnier [Fri, 22 Mar 2024 01:08:58 +0000 (21:08 -0400)]
(help-fns-function-description-header): Print functions' type
Instead of choosing English words to describe the kind of function,
use the actual type of the function object (from `cl-type-of`)
directly, and make it a button to display info about that type.
* lisp/help-fns.el (help-fns-function-description-header): Use the
function's type name in the description instead of "prose".
Use `insert` instead of `princ`, so as to preserve the text-properties
of the button.
* lisp/emacs-lisp/cl-extra.el (cl-help-type): Move to `help-mode.el`
and rename to `help-type`.
(cl--describe-class): Adjust accordingly.
* lisp/help-mode.el (help-type): New type, moved and renamed from
`cl-extra.el`.
Stefan Monnier [Thu, 21 Mar 2024 23:40:20 +0000 (19:40 -0400)]
(help-fns-function-name): New function
Consolidate code used in profiler and help--describe-command,
and improve it while we're at it.
Also use #' to quote a few function names along the way.
* lisp/help-fns.el (help-fns--function-numbers, help-fns--function-names):
New vars.
(help-fns--display-function): New aux function.
(help-fns-function-name): New function, inspired from
`help--describe-command`.
* lisp/help.el (help--describe-command): Use `help-fns-function-name`.
(help--for-help-make-sections): Remove redundant "" arg to `mapconcat`.
* lisp/profiler.el (profiler-format-entry, profiler-fixup-entry):
Delete functions.
(profiler-report-make-entry-part): Use `help-fns-function-name` instead.
(profiler-report-find-entry): Use `push-button`.
* lisp/transient.el (transient--debug): Use `help-fns-function-name`
when available.
Stefan Monnier [Thu, 21 Mar 2024 22:27:03 +0000 (18:27 -0400)]
(describe-symbol-backends): Fix addition of the "type" backend
That backend was added from `cl-extra.el` with no autoload, so
(describe-symbol `advice) failed to show the info about
the `advice` type unless `cl-extra.el` had been loaded beforehand.
`C-h o RET advice RET` worked by accident because the completion
table uses `cl-some` which is autoloaded from `cl-extra.el`.
* lisp/help-mode.el (describe-symbol-backends): Add the "type" backend.
* lisp/emacs-lisp/cl-extra.el (describe-symbol-backends): Don't add the
"type" backend here.
Stefan Monnier [Thu, 21 Mar 2024 16:28:54 +0000 (12:28 -0400)]
Speed up `describe-char` when a property has a large value
Doing `C-u C-x =` on a buffer position where the overlay/text
properties hold large values (e.g. inside the profiler report)
can be surprisingly slow because it pretty prints all those properties.
Change the code to do the pretty printing more lazily.
While at it, share that duplicated code between `descr-text.el` and
`wid-browse.el`.
* lisp/emacs-lisp/pp.el (pp-insert-short-sexp): New function.
* lisp/descr-text.el (describe-text-sexp): Delete function.
(describe-property-list): Use `pp-insert-short-sexp` instead.
* lisp/wid-browse.el (widget-browse-sexp): Use `pp-insert-short-sexp`
and `widget--allow-insertion`.
Stefan Monnier [Thu, 21 Mar 2024 16:08:02 +0000 (12:08 -0400)]
wid-edit.el: Cosmetic changes
* lisp/wid-edit.el: Use #' to quote function names.
(widget--simplify-menu, widget-echo-help): Explicitly specify the
lexenv to `eval`.
(widget-choose, widget-get-sibling, widget-setup, widget-field-find)
(widget-choice-action, widget-checklist-value-get)
(widget-radio-value-create, widget-radio-value-set)
(widget-radio-action, widget-editable-list-delete-at)
(widget-group-value-create, widget-choice-prompt-value): Use `dolist`.
(widget-convert): Hoist `(setq current` out of the ifs.
(widget-convert): Hoist `(setq keys` out of the if.
(widget-after-change): Hoist `(setq begin` out of the if.
(widget-default-completions): Use `cond`.
(widget-default-value-set): Hoist `goto-char` out of the if.
(widget-choice-action): Hoist `nth` out of the if.
(widget-checkbox-action): Hoist `widget-apply` out of the if.
(widget-editable-list-value-create): Hoist `car` out of the if.
(widget-editable-list-entry-create): Hoist `(setq child ...` out of the if.
(widget-documentation-link-action): Fold `if` into `cond`.
(widget-key-sequence-value-to-external): Use `key-parse`.
(widget-plist-convert-option, widget-alist-convert-option):
Hoist `(setq key-type` out of the if.
Stefan Monnier [Thu, 21 Mar 2024 15:38:12 +0000 (11:38 -0400)]
(widget--allow-insertion): New macro
* lisp/wid-edit.el (widget--allow-insertion): New macro.
(widget-specify-insert, widget-insert, widget-setup)
(widget-default-delete, widget-editable-list-insert-before)
(widget-editable-list-delete-at): Use it.
Adam Porter [Sat, 9 Mar 2024 05:43:14 +0000 (23:43 -0600)]
'vtable-update-object' can now be called with one argument
It's often necessary to update the representation of a single
object in a table (e.g a struct, whose identity does not change
when its slots'
values are changed). To do so, now the function may be called
like this:
(vtable-update-object table object)
Instead of like this:
(vtable-update-object table object object)
This also documents the behavior of the just-discovered limitation filed
as bug#69837.
* lisp/emacs-lisp/vtable.el (vtable-update-object): Make 'old-object'
argument optional. (Bug#69666)
* doc/lispref/strings.texi (Custom Format Strings): Mention that
precision specifier affects both '<' and '>' truncation (bug#69822).
* lisp/format-spec.el (format-spec, format-spec--do-flags): Use same
terminology as 'format', especially when referring to its behavior.
Eli Zaretskii [Thu, 21 Mar 2024 08:25:56 +0000 (10:25 +0200)]
Speed up display of RTL text with many character compositions
* src/bidi.c (bidi_level_start): New function.
* src/dispextern.h (bidi_level_start): Add prototype.
* src/xdisp.c (compute_stop_pos, set_iterator_to_next)
(get_visually_first_element, next_element_from_buffer): Call
'bidi_level_start' when looking for composed characters backwards,
to set limit of searching back, instead of looking all the way to
BOB. (Bug#69385)
Adam Porter [Thu, 21 Mar 2024 07:13:28 +0000 (02:13 -0500)]
Avoid recomputing the whole table in 'vtable--recompute-numerical'
Each element of LINE being tested is a list, the first element of
which is the value actually being represented in the table.
Previously, the 'numberp' test would always fail, because it was
being compared with the list rather than the intended value in it;
that could cause the whole table to be recomputed, sometimes
unnecessarily.
* lisp/emacs-lisp/vtable.el (vtable--recompute-numerical): Test the
car of ELEM, not ELEM itself, which is a list. (Bug#69927)
* java/org/gnu/emacs/EmacsOpenActivity.java (onCreate): Handle
file URIs when processing attachments from a mailto URI, and
check for KitKat before opening content ones.
* java/org/gnu/emacs/EmacsWindow.java <pointerMap>
(figureChange): Replace coordinate HashMap with a SparseArray.
* java/org/gnu/emacs/EmacsWindowAttachmentManager.java
(registerWindow): Don't specify FLAG_ACTIVITY_NEW_DOCUMENT on
systems where it is absent.
Kévin Le Gouguec [Mon, 18 Mar 2024 18:47:59 +0000 (19:47 +0100)]
Fix vc-git test when no identities are configured
Reported by john muhl <jm@pub.pink>.
* test/lisp/vc/vc-git-tests.el (vc-git-test--with-repo): Set
some environment variables (lifted from vc-tests.el) to let
'git commit' compute dummy author and committer identities.
Andrea Corallo [Tue, 19 Mar 2024 09:41:52 +0000 (10:41 +0100)]
* Use 'cl-type-of' in comp-cstr.el
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-union-homogeneous-no-range)
(comp-cstr-union-1-no-mem, comp-cstr-intersection-no-hashcons):
Make use of 'cl-type-of' in place of 'type-of'.
Po Lu [Tue, 19 Mar 2024 04:08:17 +0000 (12:08 +0800)]
Respect display names of Android content URIs
* java/org/gnu/emacs/EmacsNative.java (displayNameHash): New
function.
* java/org/gnu/emacs/EmacsService.java (buildContentName): New
argument RESOLVER. Generate names holding URI's display name if
available. All callers changed.
* lisp/international/mule-cmds.el (set-default-coding-systems):
Fix file name coding system as utf-8-unix on Android as on Mac
OS.
* src/androidvfs.c (enum android_vnode_type): New enum
ANDROID_VNODE_CONTENT_AUTHORITY_NAMED.
(android_content_name): Register root directories for this new
type.
(displayNameHash): New function.
(android_get_content_name): New argument WITH_CHECKSUM. If
present, treat the final two components as a pair of checksum
and display name, and verify and exclude the two.
(android_authority_name): Provide new argument as appropriate.
(android_authority_initial_name): New function.
Tweak regexp for object initializers in csharp-mode (bug#69571)
* lisp/progmodes/csharp-mode.el (csharp-guess-basic-syntax): Add
handling to not consider ended statements as object init openers.
* test/lisp/progmodes/csharp-mode-resources/indent.erts: New test
resources.
* test/lisp/progmodes/csharp-mode-tests.el: Add test for this particular
issue.
`term-mode': mention the keymap to add keybindings to
A user typically expects a keymap for mode `foo' to be called
`foo-mode-map'. term-mode has `term-mode-map' too, but for
user-defined bindings to have effect they have to be put to
`term-raw-map' instead. So let's mention that.
* lisp/term.el (term-mode) (term-mode-map) (term-raw-map): Mention
the keymaps to add keybindings to for `term-mode'. (Bug#69786)
Stefan Monnier [Thu, 14 Mar 2024 16:49:08 +0000 (12:49 -0400)]
Followup changes to `cl-type-of`
These changes came up while working on `cl-type-of` but are not
directly related to the new `cl-type-of`.
The BASE_PURESIZE bump was needed at some point on one of my
machine, not sure why.
* src/puresize.h (BASE_PURESIZE): Bump up.
* src/sqlite.c (bind_value): Don't use `Ftype_of`.
* lisp/emacs-lisp/seq.el (seq-remove-at-position): Simplify.
* lisp/emacs-lisp/cl-preloaded.el (finalizer):
New (previously missing) type.
* doc/lispref/objects.texi (Type Predicates): Minor tweaks.
Stefan Monnier [Sun, 17 Mar 2024 21:29:02 +0000 (17:29 -0400)]
(primitive-function): New type
The type hierarchy and `cl-type-of` code assumed that `subr-primitive`
only applies to functions, but since it also accepts special-forms it makes
it an unsuitable choice since it can't be a subtype of `compiled-function`.
So, use a new type `primitive-function` instead.
* lisp/subr.el (subr-primitive-p): Fix docstring (bug#69832).
(primitive-function-p): New function.
* lisp/emacs-lisp/cl-preloaded.el (primitive-function): Rename
from `subr-primitive` since `subr-primitive-p` means something else.
* src/data.c (Fcl_type_of): Return `primitive-function` instead
of `subr-primitive` for C functions.
(syms_of_data): Adjust accordingly.
Stefan Monnier [Tue, 12 Mar 2024 13:26:24 +0000 (09:26 -0400)]
(cl-type-of): New function to return more precise types (bug#69739)
* src/data.c (Fcl_type_of): New function, extracted from `Ftype_of`.
Make it return more precise types for symbols, integers, and subrs.
(Ftype_of): Use it.
(syms_of_data): Define the corresponding new symbols and defsubr
the new function.
* doc/lispref/objects.texi (Type Predicates): Document it.
* src/comp.c (emit_limple_insn): Use `Fcl_type_of`.
* lisp/emacs-lisp/cl-preloaded.el (subr): Demote it to `atom`.
(subr-native-elisp, subr-primitive): Add `compiled-function` as
parent instead.
(special-form): New type.
Kévin Le Gouguec [Mon, 12 Feb 2024 07:29:19 +0000 (08:29 +0100)]
; Re-apply accidentally reverted commit
This re-applies:
2024-03-17 "Fix vc-dir when "remote" Git branch is local"
(21828f288ef)
reverted as part of the unrelated:
2024-03-17 "Update modus-themes to their 4.4.0 version"
(67b0c1c09ea)
The original commit message follows:
Fix vc-dir when "remote" Git branch is local
While in there, add that "tracking" branch to the vc-dir
buffer. For bug#68183.
* lisp/vc/vc-git.el (vc-git-dir-extra-headers): Reduce
boilerplate with new function 'vc-git--out-ok'; stop calling
vc-git-repository-url when REMOTE is "." to avoid throwing an
error; display tracking branch; prefer "none (<details...>)" to
"not (<details...>)" since that reads more grammatically
correct.
(vc-git--out-ok): Add documentation.
(vc-git--out-str): New function to easily get the output from a
Git command.
* test/lisp/vc/vc-git-tests.el (vc-git-test--with-repo)
(vc-git-test--run): New helpers, defined to steer clear of
vc-git-- internal functions.
(vc-git-test-dir-track-local-branch): Check that vc-dir does
not crash.
Juri Linkov [Sun, 17 Mar 2024 17:57:05 +0000 (19:57 +0200)]
* lisp/tab-bar.el (tab-bar-select-restore-windows): New defcustom.
(tab-bar-select-restore-windows): New function.
(tab-bar-select-tab): Let-bind window-restore-killed-buffer-windows
to tab-bar-select-restore-windows (bug#68235).
* doc/misc/modus-themes.org: Update the manual to better document
existing functionality and cover the new features.
* etc/themes/modus-operandi-deuteranopia-theme.el:
* etc/themes/modus-operandi-theme.el:
* etc/themes/modus-operandi-tinted-theme.el:
* etc/themes/modus-operandi-tritanopia-theme.el:
* etc/themes/modus-vivendi-deuteranopia-theme.el:
* etc/themes/modus-vivendi-theme.el:
* etc/themes/modus-vivendi-tinted-theme.el:
* etc/themes/modus-vivendi-tritanopia-theme.el: Update the
palette of each theme.
* etc/themes/modus-themes.el (require): Remove call to cl-lib
and do not use relevant functions.
(modus-themes-operandi-colors, modus-themes-vivendi-colors)
(modus-themes-version, modus-themes-report-bug): Remove old
calls to 'make-obsolete' and related.
(modus-themes--annotate-theme): Tweak the completion annotation function.
(modus-themes--org-block): Deprecate the user option 'modus-themes-org-blocks'.
(modus-themes-faces): Update faces.
(modus-themes-custom-variables): Update the list of custom
variables.
Detailed release notes are available here:
<https://protesilaos.com/codelog/2024-03-17-modus-themes-4-4-0/>.
Kévin Le Gouguec [Mon, 12 Feb 2024 07:29:19 +0000 (08:29 +0100)]
Fix vc-dir when "remote" Git branch is local
While in there, add that "tracking" branch to the vc-dir
buffer. For bug#68183.
* lisp/vc/vc-git.el (vc-git-dir-extra-headers): Reduce
boilerplate with new function 'vc-git--out-ok'; stop calling
vc-git-repository-url when REMOTE is "." to avoid throwing an
error; display tracking branch; prefer "none (<details...>)" to
"not (<details...>)" since that reads more grammatically
correct.
(vc-git--out-ok): Add documentation.
(vc-git--out-str): New function to easily get the output from a
Git command.
* test/lisp/vc/vc-git-tests.el (vc-git-test--with-repo)
(vc-git-test--run): New helpers, defined to steer clear of
vc-git-- internal functions.
(vc-git-test-dir-track-local-branch): Check that vc-dir does
not crash.
* cross/ndk-build/ndk-build.mk.in (NDK_BUILD_CXX_STL)
(NDK_BUILD_CXX_LDFLAGS): New variables.
* cross/ndk-build/ndk-resolve.mk (NDK_SYSTEM_LIBRARIES):
Introduce several other C++ libraries sometimes present on
Android.
(NDK_SO_EXTRA_FLAGS_$(LOCAL_MODULE)): Insert NDK_BUILD_CXX_STL
when any of these new C++ libraries are requested.
* m4/ndk-build.m4: Completely rewrite C++ compiler and library
detection.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): Attempt to
load more libraries from static initializer.
Stefan Monnier [Sun, 17 Mar 2024 03:10:48 +0000 (23:10 -0400)]
debug.el: Prevent re-entering the debugger for the same error
We can have several active `handler-bind`s that all want to invoke the
debugger, in which case we can have the following sequence:
- The more deeply nested handler calls the debugger.
- After a while the user invokes `debugger-continue`.
- `signal_or_quit` propagates the error up the stack to the
second handler, which calls the debugger again.
- The user thus ends up right back at the same place, as if
`debugger-continue` had not be processed.
Fix this by remembering the last processed error and skipping
the debugger if we bump into it again.
* lisp/emacs-lisp/debug.el (debugger--last-error): New var.
(debugger--duplicate-p): New function.
(debug): Use them.