Commit graph

51011 commits

Author SHA1 Message Date
Eli Zaretskii
3d8f68db3b ; Fix comments and doc strings in some C files
* src/charset.c (Fmap_charset_chars, Fdefine_charset_internal)
(Ffind_charset_region, Ffind_charset_string, Fchar_charset):
* src/chartab.c (UNIPROP_COMPRESSED_FORM_P): Fix commentary and doc
strings.
2026-03-26 19:40:58 +02:00
Eli Zaretskii
887a7ec32d ; * src/xdisp.c (produce_special_glyphs): Fix commentary. 2026-03-26 19:13:15 +02:00
Basil L. Contovounesios
d780007283 Add predicate for initial_terminal
This introduces the predicate frame-initial-p, which uses
struct frame.output_method or struct terminal.type to detect
initial_terminal without relying on its name (bug#80629).
For some prior discussion, see:
https://lists.gnu.org/r/emacs-devel/2019-12/msg00480.html
https://lists.gnu.org/r/emacs-devel/2020-01/msg00120.html

* doc/lispref/frames.texi (Frames): Document frame-initial-p.
(Finding All Frames): Fix grammar.
* etc/NEWS (Lisp Changes in Emacs 31.1): Announce frame-initial-p.
* lisp/desktop.el (desktop--check-dont-save):
* lisp/emacs-lisp/debug.el (debug):
* lisp/frameset.el (frameset-restore):
* lisp/menu-bar.el (menu-bar-update-buffers):
* lisp/xt-mouse.el (turn-on-xterm-mouse-tracking-on-terminal):
Use frame-initial-p instead of checking the "initial_terminal" name.
* lisp/emacs-lisp/byte-opt.el: Mark frame-initial-p as error-free.

* src/pgtkterm.c (pgtk_focus_changed): Use IS_DAEMON in place of
Fdaemonp, thus also accepting a named daemon session.
* src/terminal.c (decode_tty_terminal): Clarify commentary.
(Fframe_initial_p): New function.
(syms_of_terminal): Expose it.
(init_initial_terminal): Update commentary now that
menu-bar-update-buffers uses frame-initial-p (bug#53740).

* test/lisp/xt-mouse-tests.el (with-xterm-mouse-mode): Simulate the
lack of an initial terminal by overriding frame-initial-p now
that turn-on-xterm-mouse-tracking-on-terminal uses it.
* test/src/terminal-tests.el: New file.
2026-03-26 15:19:56 +01:00
Basil L. Contovounesios
dfeaf7fc00 ; Simplify Fframe_id frame decoding.
The subsequent decode_live_frame already checks for nil.
2026-03-26 15:19:56 +01:00
Basil L. Contovounesios
cc4c8e6e9f Simplify some struct frame.output_method checks
* src/lisp.h (inhibit_window_system): Fix typo in commentary.
* src/dispnew.c (Fopen_termscript):
(init_display_interactive) [!HAVE_ANDROID, !MSDOS]:
* src/dosfns.c [MSDOS] (dos_cleanup):
* src/frame.c (frame_inhibit_resize, frame_windows_min_size)
(do_switch_frame, delete_frame):
(make_terminal_frame) [MSDOS]:
(Fmake_terminal_frame) [MSDOS, WINDOWSNT]:
* src/keyboard.c (read_decoded_event_from_main_queue) [!WINDOWSNT]:
(Fcurrent_input_mode):
* src/menu.c (single_menu_item):
* src/msdos.c [MSDOS] (internal_terminal_init):
* src/sysdep.c (init_sys_modes):
* src/term.c: [HAVE_GPM] (Fgpm_mouse_start, Fgpm_mouse_stop):
[MSDOS] (tty_free_frame_resources):
* src/w32xfns.c (get_frame_dc):
* src/xdisp.c (clear_garbaged_frames, hscroll_window_tree)
(redisplay_internal):
* src/xfaces.c (Fdisplay_supports_face_attributes_p)
(realize_default_face, realize_face, realize_tty_face): Use
is_tty_frame, FRAME_INITIAL_P, FRAME_MSDOS_P, FRAME_TERMCAP_P,
FRAME_W32_P, and FRAME_TTY as appropriate instead of open-coding
them (bug#80629).
2026-03-26 15:19:56 +01:00
Eli Zaretskii
70fae75629 Avoid segfaults in 'bidi_mirror_char' during startup
* src/bidi.c (bidi_mirror_char): Make sure 'bidi_mirror_table' is
initialized before accessing it.  (Bug#80668)
2026-03-24 19:09:52 +02:00
Helmut Eller
55bf30e017 Staticpro executing_kbd_macro
* src/macros.c (syms_of_macros): Staticpro executing_kbd_macro.
(executing_kbd_macro): Update comment.
* src/macros.h (executing_kbd_macro): Remove redundant comment.
2026-03-22 15:29:37 +01:00
Basil L. Contovounesios
5f3689d77f Fix no-focus-on-map on X without GTK
* src/xterm.c [!USE_GTK] (x_update_frame_user_time_window): When
replacing _NET_WM_USER_TIME with a new _NET_WM_USER_TIME_WINDOW and
the frame has requested no-focus-on-map, ensure _NET_WM_USER_TIME is
zero also on the new _NET_WM_USER_TIME_WINDOW.
(x_make_frame_visible) [!USE_GTK]: Don't overwrite _NET_WM_USER_TIME
before mapping a frame that has requested no-focus-on-map, and whose
_NET_WM_USER_TIME should thus remain zero (bug#80525).
2026-03-22 12:18:03 +01:00
Helmut Eller
b06a1f85c6 Use signed ints in struct charset_table
* src/charset.h (struct charset_table): Make the slots size and used
signed.
(charset_attributes_getter): Fix spacing.
2026-03-21 18:42:01 +01:00
Helmut Eller
b0d38e2934 * src/charset.c (Fdefine_charset_internal): Fix memory leak. 2026-03-21 18:42:01 +01:00
Helmut Eller
497fd657cd * src/charset.c (shrink_charset_table): Simplify. 2026-03-21 18:42:00 +01:00
Helmut Eller
32f9e21098 Introduce a struct charset_table
The fields of the new struct are what the global variables
charset_table, charset_table_size, charset_table_used, and
charset_attributes_table used to be.  The struct should make it clearer
that those fields must be kept in sync.

* src/charset.h (struct charset_table): New struct.
(charset_attributes_getter): Adjust accordingly.
* src/charset.c (charset_table): Change type to struct charset_table.
(charset_table_size, charset_table_used, charset_attributes_table):
Moved to the struct.
(Fdefine_charset_internal, Ffind_charset_region, Ffind_charset_string)
(shrink_charset_table, syms_of_charset): Adjust to struct charset_table.
* src/pdumper.c (dump_charset, dump_charset_table): Adjust to struct
charset_table.
2026-03-21 18:42:00 +01:00
Helmut Eller
bbb4fc26e7 * src/charset.h (charset_attributes_getter): Add assertion. 2026-03-21 18:42:00 +01:00
Helmut Eller
186af8e934 Remove the charset_table_init array
Determining the best size for a static array seems difficult; so
allocate it dynamically.

* src/charset.c (CHARSET_TABLE_INIT_SIZE): New constant.
(syms_of_charset): Malloc charset_table here.
(charset_table_init): Removed.
(shrink_charset_table): New function.
(Fclear_charset_maps): Call it.
* src/charset.h (charset_table_init): Removed.
(charset_attributes_getter): Add an assertion.
* src/pdumper.c (dump_charset_table): Assert that charset_table_size ==
charset_table_used.
2026-03-21 18:41:20 +01:00
Helmut Eller
96eacb2c09 Move the attribute field of charsets to a separate vector
This simplifies the GC code, as this was the only field in the charset
struct that referenced the GC heap.  Without it, we no longer need to
trace the charset_table.

* src/charset.h (struct charset.attributes): Removed.
(charset_attributes_getter): New helper.
(CHARSET_ATTRIBUTES): Use it.
* src/charset.c (charset_attributes_table): New.
(Fdefine_charset_internal): Place attrs in charset_attributes_table.
(syms_of_charset): Initialize charset_attributes_table.
(mark_charset): Deleted.
* src/pdumper.c (dump_charset): Skip attributes field.
* src/lisp.h (mark_charset): Deleted.
* src/alloc.c (garbage_collect): mark_charset no longer needed.
2026-03-21 18:20:42 +01:00
Eli Zaretskii
531f45551a ; * src/fns.c (internal_equal_cycle) <use-short-answers>: Doc fix. 2026-03-21 10:12:03 +02:00
Stefan Monnier
378cfb8660 (Fmakunbound): Break aliasing, if present (bug#80538)
* src/data.c (Fmakunbound): Break aliasing, if present.
* doc/lispref/variables.texi (Void Variables): Document it.
2026-03-20 17:21:05 -04:00
Eli Zaretskii
ee42c392d2 ; Fix documentation of window-dimension functions
* doc/lispref/windows.texi (Window Sizes):
* src/window.c (Fwindow_body_height, Fwindow_total_height)
(Fwindow_total_width, Fwindow_body_width): Clarify that window
dimensions are returned in canonical columns and lines.
(Bug#80620)
2026-03-19 17:40:31 +02:00
Stéphane Marks
7ae5562bd4 Kick the event loop in NS drag and drop (bug#80592)
Eliminate an annoying event-loop delay after dropping into an
Emacs window.

* src/nsterm.m: ([EmacsView performDragOperation:]): Kick the
event loop after posting the DRAG_N_DROP_EVENT.
2026-03-18 10:34:29 +00:00
Dmitry Gutov
f8696367bc Assign bit gravity to window in Lucid and Motif ports too
* src/widget.c (EmacsFrameRealize): Assign bit_gravity, and use
the value of NorthWestGravity which matches the GTK3 behavior,
and the general intuition that window's contents should move
with its top-left corner.  The result is that the frame is not
blinking during resizing (bug#80369).

* src/xfns.c (x_window) [!USE_X_TOOLKIT]: Change bit_gravity from
StaticGravity to NorthWestGravity as well, to match the others.
2026-03-16 23:55:24 +02:00
Pip Cet
aa90b0fb4a Count characters correctly in 'str_as_multibyte'
* src/character.c (str_as_multibyte): Increment CHARS for each
character produced, not just once.
2026-03-16 16:28:36 +00:00
Basil L. Contovounesios
88600757ae Remove more regex macros from src/conf_post.h
Further to bug#80428, they are no longer used since commit of
2018-08-05 "Simplify regex-emacs code by assuming Emacs".
Suggested by Pip Cet <pipcet@protonmail.com>.

* src/conf_post.h [emacs] (RE_TRANSLATE_TYPE): Remove;
no longer used except under lib-src.
[emacs] (RE_TRANSLATE): Remove; redefined in src/regex-emacs.c.
2026-03-16 14:29:26 +01:00
Stefan Monnier
e2004eb56f Merge remote-tracking branch 'origin/scratch/error-API' 2026-03-15 17:17:21 -04:00
Eli Zaretskii
6c4b9b2cc3 ; * src/fns.c (Fstring_make_multibyte, Fstring_as_unibyte): Doc fixes. 2026-03-15 09:55:23 +02:00
Eli Zaretskii
bb0b9635f9 Avoid segfaults in TTY menu-item selection
* src/term.c (tty_menu_show): Don't allow "selection" of items in
a bogus menu.  (Bug#80603)
2026-03-15 08:40:50 +02:00
Eli Zaretskii
f59181008f Avoid another assertion violation in TTY menus
* src/term.c (tty_menu_show): Reject bogus menus whose 'menu_items'
is nil.  (Bug#80603)
2026-03-14 19:00:31 +02:00
Basil L. Contovounesios
7077633e67 Rename emacs-module.h.in -> emacs-module.in.h
* src/emacs-module.h.in: Rename...
* src/emacs-module.in.h: ...to this, for consistency with all other
lib/*.in.h files (bug#80428).
* Makefile.in (CONFIG_STATUS_FILES_IN):
* admin/release-branch.txt:
* src/emacs-module.c: All uses updated.
* admin/authors.el (authors-renamed-files-alist): Register rename.
* configure.ac: Specify non-default AC_CONFIG_FILES input file.
2026-03-14 15:08:15 +01:00
Basil L. Contovounesios
14c0e69c1d Review some attribute macro usage
* .dir-locals.el (c-noise-macro-names): Remove ANDROID_EXPORT, which
is no longer used.  Add ATTRIBUTE_COLD, ATTRIBUTE_CONST,
ATTRIBUTE_MAY_ALIAS, ATTRIBUTE_NONSTRING, ATTRIBUTE_RETURNS_NONNULL,
EXTERNALLY_VISIBLE, MAYBE_UNUSED, and NODISCARD.
(c-noise-macro-with-parens-names): Also tell cc-mode about some
function-like attribute macros in use (bug#80428).

* src/conf_post.h (RE_TRANSLATE_P): Remove; it is no longer used.
2026-03-14 15:08:15 +01:00
Eli Zaretskii
7887f202c6 Avoid assertion violations in tty menus in rare cases
* src/term.c (mouse_get_xy): Restore the lost protection against
'mouse_position' returning nil as mouse coordinates.  (Bug#80603)
2026-03-14 14:11:49 +02:00
Eli Zaretskii
4a81c87a7c Avoid assertion violations in 'display_menu_bar'
* src/xdisp.c (display_menu_bar): Return immediately if the
menu-bar items were not yet computed.  This avoids assertion
violations when this function is called as part of creating a new
frame.  (Bug#80603)
2026-03-13 15:57:05 +02:00
Basil L. Contovounesios
d1079cced2 Replace remaining uses of Qwrong_type_argument
For discussion, see:
https://lists.gnu.org/r/emacs-devel/2026-03/msg00306.html

* src/comp.c (helper_GET_SYMBOL_WITH_POSITION): Use
symbol-with-pos-p, not wrong-type-argument, in the
wrong-type-argument error predicate slot.
* src/data.c (Fbare_symbol):
* src/print.c (print_bind_overrides):
* src/treesit.c (Ftreesit_parser_create, treesit_resolve_node):
Prefer wrong_type_argument over xsignal2.
2026-03-12 16:41:18 -04:00
Stefan Monnier
9348c19b82 Use single-arg form of signal to re-throw an error
* lisp/vc/smerge-mode.el (smerge-extend):
* lisp/vc/diff-mode.el (diff-beginning-of-file-and-junk):
* lisp/transient.el (transient--with-emergency-exit):
* lisp/textmodes/tex-mode.el (latex-forward-sexp):
* lisp/tar-mode.el (tar-mode):
* lisp/savehist.el (savehist--reload):
* lisp/progmodes/octave.el (inferior-octave-resync-dirs):
* lisp/progmodes/js.el (js--re-search-forward):
* lisp/plstore.el (plstore--decrypt):
* lisp/net/dbus.el (dbus-ignore-errors, dbus-register-signal)
(dbus-handle-event):
* lisp/mouse.el (mouse-drag-track, mouse-drag-region-rectangle):
* lisp/minibuffer.el (completion-pcm--find-all-completions):
* lisp/mail/rfc2231.el (rfc2231-parse-string):
* lisp/mail/rfc2047.el (rfc2047-encode-region):
* lisp/jit-lock.el (jit-lock-fontify-now):
* lisp/international/ja-dic-utl.el (skkdic-lookup-key):
* lisp/gnus/nnselect.el (nnselect-generate-artlist):
* lisp/gnus/mml-sec.el (mml-secure-epg-encrypt, mml-secure-epg-sign):
* lisp/gnus/mail-source.el (mail-source-fetch-pop)
(mail-source-check-pop):
* lisp/gnus/gnus-art.el (gnus-article-read-summary-keys):
* lisp/files.el (basic-save-buffer-2, files--ensure-directory)
(files--force, copy-directory):
* lisp/eshell/esh-io.el (eshell-output-object-to-target):
* lisp/epa.el (epa-decrypt-file, epa-verify-file, epa-sign-file)
(epa-encrypt-file, epa-decrypt-region, epa-verify-region)
(epa-sign-region, epa-encrypt-region, epa-delete-keys)
(epa-export-keys, epa-insert-keys):
* lisp/emacs-lisp/package.el (package--unless-error):
* lisp/emacs-lisp/multisession.el (multisession--read-file-value):
* lisp/emacs-lisp/lisp.el (up-list-default-function):
* lisp/desktop.el (desktop-kill):
* lisp/calendar/time-date.el (date-to-time):
* lisp/calendar/appt.el (appt-display-message):
* lisp/calc/calc.el (calc-do):
* lisp/bookmark.el (bookmark-handle-bookmark):
* src/fileio.c (report_file_errno):
* lisp/vc/vc.el (vc-checkout, vc-pull): Use `(signal err)` instead
of `(signal (car err) (cdr err))`.
2026-03-10 10:48:22 -04:00
Stefan Monnier
a1358530f5 Improve the error API
Define new functions to manipulate error descriptors and
add support for `signal` to *re*signal a previous error.

 * src/eval.c (Fsignal): Make the second arg optional and document
the possibility of passing a whole error descriptor to re-signal it.
(signal_or_quit): Fix a few corner case issues when
DATA is `nil` and ERROR_SYMBOL is an error descriptor.

* lisp/subr.el (error-type-p, error--p, error-type, error-data)
(error-has-type-p, error-slot-value): New function.

* doc/lispref/control.texi (Handling Errors): Prefer "error descriptor"
to "error description".  Use the new single-arg call to `signal` to
re-throw an error.
Document `error-type`, `error-data` and `error-slot-value`.
(Error Symbols): Document the new functions `error-type-p` and
`error-has-type-p`.
2026-03-10 10:48:10 -04:00
Stefan Monnier
ea5f15d096 Fix signal calls where the data argument is not a list
* test/src/thread-tests.el (threads-join-error):
* test/src/emacs-module-resources/mod-test.c (Fmod_test_signal):
* src/print.c (print_bind_overrides):
* lisp/url/url-future.el (url-future-finish, url-future-errored)
(url-future-call, url-future-cancel): Make sure signal's data is a list.

* test/src/emacs-module-tests.el (mod-test-non-local-exit-signal-test):
Adjust accordingly.
2026-03-10 00:13:31 -04:00
Pip Cet
f254b2cc19 Fix infloop when decoding incomplete embedded UTF-8 input
* src/coding.c (decode_coding_iso_2022): Record conversion result for
incomplete data.
2026-03-07 11:36:58 +00:00
Eli Zaretskii
06471a82c8 Fix segfaults in 'kbd_buffer_get_event'
* src/keyboard.c (kbd_buffer_get_event): Ignore selection-request
events when accessing the frame of an event.  Suggested by dick
r. chiang <dick.r.chiang@gmail.com>.  (Bug#80558)
2026-03-07 09:49:22 +02:00
Stéphane Marks
b7aca342e6 ; Move ns_init_colors from Fns_list_colors to emacs.c (bug#80377)
Support calls to ns_lisp_to_color or Fns_list_colors in headless
environments where ns_term_init is not called, and calls before
ns_term_init runs.

* src/emacs.c (main): Call ns_init_colors when not in dump mode.
* src/nsfns.m (ns_init_colors): Make public function.
(Fns_list_colors): Remove ns_init_colors call.
* src/nsterm.h: extern ns_init_colors.
2026-03-07 00:04:21 +00:00
Martin Rudalics
8034e48630 Additional fixes for 'get-mru-frame' (Bug#80397)
* src/frame.c (delete_frame): Call 'get-mru-frame' safely and
with EXCLUDE-FRAME argument set up correctly.
* lisp/frame.el (get-mru-frames, get-mru-frame): Fix doc-strings.
2026-03-06 09:51:21 +01:00
Martin Rudalics
1f30f37df8 Fix segfault introduced by recent 'get-mru-frame' change
* src/frame.c (delete_frame): Fix segfault when deleting a
frame and 'get-mru-frame' returns that frame.
2026-03-05 11:22:55 +01:00
Alan Third
d40e5050be Fix seg fault when image dimensions don't match (bug#80518)
* src/image.c (four_corners_best): [USE_CAIRO] Reset the image
dimensions to real values.
(Fimage_transforms_p): Fix typo.
2026-03-04 19:21:36 +00:00
Mattias Engdegård
dfa4a0e5a2 Faster JSON string serialisation (bug#80529)
* src/json.c (json_out_string):
Optimise for runs of non-special ASCII chars.

This seems to be a a substantial performance gain for long strings but a
smaller regression for short strings (up to 6 chars or thereabouts,
depending on cpu, compiler, and/or C library).  Still likely worth it.

Suggested by Pavel <cyberkm@gmail.com>.
2026-03-03 17:21:16 +01:00
Manuel Giraud
d272dedf8c Add mirroring for special glyphs (bug#80440)
See initial discussion here:
https://lists.gnu.org/archive/html/emacs-devel/2026-02/msg00400.html

* lisp/international/characters.el (pairs): Populate
special-mirror-table.
* src/xdisp.c (produce_special_glyphs): Add two arguments.  One
to identify the paragraph direction and one to identify that the
glyph is produced on the left hand side of a window.  Mirror
glyph defined in the display table according to the new
special-mirror-table.  Bidi mirroring always takes precedence.
(init_iterator, insert_left_trunc_glyphs, display_line)
(display_string): Call 'produce_special_glyphs' with new arguments.
(syms_of_xdisp) <special-mirror-table>: New char-table.
* etc/NEWS: Announce the change.
2026-03-03 16:24:58 +02:00
Sean Whitton
1f9b6223e1 ; Move documentation for multiple-terminals-merge-keyboards. 2026-03-03 11:14:10 +00:00
Eli Zaretskii
f46eaf609e ; * src/w32image.c (w32_gdip_export_frame): Add error checking. 2026-03-02 17:03:17 +02:00
Eli Zaretskii
a755d7fcf0 Teach Emacs on MS-Windows how to export frame screenshots
* src/w32image.c (w32_gdip_export_frame): New function.
(gdiplus_init): Load 'GdipCreateBitmapFromHBITMAP' from GDI+ DLL.
* src/w32fns.c (Fw32_export_frame): New primitive.

* etc/NEWS: Announce the new primitive.
2026-03-01 15:08:51 +02:00
Sean Whitton
d78a1db462 New variable 'multiple-terminals-merge-keyboards'
* src/keyboard.c (syms_of_keyboard):
<multiple_terminals_merge_keyboards>: New variable.
(read_event_from_main_queue): Mention it in message.
* lisp/cus-start.el: Make it customizable.
* src/callint.c (Ffuncall_interactively):
* src/keyboard.c (Frecursive_edit):
* src/minibuf.c (read_minibuf): When its value is true, don't
enter single-kboard mode (bug#79892).
* admin/notes/multi-tty:
* etc/NEWS: Document it.
2026-02-28 20:54:56 +00:00
Paul Eggert
aed1c8b536 Don’t stuff keyboard input uselessly
Also, document stuffing better.
* src/keyboard.c (stuff_buffered_input):
Give up on stuffing if it fails.
* src/sysdep.c (stuff_char): Return failure indication.
2026-02-28 09:09:22 -08:00
Sean Whitton
62ab58972c ; * src/callproc.c (command-line-max-length): Use DEFVAR_INT. 2026-02-28 15:50:10 +00:00
Sean Whitton
342e002c87 Show a message in locked frames in single-kboard mode
* src/keyboard.c (kbd_buffer_get_event): Pass the event's frame
up to the caller by means of a new 'struct frame **' argument.
(read_event_from_main_queue): Show a message in locked frames in
single-kboard mode (bug#79892).
* src/xdisp.c (log_message): Factor out of message3.
(message3): Call it.
(message3_nolog): Rename to ...
(message3_frame_nolog): ... this.  New 'struct frame *' argument
which causes temporarily switching to another frame when
displaying the message.
(message3_frame, message3_nolog): New functions.
* src/lisp.h: Declare message3_frame and message3_frame_nolog.
* admin/notes/multi-tty: Remove notes on showing a message.
2026-02-28 15:34:16 +00:00
Eli Zaretskii
b540c45bc5 Document that string ARG of 'kill-emacs' might not work
* src/emacs.c (Fkill_emacs):
* doc/lispref/os.texi (Killing Emacs): Document that EXIT-DATA
being a string doesn't always work.  (Bug#80435)
2026-02-28 16:10:08 +02:00