Don't highlight matches in dired query-replace commands
* lisp/dired-aux.el (dired-do-query-replace-regexp)
(dired-do-replace-regexp-as-diff)
(dired-do-find-regexp-and-replace): Turn off lazy highlighting
when reading the regexp from the user to avoid highlighting
regexp matches in the dired buffer. (bug#72147)
*
lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode--indent-rules,
tsx-ts-mode--font-lock-compatibility-bb1f97b,
tsx-ts-mode--font-lock-compatibility-function-expression,
tsx-ts-mode--font-lock-compatibility-function-expression,
typescript-ts-mode--font-lock-settings): Use the new helper.
Paul Eggert [Sat, 20 Jul 2024 22:52:05 +0000 (15:52 -0700)]
Fix bool vector length overflow
* src/alloc.c (make_clear_bool_vector): It’s now the caller’s
responsibility to make sure the bool vector length is in range.
Add an eassert to double-check this. This lets some locals be
ptrdiff_t not EMACS_INT.
(Fmake_bool_vector, Fbool_vector):
Check that bool vector lengths are in range.
* src/lisp.h (BOOL_VECTOR_LENGTH_MAX): New macro.
(bool_vector_words, bool_vector_bytes): Avoid undefined
behavior if size == EMACS_INT_MAX - (BITS_PER_BITS_WORD - 1).
This is mostly theoretical but it’s easy to do it right.
* src/lread.c (read_bool_vector): Use EMACS_INT, not just ptrdiff_t.
Check that length doesn’t exceed BOOL_VECTOR_LENGTH_MAX.
This fixes an unlikely integer overflow where the calculated size
went negative.
Paul Eggert [Sat, 20 Jul 2024 16:03:24 +0000 (09:03 -0700)]
Change list-length intptr_t to ptrdiff_t
* src/fns.c (list_length, Fsafe_length, Fproper_list_p):
Use ptrdiff_t not intptr_t for accumulator, since result is ptrdiff_t.
This fixes a minor glitch in 2019-01-11T05:35:31!eggert@cs.ucla.edu
where I removed unnecessary overflow checks but forgot to change types.
This change should alter generated code only on oddball platforms where
ptrdiff_t is narrower than intptr_t, e.g., CheriBSD.
Yuan Fu [Sat, 20 Jul 2024 20:56:32 +0000 (13:56 -0700)]
Support dumping tree-sitter query (bug#69952)
Previous commit allows Emacs to dump tree-sitter queries by simply
dumping the query string and language symbol, and left the query object
and cursor object as NULL. This commit makes sure Emacs doesn't crash
when loading the dumped query, by make sure Emacs can handle the case
where the cursor is NULL.
* src/treesit.c (make_treesit_query): Initialize query with null cursor.
(treesit_ensure_query_cursor): New function.
(treesit_initialize_query): Ensure cursor is non-null.
* src/treesit.h (Lisp_TS_Query): Update documentation.
Paul Eggert [Sat, 20 Jul 2024 15:52:55 +0000 (08:52 -0700)]
SAFE_ALLOCA fixes
* src/comp.c (declare_imported_func, emit_simple_limple_call)
(declare_lex_function, compile_function):
* src/emacs-module.c (funcall_module):
* src/fns.c (Fstring_distance):
* src/font.c (font_sort_entities):
* src/haikumenu.c (digest_menu_items, haiku_menu_show):
* src/pgtkselect.c (Fpgtk_register_dnd_targets):
* src/xfns.c (Fx_begin_drag):
* src/xmenu.c (x_menu_show):
* src/xterm.c (x_dnd_compute_toplevels, handle_one_xevent)
(x_term_init):
Prefer SAFE_NALLOCA to doing size multiplication by hand, to catch
unlikely integer overflows.
* src/comp.c (emit_simple_limple_call): Fix bug where
SAFE_FREE was called too early, leading to unlikely
use of freed storage.
* src/xterm.c (handle_one_xevent): Remove side effects
from SAFE_ALLOCA args, as the args are evaluated twice.
James Thomas [Tue, 16 Jul 2024 01:34:23 +0000 (07:04 +0530)]
; * doc/misc/gnus.texi (Agent Caveats): Fix doc
* doc/misc/gnus.texi (Agent Caveats): Change doc due to commit
2020-10-16 "Add a new variable to control Gnus Agent caching"
(41d220dc6085, bug#43356). (Bug#72134)
Paul Eggert [Sat, 20 Jul 2024 07:17:14 +0000 (00:17 -0700)]
Avoid accessing uninitialized bool_vector words
Although loading uninitialized works from memory and then ignoring
the result works fine on conventional architectures, it
technically has undefined behavior in C, so redo bool_vector
allocation so that the code never does that. This can improve
performance when allocating large vectors of nil, since calloc can
clear the memory lazily.
* src/alloc.c (make_clear_bool_vector): New function,
a generalization of make_uninit_bool_vector.
(make_uninit_bool_vector): Use it.
(Fmake_bool_vector): If !INIT, rely on make_clear_bool_vector.
* src/alloc.c (Fbool_vector):
* src/fns.c (Freverse): Don’t access uninitialized bool_vector words.
* src/xdisp.c (Fremember_mouse_glyph) [CONVERT_TO_EMACS_RECT]:
Expand CONVERT_TO_EMACS_RECT to convert native rectangles into
a readable format if required. Reported by Stefan Kangas
<stefankangas@gmail.com>.
Po Lu [Sat, 20 Jul 2024 03:28:47 +0000 (11:28 +0800)]
Respect mouse-fine-graned-tracking in touch screen simple translation
* lisp/touch-screen.el (touch-screen-current-tool): Expand doc
string.
(touch-screen-handle-point-update): Record extents of glyph
beneath the mouse as computed by `remember_mouse_glyph' if
necessary, and defer generation of mouse-movement events till
the mouse exit it.
* src/xdisp.c (Fremember_mouse_glyph): New function.
(syms_of_xdisp): Define new subr.
Paul Eggert [Fri, 19 Jul 2024 20:39:21 +0000 (13:39 -0700)]
Work around GCC bug 58416 on 32-bit x86
* configure.ac (C_SWITCH_MATCHINE): On 32-bit x86 with GCC 4+,
append -mfpmath=sse (if SSE2 is known to work) or -fno-tree-sra
(otherwise) to work around GCC bug 58416.
* etc/NEWS: Mention this.
Paul Eggert [Fri, 19 Jul 2024 19:44:35 +0000 (12:44 -0700)]
In ‘INSTALL’ put configure vars in one section
* INSTALL: Move description of CFLAGS etc. into the section headed
“Here is a complete list of the variables you may want to set”
since they are also variables one might want to set.
Jim Porter [Fri, 19 Jul 2024 16:34:03 +0000 (09:34 -0700)]
Don't set exit info in Eshell if the command is being piped elsewhere
Previously, the exit info in Eshell was that of the last command that
finished, rather than the last command in a pipeline.
* lisp/eshell/esh-cmd.el (eshell-exec-lisp)
(eshell-lisp-command): Check whether the command is being piped.
* lisp/eshell/esh-proc.el (eshell-gather-process-output): Record whether
the command is being piped...
(eshell-sentinel): ... and do the right thing with that info.
* test/lisp/eshell/esh-proc-tests.el
(esh-proc-test/sigpipe-exits-process): Check the exit status to ensure
we don't report the first process's SIGPIPE exit.
Jim Porter [Tue, 24 Jan 2023 01:21:57 +0000 (17:21 -0800)]
Split out exit code parts of 'eshell-close-handles' into a new function
* lisp/eshell/esh-cmd.el (eshell-last-command-status)
(eshell-last-command-result): Move here from esh-io.el.
(eshell-set-exit-info): New function, extracted from
'eshell-close-handles'.
* lisp/eshell/esh-io.el (eshell-close-handles): Make old calling
convention obsolete. Update callers to use 'eshell-set-exit-info' as
needed.
* lisp/play/gamegrid.el (gamegrid-add-score-insecure): Move point to
the score just added, or end of buffer if the new score did not make
the list. This makes it easier to see where the last game
ranked. (Bug#72185)
Jim Porter [Thu, 18 Jul 2024 18:43:34 +0000 (11:43 -0700)]
Improve implementation of built-in Eshell "kill" command
* lisp/eshell/esh-proc.el (eshell/kill): Fix handling of commands like
"kill 123". Use REMOTE when signalling PIDs in remote directories.
Signal using process objects when possible. Report errors when failing
to signal.
* test/lisp/eshell/esh-proc-tests.el (esh-proc-test/kill/process-id)
(esh-proc-test/kill/process-object): New tests (bug#72013).
Jim Porter [Wed, 17 Jul 2024 05:07:33 +0000 (22:07 -0700)]
Improve handling of deferrable Eshell commands
Now, we use the 'eshell-deferrable' wrapper to wrap a form that returns
a process (or list thereof). This improves upon the old method, which
failed to handle 'eshell-replace-command' correctly. In that case,
Eshell would fail to unmark commands as deferrable when necessary
(e.g. for commands in pipelines).
* lisp/eshell/esh-cmd.el (eshell-deferrable-commands): Make into a
defvar.
(eshell-deferrable): New function...
(eshell-structure-basic-command): ... use it.
(eshell-trap-errors): Rename to...
(eshell-do-command): ... this, and use 'eshell-deferrable'. Update
callers.
(eshell--unmark-deferrable): Remove. Update callers.
(eshell-execute-pipeline): Remove 'eshell-process-identity'.
(eshell-process-identity, eshell-named-command*, eshell-lisp-command*):
Make obsolete.
* test/lisp/eshell/esh-cmd-tests.el (eshell-test-replace-command): New
function.
(esh-cmd-test/pipeline/replace-command): New test.
Stefan Kangas [Tue, 16 Jul 2024 02:34:53 +0000 (04:34 +0200)]
Use strnlen to avoid unnecessary work in pgtkfns.c
* src/pgtkfns.c (pgtk_get_defaults_value, pgtk_set_defaults_value):
Factor out new function...
(pgtk_check_resource_key_length): ...to here. Avoid unnecessary work by
using strnlen.
Eli Zaretskii [Thu, 18 Jul 2024 09:59:28 +0000 (12:59 +0300)]
Minor cleanup of code in insdel.c
* src/insdel.c (del_range_2): Update *_BYTE variables _after_
updating the corresponding character values. This follows what we
do everywhere else, and allows to put a watchpoint on, say, Z_BYTE
to check consistency between the character and byte counts. See
bug#72165 for one situation where it is useful.
Po Lu [Tue, 16 Jul 2024 02:14:30 +0000 (10:14 +0800)]
Port better to Android 3.0
* java/org/gnu/emacs/EmacsNoninteractive.java (main): Use the
old getPackageInfo calling convention if it exists rather than
on Android 2.3.3 and earlier.
Paul Eggert [Wed, 17 Jul 2024 15:13:31 +0000 (08:13 -0700)]
Go back to preferring -isystem to -I
* configure.ac: Go back to preferring -isystem to -I,
as headers like <gobject/gparam.h> still need it. This
reverts almost all of 2024-07-16T02:25:44!eggert@cs.ucla.edu,
except that the ‘nw="$nw -Wsystem-headers"’ line continues to
be removed as it is no longer needed due to recent Gnulib changes.
Problem reported by Eli Zaretskii in:
https://lists.gnu.org/r/emacs-devel/2024-07/msg00756.html
Notive the nested "*" blob inside the the {} group.
Eglot used to reject them in 'workspace/didChangeWatchedFiles' requests,
responding with "Internal Error". This could confuse some servers. Now
I've done some changes to the state machine generation and it supports
them.
* lisp/progmodes/eglot.el (eglot--glob-parse): Relax parser.
(eglot--glob-fsm): New helper.
(eglot--glob-compile, eglot--glob-emit-{}): Use it.
* test/lisp/progmodes/eglot-tests.el (eglot-test-glob-test):
Uncomment some test cases.
Paul Eggert [Tue, 16 Jul 2024 16:19:31 +0000 (09:19 -0700)]
Check for more ‘find’ failures and port ‘find’
* Makefile.in (install-eln), configure.ac (emacs_cv_find_delete):
* make-dist: Use ‘find ... -exec CMD {} +’ rather than ‘find
... -exec CMD {} \;’ so that if CMD fails, ‘find’ fails too.
* Makefile.in (install-eln): Port to ‘find’ implementations that
behave differently from GNU ‘find’ when given an argument
that contains ‘{}’ within a longer string. POSIX allows
this behavior.
Paul Eggert [Tue, 16 Jul 2024 02:41:35 +0000 (19:41 -0700)]
Quote BIN_DESTDIR better
* Makefile.in (BIN_DESTDIR, install-eln, uninstall):
* src/Makefile.in ($(pdmp)):
Be more consistent about quoting BIN_DESTDIR and ELN_DESTDIR,
avoiding double-quoting ''like this'' which does not work as
expected.
Paul Eggert [Tue, 16 Jul 2024 02:25:44 +0000 (19:25 -0700)]
Prefer -I to -isystem
* configure.ac: Simplify configuration by using -I instead of
-isystem, as -isystem is no longer helpful for suppressing
diagnostics (and likely has not been helpful for years).
Do not suppress -Wsystem-headers, as Gnulib no longer enables it.
Paul Eggert [Mon, 15 Jul 2024 00:00:56 +0000 (01:00 +0100)]
Simplify time form analysis
This does not change behavior; it merely refactors the code
for simplicity.
* src/timefns.c (enum timeform, struct form_time):
Remove. All uses removed.
(decode_time_components): Accept HZ instead of FORM.
This saves a switch. All uses changed.
(decode_lisp_time): Return union c_time instead of struct form_time.
All uses changed.
(lisp_time_cform): Remove. All uses changed to just use
decode_lisp_time.
(time_arith, Ftime_convert): Check (TICKS . HZ) form directly
using CONSP, instead of using the old struct form_time.
That's fast enough here.
Paul Eggert [Sun, 14 Jul 2024 16:36:01 +0000 (17:36 +0100)]
Test !FASTER_TIMEFNS with builtin resolutions
* src/timefns.c (timespec_hz, trillion, ztrillion):
If !FASTER_TIMEFNS, do not optimize the calculations of
these variables. This gives better test coverage of the
slow-path code, when compiling with -DFASTER_TIMEFNS=0.
(NEED_ZTRILLION_INIT): Move up, to simplify #ifdefery.
Now defined or not defined, instead of being 1 or not defined,
since it is used only via #ifdef.
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.