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)
Stefan Kangas [Sun, 7 Jul 2024 11:40:59 +0000 (13:40 +0200)]
Make `checkdoc-verb-check-experimental-flag` default to nil
This user option leads to a very large amount of false positives in
practice. In my personal experience, almost all occurrences that are
flagged are false positives. Flipping the default to something less
intrusive should hopefully encourage more use of checkdoc.
* lisp/emacs-lisp/checkdoc.el
(checkdoc-verb-check-experimental-flag): Switch the default to nil.
Stefan Kangas [Sun, 7 Jul 2024 11:37:55 +0000 (13:37 +0200)]
checkdoc: Flag formatting mistakes in warnings
* lisp/emacs-lisp/checkdoc.el (checkdoc-message-text-next-string)
(checkdoc-message-text-engine): Flag formatting mistakes in warnings.
(checkdoc--warning-function-re): New variable.
Juri Linkov [Sun, 7 Jul 2024 06:57:34 +0000 (09:57 +0300)]
* lisp/files.el (insert-directory): Quote switches in wildcard case.
Use shell-quote-wildcard-pattern on the switches string split by
split-string-and-unquote. This helps to quote such switches as
"--block-size='1" (bug#71935).
Juri Linkov [Sun, 7 Jul 2024 06:52:01 +0000 (09:52 +0300)]
Fix uses of 'dired-omit-mode' (bug#71905)
* lisp/dired.el (dired-jump): Disable dired-omit-mode with -1.
* lisp/files.el (recover-session): Disable dired-omit-mode
explicitly afterwards instead of modifying dired-mode-hook
that fails when it contains a lambda.
Stefan Kangas [Sun, 7 Jul 2024 02:31:01 +0000 (04:31 +0200)]
Fix fontification of network files in `awk-mode`
* lisp/progmodes/cc-awk.el (awk-font-lock-keywords): Fix fontification
of special network file names such as "/inet4/tcp/0/localhost/daytime".
See Info node '(gawk) TCP/IP Networking'.
Po Lu [Sun, 7 Jul 2024 02:19:31 +0000 (10:19 +0800)]
Correct JNI string error checking and miscellaneous corrections
* src/android-emacs.c (main): Do not attempt to load the
bootstrap class path, which is redundant on all Android releases.
* src/android.c (initEmacs, android_browse_url): Do not assume
exceptions will be raised if GetStringUTFChars fails. Decode
Android JNI strings as Qandroid_jni.
* src/androidvfs.c (android_saf_check_nonnull): New function.
(android_saf_new_mkdir): Likewise.