Martin Rudalics [Mon, 27 Jan 2025 09:06:51 +0000 (10:06 +0100)]
In Elisp manual document new functions for changing window layouts
* doc/lispref/windows.texi (Changing Window Layouts): New section
to document the new functions for changing window layouts.
* doc/lispref/elisp.texi (Top): Add entry for new section.
Paul Eggert [Mon, 27 Jan 2025 07:04:21 +0000 (23:04 -0800)]
Pacify -Wanalyzer-use-of-uninitialized-value
With ‘configure --enable-gcc-warnings’,
gcc (GCC) 14.2.1 20250110 (Red Hat 14.2.1-7) on x86-64
complained, as it apparently did not want to assume that enum
variables have one of the listed values.
Work around the problem by using tables rather than
switch statements. This gives up a little static
checking but I don’t see any other easy way to pacify
GCC without disabling the warnings entirely.
* src/pdumper.c (dump_fwd_int, dump_fwd_bool, dump_fwd_obj)
(dump_fwd_buffer_obj, dump_fwd_kboard_obj):
Last arg is now void const * so that these functions’ addresses
can all be put into the same array.
(dump_fwd, dump_anonymous_allocate_posix, dump_map_file_posix):
Use an array rather than a switch.
(mem_prot_posix_table): New static constant table.
Paul Eggert [Mon, 27 Jan 2025 06:15:50 +0000 (22:15 -0800)]
Fix unlikely eassert failure in pgtk_enumerate_devices
* src/pgtkterm.c (pgtk_enumerate_devices): Prefer
make_formatted_string to snprintf + build_string + eassert, as
it’s simpler and won’t crash Emacs if the eassert fails.
Paul Eggert [Mon, 27 Jan 2025 06:15:50 +0000 (22:15 -0800)]
Minor format_string tuneup
* src/comp.c (format_string): Prefer strcpy to doing things by hand
in a place where strcpy is easier to read, generates
more-efficient code, and similar parts of Emacs do strcpy.
Paul Eggert [Mon, 27 Jan 2025 06:15:49 +0000 (22:15 -0800)]
Ignore -fanalyzer-null-argument in pgtkterm.c
* src/pgtkterm.c: Ignore -Wanalyzer-null-dereference.
I don’t have time to look into all the diagnostics,
but the ones I checked seemed to be false alarms with
gcc -std=gnu23 on x86-64, and we are ignoring this
diagnostic in other modules. This is GCC 14.2.1 20250110 (Red Hat 14.2.1-7).
Paul Eggert [Mon, 27 Jan 2025 06:15:49 +0000 (22:15 -0800)]
Protect against GCing of last_mouse_window
* src/window.c (last_mouse_window): New global var. All static
instances removed, and all their uses replaced with this global
var. This fixes a very unlikely bug where last_mouse_window was
GC’ed and a new window created in its place. It also fixes several
places that assumed NIL_IS_ZERO without static_asserting it.
(init_window_once): Initialize the new var.
Paul Eggert [Mon, 27 Jan 2025 06:15:49 +0000 (22:15 -0800)]
Pacify GCC in pgtkselect malloc alignment
* src/pgtkselect.c (pgtk_size_for_format): Remove.
(pgtk_get_window_property): Third arg is now void **, not unsigned
char **. Omit last arg. All callers changed. Simplify
allocation to pacify GCC 14.2.1 complaint about malloc size
mismatching size of array: there’s no need for an extra byte when
converting from ldata to idata.
(selection_data_to_lisp_data): Third arg is now void const *,
not unsigned char const *. All callers changed.
Omit unnecessary casts. Make some locals more local.
Paul Eggert [Mon, 27 Jan 2025 06:15:49 +0000 (22:15 -0800)]
Avoid unlikely int overflow.
* src/pgtkterm.c (pgtk_term_init):
* src/xterm.c (x_term_init):
Use a bool, not an int that keeps incrementing,
to record whether initialization has occurred.
Paul Eggert [Mon, 27 Jan 2025 06:15:49 +0000 (22:15 -0800)]
Prefer make_formatted_string in svg_load_image
* src/image.c (svg_load_image): Prefer make_formatted_string to
snprintf, as this simplifies the code and does not truncate the
resulting string arbitrarily.
Paul Eggert [Mon, 27 Jan 2025 06:15:48 +0000 (22:15 -0800)]
Simplify make_formatted_string API
From a suggestion by Pip Cet.
* src/alloc.c (make_formatted_string): Omit first argument,
to simplify the calling convention. All callers changed.
* src/doprnt.c (doprnt): Also support %u. Update doc.
Paul Eggert [Mon, 27 Jan 2025 06:15:48 +0000 (22:15 -0800)]
Fix unlikely time zone abbreviation bug
* src/timefns.c (Fcurrent_time_zone): Fix double-"-" bug when time
zone name is not known and time zone offset is -3600 or less.
Also, stop assuming that make_formatted_string works with "*"
precisions; this might ease future changes.
Gerd Möllmann [Sun, 26 Jan 2025 10:31:32 +0000 (11:31 +0100)]
Display separators on tty menus with display table entries
* src/xdisp.c (display_tty_menu_separator): Lookup separator char in
standard-display-table, make a string, and display that using
display_string.
* src/xdisp.c (display_tty_menu_separator_char): New function.
(display_tty_menu_separator): Use it.
* lisp/disp-table.el (display-table): Increase from 12 to 18.
(box-double-vertical, box-double-horizontal, box-double-down-right)
(box-double-down-left, box-double-up-right, box-double-up-left): New
symbols for extra slots.
(display-table-slot, set-display-table-slot): Change doc string.
(describe-display-table): Describe new slots.
(standard-display-unicode-special-glyphs): Define new slots.
* src/disptab.h (DISP_TABLE_P): Add enumerators.
(DISP_TABLE_EXTRA_SLOTS): Define based on enum box.
* src/dispnew.c (produce_box_glyphs): Add new enumerators to switch to
make it exhaustive.
* src/xdisp.c (display_tty_menu_separator): Use BOX_DOUBLE_HORIZONTAL
for '=' if present.
* doc/lispref/display.texi: Add documentation.
* etc/NEWS: Mention in NEWS.
Tassilo Horn [Sun, 26 Jan 2025 08:44:59 +0000 (09:44 +0100)]
Use dired--inhibit-auto-revert for fixing bug#71264
The original fix bound auto-revert-mode to nil which had the side-effect
of disabling auto-revert forever in this buffer because
auto-revert-handler removes the buffer from auto-revert-buffer-list when
it's called but auto-revert-mode is nil.
* lisp/dired.el (dired-internal-do-deletions): Bind
dired--inhibit-auto-revert during deletion (bug#71264).
Juri Linkov [Sat, 25 Jan 2025 18:14:15 +0000 (20:14 +0200)]
Add 'treesit-forward-comment' with 'forward-comment-function'
* lisp/treesit.el (treesit-forward-comment): New function.
(treesit-major-mode-setup): Set 'forward-comment-function' to
'treesit-forward-comment' if the 'comment' thing is defined.
* src/syntax.c (forward-comment-function): New variable.
(Fforward_comment): Call the function from 'forward-comment-function'
when it's non-nil (bug#75609).
Mauro Aranda [Sat, 18 Jan 2025 11:25:40 +0000 (08:25 -0300)]
Delete all overlays that belong to an editable-field
* lisp/wid-edit.el (widget-specify-field): Store the end overlay
that we sometimes create for an editable-field widget.
(widget-field-value-delete): Make sure we delete all overlays
that belong to the widget. (Bug#75646)
* test/lisp/wid-edit-tests.el (widget-test-delete-field-overlays): New
test.
python-mode: add 'exit' and 'quit' to the list of block-enders
'exit()' and 'quit()' end the current codeflow, there can't be
any code past it, similarly to 'return', 'continue', etc. So
when calculating indentation for the line next to 'exit()',
'os.exit()', 'os._exit()', 'sys.exit()' and 'quit()', decrease
the indentation level.
* /lisp/progmodes/python.el (python-rx): Add 'exit()', 'os.exit()',
'os._exit()', 'sys.exit()', 'quit' to the list of block-enders.
(Bug#75729)
Maxim Cournoyer [Tue, 21 Jan 2025 02:50:44 +0000 (11:50 +0900)]
lisp: Introduce a `lisp-fill-paragraph-as-displayed' variable.
Starting with Emacs 28, filling strings now happens in a
narrowed scope, and looses the leading indentation and can cause
the string to extend past the fill-column value. Introduce
`lisp-fill-paragraph-as-displayed' as a new variable allowing
opting out of this new behavior in specific scenarios (such as
when using the Scheme major mode, say).
* lisp/emacs-lisp/lisp-mode.el
(lisp-fill-paragraph-as-displayed): New variable.
(lisp-fill-paragraph): Honor it, by avoiding the logic narrow to
strings before applying fill-paragraph.
* test/lisp/emacs-lisp/lisp-mode-tests.el
(lisp-fill-paragraph-respects-fill-column): Test it.
(lisp-fill-paragraph-docstring-boundaries): New test, as a
safeguard to avoid regressions.
Stefan Monnier [Wed, 19 Jun 2024 20:35:56 +0000 (16:35 -0400)]
Reload <pkg>-loaddefs when replacing built-in packages
* lisp/emacs-lisp/package.el (package--reload-previously-loaded):
Add new optional argument to display a specified warning upon
reloading.
(package-activate-1): Always reload libraries when loading built-in
packages. This avoids ELPA versions of built-in packages to be
mixed with the built-in package autoloads.
Daniel Mendler [Sat, 11 Jan 2025 15:36:56 +0000 (16:36 +0100)]
ibuffer: Display column titles in header line
If the option `ibuffer-use-header-line' is set to `title',
display column titles in the header line.
* lisp/ibuffer.el (ibuffer--format-title)
(ibuffer--format-summary): New functions extracted from
`ibuffer-update-title-and-summary'.
(ibuffer-update-title-and-summary): Use them.
(ibuffer-update): Do not always override `header-line-format'.
(ibuffer-use-header-line): Update docstring and option `:type'.
* lisp/ibuf-macs.el (define-ibuffer-sorter): Add "@" to the
interactive specification for clicks on the header line.
* lisp/sqlite-mode.el: (sqlite-mode-list-tables)
(sqlite-mode-list-columns, sqlite--mode--list-data)
(sqlite-mode-delete): Quote identifiers (table and column
names) in the SQL queries. Fixes, e.g., opening databases
which have a table called "values". (Bug#75598)
Gerd Möllmann [Sat, 25 Jan 2025 06:54:56 +0000 (07:54 +0100)]
Multi-tty: selected frame can be a GUI frame
* src/dispnew.c (frame_selected_window_frame): New function.
(is_cursor_obscured): Use it.
(terminal_cursor_magic): Use the frame of the selected window of he root
frame.
(combine_updates_for_frame): Move Android conditional compilation out.
Gerd Möllmann [Sat, 25 Jan 2025 06:33:45 +0000 (07:33 +0100)]
Fix mouse position handling for nested tty child frames
* src/dispnew.c (child_xy): New function.
* src/dispextern.h: Declare it.
* src/term.c (tty_frame_at): Return child-relative (x, y) in output
parameters.
(Ftty_frame_at): Return a list (FRAME CHILD-X CHILD-Y).
(handle_one_term_event): Adapt use of tty_frame_at.
* lisp/xt-mouse.el (xterm-mouse-event): Use new tty-frame-at.
Gerd Möllmann [Sat, 25 Jan 2025 04:33:13 +0000 (05:33 +0100)]
Simplify absolute (x, y) computation on ttys
* src/dispnew.c (root_xy): New function.
(frame_pos_abs): Removed.
(frame_rect_abs, abs_cursor_pos): Use root_xy.
* src/dispextern.h: Declare root_xy.
* src/term.c (mouse_get_xy): Use it.
Stephen Gildea [Fri, 24 Jan 2025 18:12:58 +0000 (10:12 -0800)]
; time-stamp: Rename some internal symbols
* lisp/time-stamp.el: (time-stamp-string-preprocess): Rename 'alt-form'
to 'colon-cnt' because it is now an integer.
* test/lisp/time-stamp-tests.el: Rename 'formatz-generate-tests' to
'define-formatz-tests'.
Gerd Möllmann [Fri, 24 Jan 2025 10:18:54 +0000 (11:18 +0100)]
Disable more redisplay optimizations when child frames are visible
* src/xdisp.c (redisplay_internal): Disable more optimizations
on a tty root frame displaying a child frame.
(try_cursor_movement,(try_window_reusing_current_matrix)
(try_window_id): Don't use on tty root frames displaying a child frame.
Stefan Kangas [Thu, 23 Jan 2025 23:16:08 +0000 (00:16 +0100)]
Don't use negative positions for docstrings
These were used for user-variables (doc starts with a '*'), but we don't
use that convention any more. On my machine, there are no docstrings
starting with a '*' in etc/DOC.
* src/doc.c (Fsnarf_documentation): Never use negative positions.
(get_doc_string): Don't use eabs; position must now be positive, and all
callers are verified to do that.