1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-24 14:30:43 -08:00
Commit graph

50721 commits

Author SHA1 Message Date
Martin Rudalics
1434bc97dc Run buffer-local window change functions in their buffers now
The buffer-local-versions of 'window-buffer-change-functions',
'window-size-change-functions',
'window-selection-change-functions' and
'window-state-change-functions' are now run with the respective
buffer temporarily current.  Also, the local version of
'window-buffer-change-functions' is run for the buffer removed
from the window too.

* src/window.c (run_window_change_functions_locally)
(run_window_change_functions_globally): New functions replacing
'run_window_change_functions_1'.
(run_window_change_functions): Run the buffer local versions of
these hooks in their respective buffers.  Run
'window-buffer-change-functions' for the buffer removed from the
window too.
(Vwindow_buffer_change_functions, Vwindow_size_change_functions)
(Vwindow_selection_change_functions)
(Vwindow_state_change_functions): Mention that the buffer-local
versions are run with their buffer temporarily current.
* doc/lispref/windows.texi (Window Hooks): Mention that
buffer-local-versions of window change functions are run with
their buffer temporarily current.  Also say that
'window-buffer-change-functions' will be run for removed buffer
too.
* etc/NEWS: Advertise changes for the buffer-local versions of
window change functions.
2025-10-06 10:27:27 +02:00
Eli Zaretskii
2c0cf894f4 Fix 'restart-emacs' on MS-Windows
* src/w32.c (w32_reexec_emacs): Reset undocumented bits in
STARTUPINFO flags.  Suggested by yhr0x43 <yhr0x43@gmail.com>.
(Bug#79554)
2025-10-02 10:22:37 +03:00
Paul Eggert
50ab62ad75 Use up-to-date time in wait_reading_process_output
In “Avoid duplicate calls to current_timespec” (2015-07-05)
we started caching current_timespec results in NOW.
However, this was buggy: we updated NOW only when the timeout was
nonzero, but the timeout can be set temporarily to zero in several
places in wait_reading_process_output (such as when checking for
process status changes), which would cause us to never update NOW
and therefore never detect that a timeout happened.

Also, this caching was wrong even in principle: since we call
Lisp code from wait_reading_process_output, substantial amounts
of time can pass, and we can be left using an outdated NOW and
incorrectly not time out.  Also, nowadays we can use
monotonic_coarse_timespec which is fast, and which is better
anyway because it’s immune to manual clock changes.

Co-authored-by: Spencer Baugh <sbaugh@janestreet.com>
* src/process.c (wait_reading_process_output):
Stop caching the current realtime.
Instead, use the coarse monotonic clock without caching.
2025-09-27 12:26:24 -07:00
Paul Eggert
5e06aa209b Prefer coarse timestamps when using X sync
They are good enough for this purpose, and are cheaper to get.
* src/timefns.c (monotonic_coarse_timespec): New function.
* src/xterm.c [HAVE_XSYNC && !USE_GTK && HAVE_CLOCK_GETTIME]:
(x_sync_current_monotonic_time): Use it.
(CLOCK_MONOTONIC): Remove; no longer uneeded here.
2025-09-27 12:26:24 -07:00
Andrea Corallo
0b9e96ce5e Make native lisp code reflect EQ C implementation
* src/comp.c (ABI_VERSION): Bump new version
	(comp_t): add 'eq'.
	(helper_link_table): add 'slow_eq'.
	(emit_slow_eq): New function.
	(emit_EQ): Rework to reflect EQ implementation.
	(declare_runtime_imported_funcs): Import 'slow_eq'.
	(Fcomp__init_ctxt): Register emitter 'emit_eq' for op code Qeq.

This and the previous 2 commits increase elisp-benchmarks performance by
3.6% on my test machine. Also a (small) reduction in eln size comes with
it.
2025-09-22 10:28:40 +02:00
Andrea Corallo
e7380934d0 * Make sure the compiler optimizes for symbols_with_pos_enabled 0 in EQ
* src/lisp.h (EQ): Make use '__builtin_expect'.
2025-09-22 10:28:40 +02:00
Pip Cet
020e2f5ddb Change EQ to move slow code path into a separate function
* src/data.c (slow_eq): New function.
    * src/lisp.h (EQ): Call it.
2025-09-22 10:28:40 +02:00
Eli Zaretskii
40adabe2ef Improve documentation of 'accept-process-output'
* doc/lispref/processes.texi (Accepting Output):
* src/process.c (Faccept_process_output): Document better the
meaning of the timeout of 'accept-process-output' a,d the fact
that it doesn't always return as soon as some output is available.
See https://lists.gnu.org/archive/html/emacs-devel/2025-08/msg00750.html
for more details.
2025-09-20 12:32:21 +03:00
Po Lu
2457934323 Fix reference leak in displaying successive dashes of distinct styles on Android
* src/android.c (android_set_dashes): Always release local
reference to dash array even when it was returned by
GetObjectField.
2025-09-20 10:08:05 +08:00
Mattias Engdegård
9f174f08d8 ; * src/bytecode.c (exec_byte_code): Revert gratuituous style change 2025-09-19 10:31:54 +02:00
Po Lu
fb15f86248 ; * src/bytecode.c (exec_byte_code): Fix coding style. 2025-09-19 09:28:17 +08:00
Mattias Engdegård
7d5633d0f4 * src/bytecode.c (exec_byte_code): Better quitcounter reset value.
This value forces a quit check at the next backward branch, to avoid
rare situations being hard to interrupt.
Suggested by Pip Cet.
2025-09-18 22:13:38 +02:00
Mattias Engdegård
0767f1818a Don't save quitcounter across longjmp in exec_byte_code
* src/bytecode.c (exec_byte_code): Reset quitcounter to 1 after longjmp;
the exact value isn't important.  This may reduce register pressure a
tiny bit or at least remove a useless stack slot.
2025-09-18 17:05:29 +02:00
Mattias Engdegård
de4ca2bdb1 Turn some checking macros into functions in the GC marker code
This rids us of a bunch of unhygienic macros with free variables and
makes the marking code actually readable again.  Even better, it is all
processed by the compiler even when the checks are disabled.

* src/alloc.c (CHECK_ALLOCATED, CHECK_LIVE, CHECK_ALLOCATED_AND_LIVE)
(CHECK_ALLOCATED_AND_LIVE_SYMBOL): Transform macros into...
(check_live, check_allocated_and_live, check_allocated_and_live_symbol)
(check_allocated_and_live_vectorlike): ...functions.  Callers adapted.
2025-09-17 12:49:14 +02:00
Mattias Engdegård
08b2d53e48 ; * src/lisp.h (enum handlertype): Comment accuracy. 2025-09-17 12:49:14 +02:00
Eli Zaretskii
125b3588c9 Merge from origin/emacs-30
4745456677 ; * lisp/dired-x.el (dired-find-subdir): Doc fix (bug#794...
0832e5fec5 ; * lisp/vc/vc.el (vc-print-root-log): Improve docstring ...
2fafcdbf6a ; Minor copyedits in src/editfns.c
2025-09-13 07:23:12 -04:00
Spencer Baugh
603a685ad1 Allow disabling of reloading files on doc read failure
Reloading a byte-compiled file when we fail to fetch some
docstring in it is not guaranteed to work and can cause
subtle bugs which are worse than simply not having a
docstring.  Add 'documentation-dynamic-reload' variable to
allow disabling this behavior.  See the discussion in
https://lists.gnu.org/archive/html/emacs-devel/2025-08/msg00304.html
for more details.
* src/doc.c (syms_of_doc): Add 'documentation-dynamic-reload'.
(Fdocumentation, Fdocumentation_property): Check value of
'documentation-dynamic-reload'.
2025-09-13 10:33:20 +03:00
Spencer Baugh
0e9cee2bf5 Ignore keymaps at point for positions outside the buffer
Correct a few edge cases where we used the keymaps at point when
looking up keymaps for an event position which is outside the
current buffer.  Namely:

- Clicking on a part of the mode line which is after the end of
  mode-line-format produces an event with non-nil posn-area but
  nil posn-string.

- Even if posn-string doesn't have a local keymap, we should
  still ignore the keymaps at point if posn-string is non-nil.

* src/keymap.c (Fcurrent_active_maps): Ignore keymaps at point
for more positions outside the buffer.  (bug#76620)
2025-09-09 18:02:24 -04:00
Stefan Monnier
82f6c16514 Allow use of \N{...} earlier to help fix bug#79353
* lisp/emacs-lisp/shorthands.el (hack-read-symbol-shorthands):
Avoid inf-loops during bootstrap.
E.g. this can occur while loading `uni-special-lowercase.el` where
`hack-local-variables--find-variables` uses `downcase` which triggers
loading `uni-special-lowercase.el`, ...

* lisp/international/mule-cmds.el (ucs-names): Explicitly require
`charprop`.

* src/Makefile.in ($(lispsource)/loaddefs.el): Depend on `charprop`.
2025-09-09 18:01:24 -04:00
Eli Zaretskii
2fafcdbf6a ; Minor copyedits in src/editfns.c
* src/editfns.c (Fbuffer_string, Freplace_buffer_contents)
(styled_format): Avoid using non-ASCII characters in doc strings
and comments.
2025-09-09 15:18:16 +03:00
Mattias Engdegård
11b3af6425 Harmonise doc strings for {re-,posix-,}search-{forward,backward}
The doc strings for re-search-forward and re-search-backward have been
improved (bug#25193, bug#31584) but the corresponding posix- and
non-regexp search functions still have the original text, despite
describing the exact same mechanism.

There is no reason for them to differ, so we make them all use the
updated version which also is more readable.  Any future doc string
improvements should be made to all of them in the same way for
consistency.

* src/search.c (Fsearch_backward, Fsearch_forward)
(Fposix_search_backward, Fposix_search_forward):
Use text from Fre_search_forward and Fre_search_backward.
2025-09-07 14:39:07 +02:00
Eli Zaretskii
72401548ca ; * src/process.c (deactivate_process): Fix last change. 2025-09-06 17:52:31 +03:00
Eli Zaretskii
29d18f4ffe Avoid assertion violations when starting client network process
* src/process.c (deactivate_process): Clear the callback info of
descriptors we are closing.  (Bug#79367)
2025-09-06 12:43:19 +03:00
Stefan Monnier
c374bb50da (redisplay_internal): Fix follow-mode (bug#79306)
* src/xdisp.c (redisplay_internal): Don't increment `redisplay_counter`
if we ail out before starting an actual redisplay.
2025-09-05 15:02:54 -04:00
Eli Zaretskii
951e782836 Fix locking to threads of the client network process
* src/process.c (server_accept_connection): Make the client
process be locked to the same thread as the parent server process,
or unlocked if the server process was unlocked.  (Bug#79367)
2025-09-05 08:52:05 +03:00
Po Lu
446c037d57 Fix crash when the same XI device appears in multiple hierarchy events
* src/xterm.c (xi_disable_devices): Move `out' label into the
outermost loop.  (bug#79343)
2025-09-04 09:10:20 +08:00
Mattias Engdegård
985657e515 ; * src/data.c (Fash): GCC argument signedness quibble 2025-09-01 15:13:58 +02:00
Mattias Engdegård
bbc9ed3871 * src/data.c (Fash): Speed up when argument and result are fixnums. 2025-09-01 14:20:04 +02:00
Sergio Pastor Pérez
8d301906e1 bug#79241: Fix incorrect handling of overlays in `vertical-motion'
* src/indent.c (vertical-motion): If iterator is inside an overlay,
reset it to the beginning of line before trying to reach goal
column.  This prevents point from being stuck at the beginning
of overlay strings during upward motions.

Copyright-paperwork-exempt: yes
2025-08-30 12:39:35 +03:00
Robert Pluim
b7cef00571 ; Fix formatting
* src/process.c (clear_fd_callback_data, delete_write_fd,
delete_keyboard_wait_descriptor): Space before paren.
2025-08-27 11:24:53 +02:00
Eli Zaretskii
ff83b735f9 Fix last change in 'next_element_from_display_vector'
* src/xdisp.c (next_element_from_display_vector): Only switch the
iterator from unibyte to multibyte, never in the other direction,
and not if the original character came from a unibyte buffer.
(Bug#79317)
2025-08-26 16:24:55 +03:00
Eli Zaretskii
21b072c607 Fix use of display-table for mode-line display
* src/xdisp.c (next_element_from_display_vector): Fix handling
non-ASCII characters in display-table cells corresponding to
ASCII characters.  (Bug#79311)
2025-08-25 22:27:10 +03:00
Eli Zaretskii
f884b1acef Fix assertion violations caused by recent redisplay changes
* src/xdisp.c (push_it): Don't rest the string_from_prefix_prop_p
flag.  (Bug#79304)
2025-08-25 20:44:36 +03:00
Eli Zaretskii
0c49f5917f Attempt to fix assertion violations in bug#79304
The following changes make the changes for bug#79275 less
radical, closer to their previous shape, while still fixing
that bug.
* src/xdisp.c (push_prefix_prop, get_it_property): Restore
original code that determined the object and position on it.
(get_line_prefix_it_property): Take FROM_BUFFER from the actual
object of the prefix property.
2025-08-25 18:19:14 +03:00
Mattias Engdegård
308e3ab1db Disallow string data resizing (bug#79784)
Only allow string mutation that is certain not to require string data to
be resized and reallocated: writing bytes into a unibyte string, and
changing ASCII to ASCII in a multibyte string.

This ensures that mutation will never transform a unibyte string to
multibyte, that the size of a string in bytes never changes, and that
the byte offsets of characters remain the same.  Most importantly, it
removes a long-standing obstacle to reform of string representation and
allow for future performance improvements.

* src/data.c (Faset): Disallow resizing string mutation.
* src/fns.c (clear_string_char_byte_cache):
* src/alloc.c (resize_string_data):  Remove.
* test/src/data-tests.el (data-aset-string): New test.
* test/lisp/subr-tests.el (subr--subst-char-in-string):
Skip error cases.
* test/src/alloc-tests.el (aset-nbytes-change):
Remove test that is no longer relevant.
* doc/lispref/strings.texi (Modifying Strings):
* doc/lispref/sequences.texi (Array Functions):
* doc/lispref/text.texi (Substitution):  Update manual.
* etc/NEWS: Announce.
2025-08-24 10:28:27 +02:00
Eli Zaretskii
f3434a4f53 Fix line-prefix display when there's a 'display' string at BOL
* src/xdisp.c (push_it): Reset the 'string_from_prefix_prop_p' flag.
(try_window_id): Disable this optimization if the last unchanged
at-beg row begins with a display or overlay string and there;s a
line/wrap-prefix property on the row.
(push_prefix_prop): Accept an additional argument FROM_BUFFER to
indicate that the prefix property was found on buffer text
underlying a display or overlay property, and set up the position
to pop to accordingly.  Reset the 'string_from_display_prop_p' flag
of the iterator after pushing IT to set up for iterating the
prefix string.
(get_it_property): Use it->string, not it->object, as indication
that prefix property is on a string.
(get_line_prefix_it_property): Accept an additional argument:
pointer to a flag indicating that the prefix property was found on
buffer text underlying a display or overlay property.  Callers
adjusted.
(handle_line_prefix): Use the FROM_BUFFER flag to correctly handle
prefix properties on buffer text at the same position as a display
string.  (Bug#79275)
2025-08-23 11:34:10 +03:00
Mattias Engdegård
c04553f655 Speed up JSON parsing by not maintaining line and column (bug#79192)
We use the current parsing position instead.  The line and column in the
error weren't used (nor very accurate to begin with) and the user can
easily compute them when needed.  The line number calculation is kept
just in case but deprecated, for removal in Emacs 32.

* src/json.c (struct json_parser, json_parser_init): Update parser state.
(json_signal_error): New position computation.
(json_skip_whitespace_internal): Remove.
(is_json_whitespace): New.
(json_skip_whitespace, json_skip_whitespace_if_possible)
(json_parse_unicode, json_parse_string, json_parse_number)
(json_parse_value): Simplify and rewrite for efficiency.
(count_chars, count_newlines)
(string_byte_to_pos, string_byte_to_line)
(buffer_byte_to_pos, buffer_byte_to_line): New.
(Fjson_parse_string, Fjson_parse_buffer): Adapt to new parser state.
* test/src/json-tests.el (json-tests--parse-string-error-pos)
(json-tests--parse-buffer-error-pos, json-parse-error-position): New.
* etc/NEWS: Note deprecation of line and column.
2025-08-21 16:42:45 +02:00
Mattias Engdegård
475a5d56d0 ; * src/lread.c (from_buffer_p): New abstraction. 2025-08-21 15:11:13 +02:00
Spencer Baugh
63662f6cee Signal end-of-file with more correct data
end_of_file_error previously always signaled end-of-file with
load-true-file-name if that was non-nil (and a string).
However, this might be the wrong thing to do; for example, if a
file being loaded calls read on a buffer.

* src/lread.c (end_of_file_error): <source>: New argument; check
it to determine what data to signal with.  (bug#68546)
(read_char_escape, read_char_literal, read_string_literal)
(skip_space_and_comments, read0): Pass source to
end_of_file_error.
2025-08-19 17:00:03 +01:00
Stefan Monnier
888dc2a0b5 Reject invalid error symbols (Bug#76447)
* src/eval.c (signal_or_quit): Signal an error if 'signal' gets called
with an invalid error symbol.
2025-08-17 17:26:09 +02:00
Eli Zaretskii
034d755f2f ; * src/process.c (set_proc_thread): Fix assertion. 2025-08-16 13:28:52 +03:00
Eli Zaretskii
c93be71e45 Make sure 'make-process' locks the process to the current thread
* src/process.c (set_proc_thread): New function.
(Fset_process_thread, create_process): Use it.
2025-08-16 13:01:01 +03:00
Spencer Baugh
37325ed5a9 Zero fd_callback_info when deleting an fd
.waiting_thread and .thread could be left set to non-NULL values
in a deleted fd_callback_info entry.  These would never be
cleared by e.g. clear_waiting_thread_info since that only clears
fd_callback_info entries up to max_desc.  Clear fd_callback_info
entirely when deleting an entry.

* src/process.c (clear_fd_callback_data): Add.
(delete_write_fd, delete_keyboard_wait_descriptor): Call
clear_fd_callback_data. (bug#79201)
(delete_read_fd): Remove duplicated clearing code.
(deactivate_process): Remove duplicate recompute_max_desc.
2025-08-16 12:51:35 +03:00
Juri Linkov
0ac3a1f26c New user option 'treesit-enabled-modes' (bug#79180)
* lisp/treesit.el (treesit-enabled-modes): New user option.
* src/treesit.c (treesit-major-mode-remap-alist): New variable.

* lisp/progmodes/c-ts-mode.el:
* lisp/progmodes/csharp-mode.el:
* lisp/progmodes/java-ts-mode.el:
* lisp/progmodes/js.el:
* lisp/progmodes/json-ts-mode.el:
* lisp/progmodes/ruby-ts-mode.el:
* lisp/progmodes/sh-script.el:
* lisp/textmodes/css-mode.el:
* lisp/textmodes/mhtml-ts-mode.el:
* lisp/textmodes/toml-ts-mode.el:
Add ts-mode mapping to 'treesit-major-mode-remap-alist'
for ts-modes that already have the corresponding non-ts mode
association in 'auto-mode-alist'.

* lisp/progmodes/cmake-ts-mode.el (cmake-ts-mode-maybe):
* lisp/progmodes/dockerfile-ts-mode.el (dockerfile-ts-mode-maybe):
* lisp/progmodes/elixir-ts-mode.el (elixir-ts-mode-maybe):
* lisp/progmodes/go-ts-mode.el (go-ts-mode-maybe)
(go-mod-ts-mode-maybe, go-work-ts-mode-maybe):
* lisp/progmodes/heex-ts-mode.el (heex-ts-mode-maybe):
* lisp/progmodes/lua-ts-mode.el (lua-ts-mode-maybe):
* lisp/progmodes/php-ts-mode.el (php-ts-mode-maybe):
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode-maybe):
* lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode-maybe)
(tsx-ts-mode-maybe):
* lisp/textmodes/markdown-ts-mode.el (markdown-ts-mode-maybe):
* lisp/textmodes/yaml-ts-mode.el (yaml-ts-mode-maybe):
Add a wrapper function to 'auto-mode-alist'
for ts-modes that have no corresponding non-ts mode.
Also add a mapping to 'treesit-major-mode-remap-alist'
for the case when a non-ts mode is installed from an external
source to be able to customize it with 'treesit-enabled-modes'.
2025-08-14 19:40:08 +03:00
Michael Albinus
40e4394f87 Fix file notification problem on Windows.
* src/inotify.c (inotify_callback): Set event.frame_or_window to Qnil.

* src/keyboard.c (make_lispy_event): Make a better check for the
HAVE_W32NOTIFY case when creating a Qfile_notify event.
2025-08-12 22:05:44 +02:00
Dr.Sc.KAWAMOTO,Takuji
5b9f4ee76e Fix NS frame position update after resize/move
Fixes bug#74074, bug#79164.

* src/nsterm.m ([EmacsView windowDidEndLiveResize:]):
([EmacsView updateFramePosition]): New functions.
([EmacsView windowDidMove:]): Move contents of this function into
updateFramePosition and call it.

Copyright-paperwork-exempt: yes
2025-08-11 21:54:58 +01:00
Dmitry Gutov
fd5866cae4 ; Coding style fix 2025-08-11 02:33:53 +03:00
Dmitry Gutov
07eb39f113 Allow thread's buffer to be killed, by default
* src/thread.c (Fmake_thread): Add new argument (bug#76969).
(thread_set_error): New function, extracted from thread-signal.
(Fthread_buffer_disposition): Add getter.
(Fthread_set_buffer_disposition): And setter.
(thread_check_current_buffer): Check the values of threads'
buffer_disposition.
(thread_all_before_buffer_killed): New function.
(init_threads): Set buffer_disposition to nil for the main thread.
(syms_of_threads): Add new symbols and define the error.

* src/thread.h (thread_state): New field buffer_disposition.
(thread_all_before_buffer_killed): Declare.

* src/buffer.c (Fkill_buffer): Call thread_check_current_buffer
one more time after all hooks and after that call
thread_all_before_buffer_killed.

* src/comp.c (ABI_VERSION): Increase the value.

* test/src/thread-tests.el (thread-buffer-disposition-t)
(thread-buffer-disposition-nil)
(thread-buffer-disposition-silently)
(thread-set-buffer-disposition)
(thread-set-buffer-disposition-main-thread): New tests.

* doc/lispref/threads.texi (Basic Thread Functions): Document
buffer-disposition in make-thread and its getter and setter.

* etc/NEWS: Add entry.
2025-08-09 22:40:07 +03:00
Eli Zaretskii
9748c13208 ; Fix last change
* src/print.c (print_create_variable_mapping): Add back the wrong
spelling as compatibility measure (bug#75784).
2025-08-09 15:38:13 +03:00
Zach Shaftel
581447cd25 Improve Vprint_variable_mapping
* src/print.c (print_create_variable_mapping): Fix a typo,
`unreadeable-function' to `unreadable-function'. Add `symbols-bare'
as an override for `print-symbols-bare'.  (Bug#79161)
2025-08-09 15:34:51 +03:00