Paul Eggert [Sun, 14 Jul 2024 22:45:31 +0000 (23:45 +0100)]
Fix buffer size problem in print_bool_vector
* src/print.c (print_bool_vector): Don’t assume SIZE fits
into ptrdiff_t, since it is an EMACS_INT. This
pacifies gcc -Wformat-overflow on i686 --with-wide-int.
* src/textconv.c (get_conversion_field): Set max value to
PTRDIFF_MAX, not MOST_POSITIVE_FIXNUM, since the variable is
ptrdiff_t, not EMACS_INT. Problem caught by gcc -Woverflow on a
32-bit platform with --with-wide-int.
Paul Eggert [Sun, 14 Jul 2024 19:53:28 +0000 (20:53 +0100)]
Pacify 32-bit GCC 14.1.1 in timer_check_2
* src/keyboard.c (timer_check_2): Refactor to make flow control
more obvious, to pacify -Wanalyzer-use-of-uninitialized-value with
gcc 14.1.1 20240607 (Red Hat 14.1.1-5) on i686.
Paul Eggert [Fri, 12 Jul 2024 16:23:30 +0000 (17:23 +0100)]
Use Gnulib workaround for Android strnlen bug
The workaround for the Android 5.0 (API 21) strnlen bug
is now done in m4/strnlen.m4, taken from Gnulib, so
there is no need for Emacs to have its own workaround.
* configure.ac (ORIGINAL_AC_FUNC_STRNLEN, AC_FUNC_STRNLEN):
Remove.
Previously, project-kill-buffers always called (project-current t). A
Lisp program could change what project project-kill-buffers operated
on by binding project-current-directory-override. However, in some
edge cases (for example, if the project was deleted between looking it
up and calling project-kill-buffers) this might fail to detect a
project, and so (project-current t) would prompt the user.
To avoid this, accept the project to kill buffers for as an argument.
* lisp/progmodes/project.el (project-kill-buffers): Take project as an
optional argument (bug#72019).
Peter Oliver [Mon, 15 Jul 2024 11:03:47 +0000 (12:03 +0100)]
Fix intermittent failure of dired-test-bug27243-02
* test/lisp/dired-tests.el (dired-test-bug27243-02): Exclude free disk
space from dired listing in this test, in case it changes while it's
running and confuses the result. (Bug#72120)
Jim Porter [Sat, 13 Jul 2024 18:43:42 +0000 (11:43 -0700)]
Don't save to history from 'eshell-command' when aborting
* lisp/eshell/eshell.el (eshell-add-input-to-history)
(eshell--save-history): Declare.
(eshell-command-mode-exit): New function...
(eshell-command-mode): ... use it.
* lisp/eshell/em-hist.el (eshell-hist-initialize): Don't handle
minibuffer logic here. Always read history file (this ensures that
'eshell-command' can see the history, too).
(eshell-add-command-to-history): Remove.
Eli Zaretskii [Sun, 14 Jul 2024 06:06:55 +0000 (09:06 +0300)]
Fix decoding 'display' properties with SVG images in Enriched mode
* lisp/textmodes/enriched.el (enriched-next-annotation): Reject
matches of 'enriched-annotation-regexp' inside strings. Reported
by Christopher Howard <christopher@librehacker.com> in
https://lists.gnu.org/archive/html/help-gnu-emacs/2024-06/msg00178.html.
Paul Eggert [Sun, 14 Jul 2024 05:16:26 +0000 (22:16 -0700)]
Minor renaming in timefns.c
* src/timefns.c (current_time_in_cform): Rename this static
function from current_time_in_form, since this is about enum cform
not enum timeform. Use changed.
Po Lu [Sun, 14 Jul 2024 04:46:23 +0000 (12:46 +0800)]
Do not set LD_LIBRARY_PATH during Android initialization
* doc/emacs/android.texi (Android Environment): Adjust
documentation to match.
* java/org/gnu/emacs/EmacsNoninteractive.java (main1): New
function. Remove initialization of EmacsNative hither.
(main): Acquire an ApplicationInfo or LoadedApk, as the case may
be on the host system, derive a ClassLoader from the result, and
load and call `main1' from within this class loader.
* src/android-emacs.c (main):
* src/android.c (setEmacsParams): Do not override
LD_LIBRARY_PATH or set EMACS_LD_LIBRARY_PATH. This enables
Emacs to execute subprocesses in certain "fortified" Android
systems, amongst other things.
Jim Porter [Thu, 11 Jul 2024 23:29:37 +0000 (16:29 -0700)]
Treat SVG images like other image types in 'shr-put-image'
For both SVG and no-SVG builds, this works as expected (in the no-SVG
case, it would raise an error which subsequently gets ignored).
However, compared to the previous implementation, this lets users resize
SVG images just like every other image type (bug#71913).
Peter Oliver [Fri, 12 Jul 2024 09:52:23 +0000 (10:52 +0100)]
Fix 'wdired-test-unfinished-edit-01'
* test/lisp/wdired-tests.el (wdired-test-unfinished-edit-01):
Don't modify the random directory name if, by chance, it happens
to contain the substring "foo" anywhere but immediately after the
slash. (Bug#72073)
Eli Zaretskii [Sat, 13 Jul 2024 10:16:42 +0000 (13:16 +0300)]
; Fix last change
* lisp/progmodes/java-ts-mode.el (java-ts-mode):
* lisp/progmodes/c-ts-mode.el (c-ts-mode, c++-ts-mode): Load the
Doxygen grammar quietly, so that if it isn't available, the user
is not annoyed. (Bug#71874)
Fontify doxygen support to 'c-ts-mode', 'c++-ts-mode' and 'java-ts-mode'
Add doxygen support to 'c-ts-mode', 'c++-ts-mode' and
'java-ts-mode' using tree-sitter-doxygen from
github.com/tree-sitter-grammars.
* lisp/progmodes/c-ts-common.el
(c-ts-mode-doxygen-comment-font-lock-settings): Add font locking
rules for doxygen comment.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--feature-list): Add
'document' feature.
(c-ts-mode--doxygen-comment-regex): New regular expression for
doxygen comments.
(c-ts-mode, c++-ts-mode): Add support for doxygen parser.
* lisp/progmodes/java-ts-mode.el (java-ts-mode): Add support for
doxygen parser. (Bug#71874)
F. Jason Park [Fri, 12 Jul 2024 21:41:54 +0000 (14:41 -0700)]
Fix invalid defcustom type for erc-buffers option
* lisp/erc/erc.el (erc-ensure-target-buffer-on-privmsg): Change
invalid inner `choice' to a `const' for the third-state `status'
variant, which is new in ERC 5.6 and Emacs 30. Thanks to Mattias
Engdegård for catching this.
Eli Zaretskii [Fri, 12 Jul 2024 06:58:53 +0000 (09:58 +0300)]
Fix infloop in 'shell-resync-dirs'
* lisp/shell.el (shell-eval-command): Fix detection of newline
after last output line. (Bug#71896)
(shell-resync-dirs): Make sure the inner loop never infloops.
Suggested by Troy Hinckley <troyhinckley@dabrev.com>.
Juri Linkov [Fri, 12 Jul 2024 17:54:53 +0000 (20:54 +0300)]
* lisp/gnus/mm-uu.el (mm-uu-type-alist): Fix end-regexp of git-format-patch.
Replace git-format-patch end-regexp "^-- " with "^$".
The regexp "^-- " was intended to mark the end
of the git-formatted patch. However, git-format-patch
can produce patches without a signature. Also often
patches are just copy-pasted from the output of 'C-x v d'.
Therefore, now an empty line marks the end of the patch
since properly formatted patches don't contain an empty line
and properly configured MUAs don't strip whitespace from patches.
Suggested by Luis Henriques <henrix@camandro.org> and
Kévin Le Gouguec <kevin.legouguec@gmail.com> in bug#72059.
Po Lu [Fri, 12 Jul 2024 06:31:33 +0000 (14:31 +0800)]
Render more Android functions safe to execute in a batch session
* src/androidfns.c (Fx_display_mm_width, Fx_display_mm_height)
(Fandroid_display_monitor_attributes_list)
(Fandroid_external_storage_available_p)
(Fandroid_request_storage_access): Verify that a display
connection or service object is available.
* src/androidselect.c (Fandroid_get_clipboard)
(Fandroid_browse_url_internal, Fandroid_get_clipboard_targets)
(Fandroid_get_clipboard_data, Fandroid_notifications_notify):
Moderate tone of error messages.
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.