Po Lu [Fri, 12 Jul 2024 03:59:09 +0000 (11:59 +0800)]
Document means of executing Emacs from unrelated Android applications
* doc/emacs/android.texi (Android Environment): Document
significance, effect and purpose of EMACS_CLASS_PATH and
EMACS_LD_LIBRARY_PATH, and the utility of `pm path
org.gnu.emacs'.
Jim Porter [Tue, 9 Jul 2024 17:45:35 +0000 (10:45 -0700)]
Don't emit a prompt in Eshell when a background command is killed
* lisp/eshell/esh-cmd.el (eshell-resume-command): Check for
background-ness before resetting the prompt.
* test/lisp/eshell/esh-cmd-tests.el
(esh-cmd-test/background/simple-command): Make the regexp a bit
stricter.
(esh-cmd-test/background/kill): New test.
Paul Eggert [Thu, 11 Jul 2024 13:28:58 +0000 (15:28 +0200)]
Avoid mpz for some common timestamp cases
Performance problem reported by Gerd Möllmann and Mattias Engdegård in:
https://lists.gnu.org/r/emacs-devel/2024-06/msg00530.html
https://lists.gnu.org/r/emacs-devel/2024-06/msg00539.html
* src/timefns.c (CFORM_SECS_ONLY): The exact tv_nsec value is now
ignored if nonnegative (i.e., the only thing that matters is that
it’s nonnegative).
(decode_time_components): Use intmax_t instead of mpz arithmetic
if the tick count fits. Add another ‘default: eassume (false);’
so that the revised code pacifies --enable-gcc-warnings with GCC
11.4.0 on x86-64.
Paul Eggert [Thu, 11 Jul 2024 13:03:50 +0000 (15:03 +0200)]
Decode current time directly to timespec
* src/timefns.c (decode_time_components): If FASTER_TIMEFNS, when
returning the current time and the desired form is struct timespec
or time_t, return it directly rather than converting it to struct
ticks_hz and then to struct timespec. This can avoid some mpz
calculations and/or bignums.
Paul Eggert [Thu, 11 Jul 2024 10:57:01 +0000 (12:57 +0200)]
In timefns.c avoid by-hand overflow checking
Prefer functions like ckd_add to do overflow checking, instead of
doing it by hand, to simplify and I hope to make things a bit less
error prone.
* src/timefns.c (TIME_T_MIN, TIME_T_MAX): Remove. All by-hand
overflow checking replaced with calls to ckd_add or ckd_mul.
(s_ns_to_timespec): New static function, that uses ckd_add
instead of by-hand overflow checking.
(ticks_hz_to_timespec): Use it.
(check_tm_member): Use mpz_fits_sint_p and mpz_get_si rather
than mpz_to_intmax and by-hand overflow checking.
Paul Eggert [Thu, 11 Jul 2024 10:42:57 +0000 (12:42 +0200)]
Optimize smallish mpz to native int conversion
* src/bignum.c (make_integer_mpz, mpz_to_intmax):
If FASTER_BIGNUM, optimize the common case where the value fits in
long int. In this case we can use mpz_fits_slong_p and mpz_get_si
instead of looping with mpz_getlimbn.
(mpz_to_uintmax): Likewise for unsigned long int and mpz_get_ui.
Paul Eggert [Thu, 11 Jul 2024 10:27:36 +0000 (12:27 +0200)]
New FASTER_BIGNUM macro to test slow-path code
* src/bignum.h (FASTER_BIGNUM): New macro.
(mpz_set_intmax, mpz_set_uintmax): Optimize only if FASTER_BIGNUM.
Also, use ckd_add to test for overflow instead of doing it by hand.
Paul Eggert [Wed, 10 Jul 2024 08:23:31 +0000 (10:23 +0200)]
In timefns, prefer ui mul and div
* src/timefns.c (ticks_hz_hz_ticks): If the multiplier
is a fixnum that fits in unsigned long, use mpz_mul_ui
instead of the more-expensive mpz_mul. Similarly, if the
divisor is a fixnum that fits in unsigned long, use
mpz_fdiv_q_ui instead of mpz_fdiv_q.
Paul Eggert [Wed, 10 Jul 2024 00:37:55 +0000 (02:37 +0200)]
Reduce size of integer product in timefns
* src/timefns.c (emacs_gcd): New static function.
(ticks_hz_hz_ticks): Use it to reduce the size of the integer
product in the common case when converting from ns to ps. For
that, we need to multiply t.ticks only by 10³, not multiply by
10¹² and then divide by 10⁹. This avoids the need to use bignums
in a significant number of cases.
Paul Eggert [Mon, 8 Jul 2024 07:26:14 +0000 (09:26 +0200)]
Rename timefns internals
The old names didn’t fit in the conventions used for newer names.
* src/timefns.c (struct ticks_hz): Rename from struct lisp_time.
(union c_time): Rename lt to th.
(ticks_hz_hz_ticks): Rename from lisp_time_hz_ticks.
(ticks_hz_seconds): Rename from lisp_time_seconds.
All uses changed.
Paul Eggert [Sun, 7 Jul 2024 18:50:47 +0000 (20:50 +0200)]
Push some time conversions down
* src/timefns.c: Push some time conversions down to lower level fns.
This is a win in its own right and should allow for further speedups.
(lisp_to_timespec): Remove; this convenience function is no longer
needed now that there would be only one caller. Remaining caller
changed to use definiens.
(enum cform): New constant CFORM_TIMESPEC. Also, CFORM_SECS_ONLY
now generates a struct timespec instead of a struct lisp_time.
(union c_time.ts): New member.
(decode_ticks_hz): Handle new struct timespec cases.
(decode_float_time, lisp_time_struct): New arg cform, and return
union c_time rather than struct lisp_time. All callers changed.
(list4_to_timespec, lisp_time_argument, lisp_seconds_argument):
Let lower-level function do the conversion, to allow for better
optimization.
Paul Eggert [Sun, 7 Jul 2024 14:18:18 +0000 (16:18 +0200)]
Split lisp_to_timespec in two
* src/timefns.c (ticks_hz_to_timespec): New function,
which is almost all the old lisp_to_timespec but with
a 2-arg API. This should help further changes.
(lisp_to_timespec): Use it.
Paul Eggert [Sun, 7 Jul 2024 13:42:10 +0000 (15:42 +0200)]
Refactor timefns order
Move definitions around in timefns.c. This does not affect the
implementation; it merely makes future changes easier to follow.
* src/timefns.c (frac_to_double, mpz_time, lisp_to_timespec)
(enum cform, union c_time, decode_ticks_hz): Move earlier.
Paul Eggert [Sat, 6 Jul 2024 19:52:08 +0000 (21:52 +0200)]
Refactor timefns more functionally
Use a more-functional style in timefns.c, rather than passing
pointers to objects that are filled in. Although this does not
change behavior, it should help future improvements to the code.
* src/keyboard.c (decode_timer): Return a possibly-invalid struct
timespec instead of storing a timespec into a location specified
by an arg, and returning bool. All callers changed.
* src/systime.h (struct lisp_time): Move from here to src/timefns.c,
since the type is private to timefns.c.
* src/timefns.c (decode_float_time, decode_ticks_hz):
Return timestamp instead of storing it into a location specified
by an arg. All callers changed.
(enum cform, union c_time, struct err_time, struct form_time):
New types, to aid functional style.
(decode_time_components): Return struct err_time
instead of returning err and storing timestamp into a location
specified by an arg. New arg cform. All callers changed.
(decode_lisp_time): Return struct form_time instead of returning
form and storing timestamp into a location specified by an arg.
New arg cform, replacing decode_secs_only. All callers changed.
(list4_to_timespec): Return possibly-invalid timestamp instead
of returning a bool and storing timestamp into a location specified
by an arg. All callers changed.
(lisp_time_struct): Omit no-longer-needed arg PFORM.
All callers changed.
Po Lu [Thu, 11 Jul 2024 03:38:41 +0000 (11:38 +0800)]
Take precautions against ill-formed content URIs
* java/org/gnu/emacs/EmacsService.java (openContentUri)
(checkContentUri): Verify that URIs derived from user-provided
file names can be parsed before attempting to open them.
* lisp/progmodes/etags-regen.el (etags-regen--visit-table):
Use kill-buffer-hook to ensure a refresh if the TAGS buffer is
killed manually (bug#71727).
(etags-regen--tags-cleanup):
Bind the hook var to nil to avoid an infloop.
Jim Porter [Sat, 6 Jul 2024 21:09:08 +0000 (14:09 -0700)]
Improve Eshell's behavior when waiting for processes
This has a few benefits. First, it fixes a race condition when killing
old processes in 'eshell-command'. Second, the "wait" built-in command
is now more useful. Finally, killing processes when exiting Eshell (via
'eshell-round-robin-kill') should be much faster.
* lisp/eshell/esh-proc.el (esh-opt): Require.
(eshell-wait-for-process): Make obsolete in favor of...
(eshell-wait-for-processes): ... this. Accept a timeout and support
PIDs. Update callers.
(eshell/wait): New implementation accepting -t/--timeout.
(eshell-round-robin-kill): Use 'eshell-wait-for-processes'.
* lisp/eshell/eshell.el (eshell-command): Use 'eshell-round-robin-kill'.
* doc/misc/eshell.texi (List of Built-ins): Document the new "wait"
behavior.
Andrea Corallo [Tue, 9 Jul 2024 19:11:43 +0000 (21:11 +0200)]
Support interpreted functions as input for 'native-compile' (bug#71934)
* lisp/emacs-lisp/comp.el (comp--spill-lap-single-function): New function.
(comp--spill-lap-function): Make use of and do not accept
'(closure ...' as input.
(comp--spill-lap-function): Specialize on interpreted functions as
well.
(native-compile): Update doc.
* test/src/comp-tests.el (compile-interpreted-functions): New test.
* src/coding.c (make_string_from_utf8):
* src/fileio.c (file_name_directory):
* src/lread.c (Fintern):
* src/gnutls.c (Fgnutls_format_certificate):
Use `make_multibyte_string` and `make_unibyte_string` instead of
more expensive `make_specified_string` and `make_string_from_bytes`.
Michael Albinus [Tue, 9 Jul 2024 15:37:50 +0000 (17:37 +0200)]
Warn if D-Bus error "InteractiveAuthorizationRequired" occurs
* lisp/net/dbus.el
(dbus-error-interactive-authorization-required): New defconst.
(dbus-warn-interactive-authorization-required): New defun.
(dbus-event-error-functions): Add it.
Steven Allen [Tue, 9 Jul 2024 11:16:43 +0000 (13:16 +0200)]
Support interactive D-Bus authorization
When invoking D-Bus methods, let the user enable interactive
authorization by passing an :authorizable t parameter. This makes
it possible to D-Bus methods that require polkit authorization.
* configure.ac (HAVE_DBUS_MESSAGE_SET_ALLOW_INTERACTIVE_AUTHORIZATION):
Set a new variable if `dbus_message_set_allow_interactive_authorization'
is available.
* src/dbusbind.c (dbus-message-internal): Allow interactive
authorization by passing :authorizable t.
* doc/misc/dbus.texi (Synchronous Methods, Asynchronous Methods):
* etc/NEWS:
* lisp/net/dbus.el (dbus-call-method-asynchronously): Document the
new parameter.
Po Lu [Tue, 9 Jul 2024 01:35:16 +0000 (09:35 +0800)]
Fix byte-compiler warning in calc.el
* lisp/calc/calc.el
(calc-embedded-open-close-new-formula-alist): Remove previously
introduced quotation marks, as they bring the width of the doc
string past 80.
Stefan Monnier [Mon, 8 Jul 2024 21:09:31 +0000 (17:09 -0400)]
editorconfig-core-handle.el: Fix regressions in fnmatch handling
* lisp/editorconfig-core-handle.el
(editorconfig-core-handle-get-properties-hash): Fix computation of
relative file name.
(editorconfig-core-handle--fnmatch-p): Handle the case when `pattern`
doesn't have a `/` but does match the `/` character.
Po Lu [Mon, 8 Jul 2024 07:33:26 +0000 (15:33 +0800)]
Correct conditions for iconification on Android
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity)
<isPaused>: Rename to <isStopped>.
(attachWindow): Adjust to match.
(onPause): Delete function.
(onStop): Deem frames iconified after calls to onStop instead.
Michael Albinus [Sun, 7 Jul 2024 17:34:37 +0000 (19:34 +0200)]
Fix Tramp parser
* lisp/net/tramp.el (tramp-host-with-port-regexp): Declare.
(tramp-set-syntax): Set also `tramp-host-with-port-regexp'.
(tramp-build-host-with-port-regexp): New defun.
(tramp-host-with-port-regexp): Make it a defvar. (Bug#71972)