Michael Albinus [Thu, 30 Jan 2025 07:40:34 +0000 (08:40 +0100)]
Tramp cleanup
* doc/misc/tramp.texi (Predefined connection information):
Mention also "androidsu" as special case of "tmpdir".
(Remote processes): Signals are not delivered to remote direct
async processes. Say, that there are restrictions for transfer of
binary data to remote direct async processes.
Yuan Fu [Thu, 30 Jan 2025 07:20:38 +0000 (23:20 -0800)]
Fix tree-sitter language remapping
* src/treesit.c (resolve_language_symbol): Move forward.
(treesit_ensure_query_compiled): Resolve language remapping
here.
(Ftreesit_parser_list): Don't resolve language remaping here,
because there's no need: parsers now carries the remapped
language.
(Ftreesit_query_compile): Don't resolve language remapping here,
because we resolve language remapping when actually compiling
the query. Also we want the query to carry the unmapped
language.
Gerd Möllmann [Wed, 29 Jan 2025 12:42:40 +0000 (13:42 +0100)]
Further fixes for cursor positioning (bug#75056)
* src/dispnew.c (write_matrix): Don't set the cursor here. Parameter to
set the cursor or not removed.
(combine_updates_for_frame): Call tty_set_cursor here, depending on
whether or not the selected frame is related to the updated frame.
(update_frame_with_menu): Adapt to change of write_matrix.
Gerd Möllmann [Wed, 29 Jan 2025 07:34:43 +0000 (08:34 +0100)]
Replace two macros with functions in dispnew.c (bug#75056)
* src/dispnew.c (WINDOW_TO_FRAME_VPOS, WINDOW_TO_FRAME_VPOS): Macros
removed.
(window_to_frame_vpos, window_to_frame_vpos): Always define, and use
them instead of the removed macros.
Alan Mackenzie [Wed, 29 Jan 2025 18:35:31 +0000 (18:35 +0000)]
CC Mode: Don't propertize parens in macros incorrectly
Parentheses in macros were getting incorrectly propertized with
the '(1) (punctuation) syntax-table text property. This was
due to a typo in the patch "CC Mode: Rationalize and optimize
cache invalidation (1)" from 2024-10-06. Correct this.
* lisp/progmodes/cc-mode.el (c-depropertize-CPP): Move the
first c-clear-syntax-table-with-value-trim-caches invocation
from inside the enclosing `when' form to after it.
João Távora [Wed, 29 Jan 2025 08:37:37 +0000 (08:37 +0000)]
Eglot: don't auto-shutdown when reverting of single managed buffer
When eglot-autoshutdown is t and the only reason we're
considering it is because of a revert (which tears down Eglot's
minor mode as if by killing), detect that situation and
purposedly cancel the shutdown.
João Távora [Wed, 29 Jan 2025 08:33:54 +0000 (08:33 +0000)]
Eglot: in eglot-code-action-indications, make 'margin' interactive
Didn't know it was possible, thanks to Ergus <spacibba@aol.com> for the
tip about binding [left-margin mouse-2] in the keymap.
The technique adopted in 'eglot-mouse-call' possibly still doesn't work
very well if the margin thing we're clicking on is not on the line point
is currently on. But we don't have that problem (yet?) because LSP
action suggestions function mostly on a "at point" basis.
* lisp/progmodes/eglot.el (eglot-code-action-indications): Adjust docstring.
(eglot--mouse-call): Don't go anywhere except in text area.
(eglot-diagnostics-map): Bind eglot-mouse-actions to left-margin.
Juri Linkov [Tue, 28 Jan 2025 19:07:16 +0000 (21:07 +0200)]
Hideshow support for tree-sitter in hs-minor-mode (bug#75609)
* lisp/progmodes/hideshow.el (hs-inside-comment-p-func):
New buffer-local variable.
(hs-hide-block-at-point): Check if 'hs-block-end-regexp' is
a string or a function.
(hs-inside-comment-p): Move body to 'hs-inside-comment-p--default'.
Call 'hs-inside-comment-p-func' if it's a function.
(hs-inside-comment-p--default): New function with body from
'hs-inside-comment-p'.
(hs-hide-all): Don't use 'hs-block-start-regexp' when it's not a string.
(hs-minor-mode): Don't call 'hs-grok-mode-type' when
'hs-inside-comment-p-func' already has a buffer-local value.
* lisp/treesit.el (treesit-hs-block-end)
(treesit-hs-find-block-beginning, treesit-hs-find-next-block)
(treesit-hs-looking-at-block-start-p)
(treesit-hs-inside-comment-p): New functions.
(treesit-major-mode-setup): Set hs-minor-mode buffer-local variables.
Martin Rudalics [Tue, 28 Jan 2025 15:59:45 +0000 (16:59 +0100)]
New variable 'expose-hidden-buffer' (Bug#75828)
* src/frame.c (make_frame): Handle 'expose-hidden-buffer'.
(expose-hidden-buffer): New variable to handle hidden buffers.
* src/buffer.c (Fother_buffer): Mention that it does not return
a hidden buffer.
* lisp/frame.el (make-frame): In doc-string describe handling
of hidden buffers.
* doc/lispref/frames.texi (Creating Frames): Explain handling
of hidden buffers in description of 'make-frame'.
João Távora [Tue, 28 Jan 2025 10:37:41 +0000 (10:37 +0000)]
Eglot: restructure and overhaul documentation
* doc/misc/eglot.texi (Starting Eglot): Tweak.
(Using Eglot): Remove link to 'Eglot Variables'.
(Eglot Features): Rework.
(Eglot and Buffers): Rework.
(Eglot Commands): Rework.
(Customizing Eglot): New chapter.
(Customization Variables): Now contains what 'Eglot Variables'
used to contain.
(Other Variables): New section.
(More Customization): New section.
(...elsewhere...): Apply 'fill-paragraph'.
João Távora [Fri, 24 Jan 2025 22:51:54 +0000 (22:51 +0000)]
Eglot: symbol highlighting now done in eldoc-documentation-functions
Even though highlighting the thing at point isn't really producing
documentation at point, theory and practice have shown that using
eldoc-documentation-functions for this is a feasible way to avoid
reimplementing all the idle timer logic for such functionality.
In fact, we were already using ElDoc for this purpose, but this commit
makes it so the new eglot-highlight-eldoc-function is a first class
citizen in eldoc-documentation-functions, so users can manipulate it if
so desired.
* lisp/progmodes/eglot.el (eglot--managed-mode): Use
eglot-highlight-eldoc-function
(eglot-hover-eldoc-function): Don't mix highlighting with hover.
(eglot-highlight-eldoc-function): Rename and rework from
eglot--highlight-piggyback
Paul Eggert [Tue, 28 Jan 2025 01:13:02 +0000 (17:13 -0800)]
Make vmessage a bit safer
* src/xdisp.c (vmessage): Avoid undefined behavior if
FRAME_MESSAGE_BUF_SIZE (f) is zero, or if doprnt generates output
containing only encoding errors. Although it’s not clear whether
either is possible, it is better to be safe. Also, clarify via a
new local message_bufsize.
Pip Cet [Mon, 27 Jan 2025 21:06:27 +0000 (13:06 -0800)]
Avoid printing NUL characters in 'message' (bug#75900)
* src/xdisp.c (vmessage): Increase buffer size to fit an extra
multibyte character. On buffer overflow, drop the last multibyte
character to determine an accurate byte length.
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)