Improve 'key-translate' to support removing translations
This patch enhances the key-translate function to allow removing
keyboard translations by passing nil as the second argument (TO).
If TO is nil, any existing translation for the FROM key will be
removed. The compiler macro is updated to only check TO when it
is non-nil. This change makes key-translate more consistent with
the behavior of 'keyboard-translate', providing a way to remove
translations without having to specify the same key for both FROM
and TO.
The documentation string is updated to reflect the new behavior.
* lisp/keymap.el (key-translate): Support removing translations
by passing nil as the second argument (TO). Also signal an error
if multiple items are passed. (Bug#70139)
Lin Sun [Fri, 3 May 2024 06:52:22 +0000 (06:52 +0000)]
Enhance python-tests to adapt different Python interpreters (bug#70815)
* test/lisp/progmodes/python-tests.el
(python-tests-get-shell-interpreter): New function to get Python
interpreter for testing; and also introduce new env variable
EMACS_PYTHON_INTERPRETER to support customer Python interpreter.
Eli Zaretskii [Thu, 23 May 2024 09:51:19 +0000 (12:51 +0300)]
Fix uncompressing a .tar.gz archive whose files have no leading dir
* lisp/dired-aux.el (dired-compress): Handle the case when
NEW-FILE is not produced in the current directory by uncompressing
a compressed file. (Bug#47058)
Po Lu [Thu, 23 May 2024 07:19:46 +0000 (15:19 +0800)]
Restore specbound keyboard-locals in the correct KBOARD
* doc/lispref/variables.texi (Intro to Buffer-Local): Fix typo
in documentation.
* src/data.c (KBOARD_OBJFWDP): Move to lisp.h.
(kboard_for_bindings): New variable.
(do_symval_forwarding, store_symval_forwarding): Call
kboard_for_bindings rather than retrieving this value directly.
(set_default_internal): New argument WHERE; if valcontents be a
Lisp_Kboard_Objfwd and WHERE be specified, save the binding
there. All callers changed.
* src/eval.c (specpdl_where): Adjust for changes in structure
layout.
(specpdl_kboard): New function.
(do_specbind): Clear let->where.kbd in ordinary SPECPDL_LETs,
and set it to the kboard where the binding will be installed if
binding keyboard forwards.
(specbind, do_one_unbind, specpdl_unrewind): Provide
specpdl_kboard in invocation of set_default_internal.
* src/keyboard.c (delete_kboard): Clean thread specpdls of
references to kboards.
* src/keyboard.h (KBOARD_OBJFWDP): Move from data.c.
* src/lisp.h (union specbinding) <let.where>: Convert into
union of KBOARD and Lisp_Object.
`rm lisp/emacs-lisp/cl-preloaded.elc src/bootstrap-emacs`
followed by `make` ended up loading right after defining
`built-in-class-p` but before actually defining the
built-in-classes so the computation of bitsets failed.
Po Lu [Wed, 22 May 2024 14:00:02 +0000 (22:00 +0800)]
Improve compatibility with Android's default text editor
* java/org/gnu/emacs/EmacsView.java (showOnScreenKeyboard):
Request a selection update if `inputConnection' has been
established, to more closely emulate the OS text editing widget.
(onCreateInputConnection) [EmacsService.DEBUG_IC]: Print current
selection values before reporting them.
Juri Linkov [Tue, 21 May 2024 17:22:31 +0000 (20:22 +0300)]
Use read-from-minibuffer instead of read-string for dired-do-touch
* lisp/dired-aux.el (dired-mark-read-string): Use read-from-minibuffer
instead of read-string when op-symbol is 'touch', since it's more clear
when read-from-minibuffer returns an empty string for RET,
and it was used in dired-mark-read-string initially (bug#70725).
Michael Albinus [Tue, 21 May 2024 16:13:40 +0000 (18:13 +0200)]
Fix some Tramp oddities
* lisp/net/tramp-container.el: Move connection-local settings
where they belong to.
* lisp/net/tramp-sshfs.el (tramp-connection-properties): Do not
set connection property "direct-async-process".
(tramp-direct-async-process): Set connection-local value.
* test/lisp/net/tramp-tests.el (comp-warn-primitives): Declare.
(tramp-test18-file-attributes): Use it.
Stephen Berman [Tue, 21 May 2024 13:04:43 +0000 (15:04 +0200)]
; Avoid byte-compiler warning in todo-mode.el differently
* lisp/calendar/todo-mode.el (todo-mode-map): Define it without a
value before its use in 'todo-insert-item--next-param' to pacify
the byte-compiler.
(todo-insert-item--next-param): Move back to its previous location
to keep it under the outline heading with related code.
Eli Zaretskii [Tue, 21 May 2024 11:17:24 +0000 (14:17 +0300)]
; Avoid byte-compiler warning in todo-mode.el
* lisp/calendar/todo-mode.el (todo-insert-item--next-param): Move
to after the definition of 'todo-mode-map', which this function
uses. This avoids byte-compiler warning.
Stephen Berman [Tue, 21 May 2024 09:04:17 +0000 (11:04 +0200)]
Fix todo-mode item insertion bug (bug#70937)
* lisp/calendar/todo-mode.el (todo-insert-item--next-param):
Initially assign each key in todo-mode-map a function identifying
it as invalid for item insertion, thus preventing mistakenly
pressing a key from executing an unwanted different todo-mode
command; the actual item insertion keys are redefined when looping
over the item insertion parameters.
Juri Linkov [Tue, 21 May 2024 06:16:18 +0000 (09:16 +0300)]
Fix for 'vc-default-patch-addressee' recently added to .dir-locals.el
* lisp/vc/vc.el: Add autoloaded setting of 'safe-local-variable' property
for 'vc-default-patch-addressee' exactly like it's already done
for 'vc-prepare-patches-separately'.
Jared Finder [Tue, 21 May 2024 02:21:29 +0000 (19:21 -0700)]
Do not message for repeated enable/disable of tab-line-mode
tab-line-mode should not inform the user of an unexpected change
when enabling the mode if already enabled. For example, when
running (tab-line-mode 1) repeatedly (bug#68765).
* lisp/tab-line.el (tab-line-mode): Modify case when user is informed.
Jim Porter [Mon, 20 May 2024 19:37:22 +0000 (12:37 -0700)]
Improve implementation of 'forward-thing' using custom providers
Now, call all the custom providers for each step, using the provider
that moves point the smallest non-zero amount. This allows multiple
providers for a given "thing" to work nicely together.
* lisp/thingatpt.el (forward-thing-provider-alist): Update docstring.
(forward-thing): New implementation to call each provider N times.
(forward-thing-for-text-property): Take BACKWARD instead of N. Update
callers.
* test/lisp/thingatpt-tests.el (thing-at-point-providers)
(forward-thing-providers): Add more checks.
(consecutive-things-at-point): New test.
Michael Albinus [Mon, 20 May 2024 14:22:17 +0000 (16:22 +0200)]
Tramp code cleanup
* lisp/net/tramp-sh.el (tramp-find-shell, tramp-find-inline-compress)
(tramp-get-remote-path):
* lisp/net/tramp-smb.el (tramp-smb-handle-process-file):
Use `tramp-warning'.
* test/lisp/net/tramp-tests.el (tramp--test-container-p):
Add "kubernetes", "run0" and "nspawn".
(tramp--test-toolbox-p): New defun.
(tramp-test45-asynchronous-requests): Use it.
(tramp--test-check-files): Adapt regexp.
Eli Zaretskii [Mon, 20 May 2024 12:29:39 +0000 (15:29 +0300)]
Fix visiting zip archives inside tar archives
* lisp/tar-mode.el (tar-archive-from-tar): New local variable.
(tar-extract): Set it non-nil for an extracted member that happens
to be arc-mode archive.
* lisp/arc-mode.el (tar-archive-from-tar): Defvar it.
(archive-unique-fname): Make sure FNAME can be created in DIR,
even if FNAME is provided as an absolute file name (this happens
if the archive is a member of a Tar archive, for example).
(archive-extract): Set 'archive-remote' for archives that were
extracted from Tar archives. (Bug#70987)
Juri Linkov [Mon, 20 May 2024 06:22:10 +0000 (09:22 +0300)]
New tests for nested archives (bug#70987)
* test/lisp/tar-mode-tests.el (tar-mode-test-tar-extract-zip-and-gz):
* test/lisp/arc-mode-tests.el (arc-mode-test-zip-extract-tar-and-gz):
New tests.
* test/data/decompress/tzg.tar.gz:
* test/data/decompress/ztg.zip:
New data files to test decompressing of different combinations
of nested tar and zip archives.
Jim Porter [Sat, 11 May 2024 18:41:11 +0000 (11:41 -0700)]
Tell direction in prompts for '(previous|next)-matching-history-element'
Previously, this always said "Previous" for
'previous-matching-history-element' (likewise "Next"). Now, the prompt
accounts for a negative prefix argument changing the search direction
(bug#70882).
* lisp/simple.el (previous-matching-history-element)
(next-matching-history-element): Consult numeric prefix argument to
determine the prompt string.
Jim Porter [Mon, 29 Apr 2024 04:19:53 +0000 (21:19 -0700)]
Allow defining custom providers for more "thingatpt" functions
This also fixes an issue in EWW and bug-reference-mode where
(thing-at-point 'url) at the end of a URL would return nil.
See <https://lists.gnu.org/archive/html/emacs-devel/2024-02/msg00200.html>.
* lisp/thingatpt.el (forward-thing-provider-alist)
(bounds-of-thing-at-point-provider-alist): New variables...
(forward-thing, bounds-of-thing-at-point): ... use them.
(text-property-search-forward, text-property-search-backward)
(prop-match-beginning, prop-match-end): Declare.
(thing-at-point-for-text-property, forward-thing-for-text-property)
(bounds-of-thing-at-point-for-text-property): New functions.
* lisp/net/eww.el (eww--url-at-point): Use
'thing-at-point-for-text-property'.
(eww--bounds-of-url-at-point, eww--forward-url): New functions...
(eww-mode): ... use them.
* lisp/progmodes/bug-reference.el (bug-reference--url-at-point): Use
'thing-at-point-for-text-property'.
(bug-reference--bounds-of-url-at-point, bug-reference--forward-url): New
functions...
(bug-reference--init): ... use them.
* test/lisp/thingatpt-tests.el (thing-at-point-providers)
(forward-thing-providers, bounds-of-thing-at-point-providers): New
tests.
Paul Eggert [Sun, 19 May 2024 15:48:52 +0000 (08:48 -0700)]
Tweak STORE_NUMBER arg type
* src/regex-emacs.c (STORE_NUMBER): Make the arg int, not int16_t.
There’s no need for the caller to convert to int16_t, and using
int makes the machine code a bit smaller (and presumably a bit
faster) on x86-64 with GCC 14.
Paul Eggert [Sun, 19 May 2024 15:42:57 +0000 (08:42 -0700)]
Port knuth_hash to odd platforms
* src/lisp.h (hash_hash_t, knuth_hash): Use unsigned int and
unsigned long long int rather than uint32_t and uint64_t, as POSIX
does not guarantee the presence of uint64_t, and uint32_t and
uint64_t both in theory have problems with undefined behavior on
integer overflow. This doesn’t affect behavior (or even machine
code) on typical platforms.
Paul Eggert [Sat, 18 May 2024 20:18:32 +0000 (13:18 -0700)]
Pacify -Wanalyzer-null-dereference in sfnt.c
* src/sfnt.c (sfnt_map_table, sfnt_read_table)
(sfnt_read_cvar_table): Pacify GCC -Wanalyzer-null-dereference.
The change to sfnt_read_cvar_table fixes what appears to be
an actual null-dereference bug.
When PIXELWISE is nil, we still calculate width in pixels and
then convert it to columns. However, part of the calculation
was using columns where it should have used pixels. (Bug#70894)
Po Lu [Sun, 19 May 2024 01:46:26 +0000 (09:46 +0800)]
Fix the DJGPP build
* config.bat: Generate stdbit.in-h from stdbit.in.h.
* msdos/sedlibmk.inp (GL_STDC_...): Enable generation
of ISO C2x features.
(STDBIT_H): Define to stdbit.h.
(GL_GENERATE_STDBIT_H_CONDITION): Define to 1.
F. Jason Park [Thu, 9 May 2024 02:03:58 +0000 (19:03 -0700)]
Reconcile erc-stamp--date-stamps when merging buffers
* etc/ERC-NEWS: Mention new face `erc-information'.
* lisp/erc/erc-button.el (erc-button-add-buttons): Skip buttonization
when the "msg prop" `erc--skip' is present and contains the symbol
`button'. Set `alist' to nil in the same guard condition as a
roundabout way of suppressing further processing.
* lisp/erc/erc-networks.el (erc--insert-admin-message): Forward
declaration.
(erc-networks--insert-transplanted-content)
(erc-networks--transplant-buffer-content): Replace former with latter.
Change signature to take source and destination buffers as parameters.
(erc-networks--transplant-target-buffer-function): New function-valued
variable.
(erc-networks--target-transplant-in-progress-p): New variable, a flag
for downstream code to detect when a transplant is underway.
(erc-networks--reclaim-orphaned-target-buffers): Defer to
`erc-networks--transplant-target-buffer-function' to handle the actual
transplant business. Crucially, kill the buffer afterwards instead of
beforehand. If new buffer-association bugs emerge related to the
combining of old or renamed target buffers, this reordering may be at
fault.
(erc-networks--copy-over-server-buffer-contents): Pass old and new
buffers to `erc-networks--insert-transplanted-content'.
* lisp/erc/erc-stamp.el
(erc-stamp--defer-date-insertion-on-post-modify): Set `fn' slot of
`erc-stamp--date' instance to `ignore' when running the actual
callback in order to conserve a little space.
(erc-stamp--date-mode): Add and remove hook members for
`erc-networks--copy-server-buffer-functions' and
`erc-networks--transplant-target-buffer-function'.
(erc-insert-timestamp-left-and-right): Always clear
`erc-timestamp-last-inserted-right' to ensure a right stamp
accompanies every date stamp.
(erc-stamp--dedupe-date-stamps)
(erc-stamp--dedupe-date-stamps-from-buffer)
(erc-stamp--dedupe-date-stamps-from-target-buffer): New functions.
Date stamp behavior was revamped as part of bug#60936.
* lisp/erc/erc.el (erc-informational): New face.
(erc--insert-admin-message): New function to hide some "msg prop"
complexity from "upstream" libraries, like `erc-networks', and thus
avoid more forward-declarations. A less smelly approach would be to
devise a general interface owned by such libraries, or erc-common,
that `erc-mode' could then hook into on init.
(erc-display-message-highlight): Make face matching more limber to
accommodate the convention of face names lacking a "-face" suffix.
(erc-message-english-graft): New variable.
(erc-kill-channel): Inhibit execution of hook when
`erc-networks--target-transplant-in-progress-p' is non-nil.
* test/lisp/erc/erc-networks-tests.el
(erc-networks--rename-server-buffer--no-existing--orphan)
(erc-networks--rename-server-buffer--existing--reuse)
(erc-networks--rename-server-buffer--local-match)
(erc-networks--rename-server-buffer--local-nomatch): Use helper to
initialize markers.
* test/lisp/erc/erc-stamp-tests.el (erc-stamp--dedupe-date-stamps):
New test. (Bug#70928)
F. Jason Park [Wed, 15 May 2024 04:09:55 +0000 (21:09 -0700)]
Don't kill server buffer with erc-kill-buffer-on-part
* etc/ERC-NEWS: Mention new flag `erc-killing-buffer-on-part-p' and
the renaming of `erc-kill-channel'.
* lisp/erc/erc-backend.el (erc-server-PART): Only kill a buffer on
behalf of `erc-kill-buffer-on-part' when the buffer hasn't already
been killed, and bind `erc-killing-buffer-on-part-p' to t when doing
so.
* lisp/erc/erc-log.el (erc-conditional-save-buffer): Don't save logs
when the buffer parameter is nil because that causes the server buffer
to be saved out. It's possible that user code relying on this
longstanding bug will be affected, however, by default, the server
buffer will also be saved out independently at designated junctures.
* lisp/erc/erc.el (erc-part-hook): Redo doc string.
(erc-killing-buffer-on-part-p): New variable, a flag to prevent
redundant execution of `erc-kill-channel-hook' members concerned with
parted channels.
(erc-kill-buffer-on-part): Tweak doc string.
(erc-kill-channel-hook): Use new name for `erc-kill-channel',
`erc-part-channel-on-kill'.
(erc-kill-channel, erc-part-channel-on-kill): Rename former to latter,
and inhibit execution when `erc-killing-buffer-on-part-p' is non-nil.
* test/lisp/erc/erc-scenarios-base-kill-on-part.el: New file.
(Bug#70840)
kobarity [Sat, 24 Feb 2024 14:11:02 +0000 (23:11 +0900)]
Improve fontification of Python assignments with type hints
* lisp/progmodes/python.el (python-font-lock-keywords-maximum-decoration):
Fontify type hints of assignment statement. (Bug#69357)
* test/lisp/progmodes/python-tests.el
(python-font-lock-assignment-statement-11)
(python-font-lock-assignment-statement-12)
(python-font-lock-assignment-statement-13)
(python-font-lock-assignment-statement-18): Add fontification of type
hints.
(python-font-lock-assignment-statement-19): New test.
nxml-mode: Add schemas for Mono/.NET related files
* etc/schema/dotnet-appconfig.rnc:
* etc/schema/dotnet-packages-config.rnc:
* etc/schema/dotnet-packages-props.rnc:
* etc/schema/dotnet-resx.rnc:
* etc/schema/msbuild.rnc:
* etc/schema/nuget.rnc:
* etc/schema/nuspec.rnc: New files.
* etc/schema/README: Document copyright status of above new files.
* etc/schema/schemas.xml: Use above new files to support Mono/.NET
development related XML files.
This change was discussed in:
https://lists.gnu.org/r/emacs-devel/2024-02/msg00638.html
Paul Eggert [Sun, 12 May 2024 21:26:32 +0000 (14:26 -0700)]
Simplify 32-bit Android bit fiddling
* src/sfnt.c: Include stdbit.h.
(sfnt_count_leading_zero_bits) [!INT64_MAX]: Remove this function,
which was confusingly named as it actually returned 31 minus the
number of leading zero bits.
(sfnt_multiply_divide_2) [!INT64_MAX]: Use stdc_leading_zeros instead.
Paul Eggert [Sun, 12 May 2024 21:22:58 +0000 (14:22 -0700)]
Prefer stdbit.h to count-one-bits.h etc
C23's <stdbit.h> in the long run should be better supported than
Gnulib's count-one-bits.h and similar headers, so switch to the
C23 primitives, with a Gnulib fallback for platforms lacking C23.
* admin/merge-gnulib (GNULIB_MODULES): Remove count-leading-zeros,
count-one-bits, count-trailing-zeros. Add stdc_bit_width,
stdc_count_ones, stdc_trailing_zeros.
* lib/count-leading-zeros.c, lib/count-leading-zeros.h:
* lib/count-one-bits.c, lib/count-one-bits.h:
* lib/count-trailing-zeros.c, lib/count-trailing-zeros.h: Remove.
* lib/stdbit.c, lib/stdbit.in.h, lib/stdc_bit_width.c:
* lib/stdc_count_ones.c, lib/stdc_leading_zeros.c:
* lib/stdc_trailing_zeros.c, m4/stdbit_h.m4:
New files, copied from Gnulib.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
* src/data.c: Do not include count-one-bits.h, count-trailing-zeros.h.
Instead, rely on lisp.h including stdbit.h.
(Flogcount, Fbool_vector_count_population)
(Fbool_vector_count_consecutive): Use stdbit.h macros instead of
count-one-bits.h and count-trailing-zeros.h macros.
(shift_right_ull, count_one_bits_word, pre_value)
(count_trailing_zero_bits): Remove; no longer needed.
* src/lisp.h: Include stdbit.h instead of count-leading-zeros.h.
(elogb): Use stdbit.h macro instead of count-leading-zeros.h macro.
Dmitry Gutov [Sat, 18 May 2024 13:30:23 +0000 (16:30 +0300)]
minibuffer-completion-help: Fix earlier mistake
* lisp/minibuffer.el (minibuffer-completion-help): Fix earlier
mistake. Instead of altering a variable whose value is
immutable (and already captured in a saved list), move the
reference to said list to a lexical binding and alter that
list's second element instead.
Tony Zorman [Sun, 15 Oct 2023 14:51:00 +0000 (16:51 +0200)]
use-package: Add ':ignored-files' support to ':vc' keyword
* lisp/use-package/use-package-core.el (use-package-split-when):
New utility function to split a list whenever a specified
predicate returns t.
(use-package-vc-valid-keywords): A new defconst to gather all
allowed keywords.
(use-package-normalize--vc-arg): Properly normalize the
':ignored-files' keyword, in that the following are all valid
ways of entering files:
:ignored-files "a"
:ignored-files ("a")
:ignored-files "a" "b" "c"
:ignored-files ("a" "b" "c")
(use-package-normalize/:vc): Adjust normalization, now that we
do not necessarily receive a valid plist as an input. (Bug#66567)
* test/lisp/use-package/use-package-tests.el
(use-package-test-normalize/:vc): Add tests for ':ignored-files'
keyword.
Jared Finder [Fri, 26 Jan 2024 18:08:30 +0000 (10:08 -0800)]
Add user option to only display default tool bar
This works well with `window-tool-bar-mode', to be added in upcoming
commit. Then the default tool bar is displayed frame-wide and
mode-specific tool bars are displayed in the window that mode is
active in.
* lisp/tool-bar.el (tool-bar-always-show-default): New user option.
(tool-bar--cache-key, tool-bar-make-keymap-1): Return default tool bar
when option is set.
Eli Zaretskii [Sat, 18 May 2024 09:15:21 +0000 (12:15 +0300)]
Document :box attribute caveats when used on display strings
* doc/lispref/display.texi (Replacing Specs, Face Attributes):
Mention special considerations when a display string has a
':box' face attribute identical to the surrounding buffer text.
Suggested by JD Smith <jdtsmith@gmail.com>. (Bug#70637)
Joost Kremers [Tue, 7 May 2024 09:52:27 +0000 (11:52 +0200)]
Make 'vtable-insert-object' more versatile
* lisp/emacs-lisp/vtable.el (vtable-insert-object): Rename
argument AFTER-OBJECT to LOCATION; allow use of index to
refer to the insertion position; add argument BEFORE.
(Bug#70664).
* etc/NEWS:
* doc/misc/vtable.texi (Interface Functions): Document the
change.
* test/lisp/emacs-lisp/vtable-tests.el
(test-vtable-insert-object): New test.
Eli Zaretskii [Sat, 18 May 2024 06:12:54 +0000 (09:12 +0300)]
Improve documentation of 'movemail'
* doc/emacs/rmail.texi (Movemail): Fix the name of the Mailutils
manual in the printed version. Add index entries. Move the
description of remote mailboxes to...
(Remote Mailboxes): ...here, to avoid duplication.