Commit graph

176481 commits

Author SHA1 Message Date
Gerd Möllmann
782be196e5 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.
2025-01-30 05:41:12 +01:00
Gerd Möllmann
7aacefba6b 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.
2025-01-30 05:41:12 +01:00
Gerd Möllmann
6cf479931d Don't use selected frame in tty_set_cursor (bug#75056)
* src/dispnew.c (tty_set_cursor): Add frmae parameter.
(write_matrix): Pass to the updated frame to tty_set_cursor.
2025-01-30 05:41:12 +01:00
Alan Mackenzie
b34c069d82 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.
2025-01-29 18:35:31 +00:00
Juri Linkov
6a92f674fe Fix args in treesit-beginning-of-defun and treesit-end-of-defun
* lisp/treesit.el (treesit-beginning-of-defun): Set arg to 1 when nil.
(treesit-end-of-defun): Fix arg names in docstring.
2025-01-29 19:58:10 +02:00
Basil L. Contovounesios
25c254aa41
; Remove duplicate defvar in comp-run.el.
* lisp/emacs-lisp/comp-run.el (comp-async-compilations): Remove
duplicate definition (bug#75925).
2025-01-29 18:13:41 +01:00
Eli Zaretskii
cb62a47896 ; Fix Cygw32 build 2025-01-29 17:55:58 +02:00
João Távora
142fe5ace4 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.

* lisp/progmodes/eglot.el (eglot--managed-mode): Tweak.
2025-01-29 08:59:07 +00:00
João Távora
e2ff77052d 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.
2025-01-29 08:56:02 +00:00
Juri Linkov
2e3b085d44 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.
2025-01-28 21:07:16 +02:00
Juri Linkov
cd6aed5c9e * lisp/treesit.el: Use default display behavior for treesit-explore.
(treesit-explorer-switch-parser, treesit-explore):
Revert to previous behavior (bug#75079).
2025-01-28 20:49:52 +02:00
Martin Rudalics
af033548aa Fix two more drawings in windows.texi
* doc/lispref/windows.texi (Changing Window Layouts): Fix two more
drawings.
2025-01-28 18:46:31 +01:00
Eli Zaretskii
8c4a4b4eab ; Fix last change
* src/buffer.c (Fother_buffer):
* lisp/frame.el (make-frame):
* doc/lispref/frames.texi (Creating Frames): Fix em-dash.
2025-01-28 18:18:24 +02:00
Martin Rudalics
7f01dd8906 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'.
2025-01-28 16:59:45 +01:00
Bastien Guerry
c400ac680f ; * admin/MAINTAINERS: Remove Bastien Guerry. 2025-01-28 14:25:22 +01:00
João Távora
b4e9115f4f Eglot: allow customizing the mode line (bug#71823)
* lisp/progmodes/eglot.el (eglot-code-action-indications): Adjust docstring.
(eglot--mode-line-props): Tweak.
(eglot--mode-line-format): Delete.
(eglot-mode-line-format): New defcustom.
(eglot-mode-line-menu, eglot-mode-line-session)
(eglot-mode-line-error, eglot-mode-line-pending-requests)
(eglot-mode-line-progress, eglot-mode-line-action-suggestion): New
constants.
(mode-line-misc-info): Adjust setting

* etc/EGLOT-NEWS: Mention new feature.

* doc/misc/eglot.texi (Customization Variables): Mention new variable.
2025-01-28 11:04:21 +00:00
João Távora
d6a502fc7a Eglot: suggest code actions at point
* lisp/progmodes/eglot.el (eglot-code-action-indicator-face): New face.
(eglot-code-action-indications, eglot-code-action-indicator): New defcustoms.
(eglot--highlights): Move up here.
(eglot--managed-mode): Rework.
(eglot--server-menu-map, eglot--main-menu-map): Extract maps into
variables (avoids odd mode-line bug).
(eglot--mode-line-format): Rework.
(eglot--code-action-params): New helper.
(eglot-code-actions): Rework.
(eglot--read-execute-code-action): Tweak.
(eglot-code-action-suggestion): New function.

* etc/EGLOT-NEWS: Mention new feature.

* doc/misc/eglot.texi (Eglot Features): Mention new feature.
(Customization Variables): Mention new variables.
2025-01-28 11:04:21 +00:00
João Távora
7f0ef9655c Eglot: introduce eglot-advertise-cancellation
Setting this variable to true causes Eglot to send special
cancellation notification for certain stale client request.

This may help some LSP servers avoid doing costly but ultimately useless
work on behalf of the client, improving overall performance.

Request cancellation is described in

   https://microsoft.github.io/language-server-protocol/
      specifications/lsp/3.17/specification/#cancelRequest

* lisp/jsonrpc.el (jsonrpc-request): Accept function as value for
CANCEL-ON-INPUT.

* lisp/progmodes/eglot.el (eglot--request): Rework.

* doc/misc/eglot.texi (Customizing Eglot): Mention
eglot-advertise-cancellation.
2025-01-28 11:04:21 +00:00
João Távora
9e4b626f7e 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'.
2025-01-28 11:04:19 +00:00
João Távora
60166a419f 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
2025-01-28 11:00:47 +00:00
Martin Rudalics
33827bed04 Fix previous commit for Changing Window Layouts
* doc/lispref/windows.texi (Changing Window Layouts): Remove wrong
example.  Change some indentations.
2025-01-28 10:00:50 +01:00
Gerd Möllmann
d60198d7a4 Fix frame-visible-p for tty root frames
* src/frame.c (Fframe_visible_p): Don't unconditionally return t for tty
root frames.
2025-01-28 04:39:59 +01:00
Paul Eggert
1f1088188e Avoid some make_formatted_string mallocs
* src/alloc.c (make_formatted_string):
Grow the local buffer from 64 to MAX_ALLOCA bytes.
2025-01-27 17:16:44 -08:00
Paul Eggert
8e7588a267 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.
2025-01-27 17:16:44 -08:00
Pip Cet
8812f526cf 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.
2025-01-27 17:16:43 -08:00
Pip Cet
0ed913cf46 Fix buffer overflows in doprnt (bug#75900)
* src/doprnt.c (doprnt): Clear rest of buffer on multibyte overflow.
Always decrement bufsize when writing a byte.
2025-01-27 17:16:43 -08:00
Paul Eggert
9b2e230c06 doprnt %X support
* src/doprnt.c (doprnt): Also support %X, since callers
now use %X.
2025-01-27 17:16:43 -08:00
Stefan Kangas
ba60fa3dea Don't use obsolete face variables in lisp-mode.el
* lisp/emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-1)
(lisp-cl-font-lock-keywords-1, lisp-el-font-lock-keywords-2)
(lisp-cl-font-lock-keywords-2): Don't use obsolete face variables.
2025-01-27 22:48:53 +01:00
Stephen Gildea
29c6dad78d time-stamp: Don't get confused by newline in file name
* lisp/time-stamp.el (time-stamp-filtered-buffer-file-name): New helper
* test/lisp/time-stamp-tests.el: (time-stamp-custom-file-name): New test
2025-01-27 10:46:56 -08:00
Stephen Gildea
2d386fc449 time-stamp-tests: Make macro-defined tests findable
* test/lisp/time-stamp-tests.el (define-formatz-tests): Use
'find-function-update-type-alist' to make defined tests findable.
(formatz-find-test-def-function): New test-finding function.
2025-01-27 10:42:35 -08:00
jared
5eae7f5227 Fix clicking in child frames with GPM
* src/term.c (handle_one_term_event): Store child frame
coordinates in event.
2025-01-27 14:09:51 +02:00
Gerd Möllmann
59050c3e8c ; Fix workaround for xt-mouse-tests
* lisp/xt-mouse.el (xterm-mouse-event): For running this in batch mode,
fix computation of x and y.
2025-01-27 10:21:08 +01:00
Martin Rudalics
827dfe5a72 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.
2025-01-27 10:06:51 +01:00
Stefan Kangas
d2ffa0fa48 ; Fix byte-compilation warnings 2025-01-27 09:19:39 +01:00
Paul Eggert
1ed769a3cb 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.
2025-01-26 23:05:55 -08:00
Paul Eggert
a5c47258ff Fix unlikely eassert failure in invalid_radix_integer
* src/lread.c (invalid_radix_integer):
Simplify by using sprintf with a big-enough buffer.
2025-01-26 23:05:55 -08:00
Paul Eggert
f809302fe5 Fix unlikely eassert failure in xg_set_widget_bg
* src/gtkutil.c (xg_set_widget_bg): Simplify by using
sprintf with a big-enough buffer.
2025-01-26 23:05:55 -08:00
Paul Eggert
901659bb70 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.
2025-01-26 23:05:54 -08:00
Paul Eggert
f8b8dddce9 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.
2025-01-26 23:05:54 -08:00
Paul Eggert
8d8272d02e 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).
2025-01-26 23:05:54 -08:00
Paul Eggert
728c7904fe Pacify -fanalyzer-null-argument on pgtk_term_init
* src/pgtkterm.c (pgtk_term_init): Use xstrdup, not g_strdup.
The value is never freed so the allocator shouldn’t matter.
2025-01-26 23:05:53 -08:00
Paul Eggert
2e8ef09104 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.
2025-01-26 23:05:53 -08:00
Paul Eggert
ff65cc9944 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.
2025-01-26 23:05:53 -08:00
Paul Eggert
c0d83876f1 Avoid undefined behavior with botched pgtk menu
* src/pgtkmenu.c (pgtk_menu_show): Do not dereference save_wv if
null.  Problem found by gcc 20250110 (Red Hat 14.2.1-7)
-Wanalyzer-null-dereference.
2025-01-26 23:05:53 -08:00
Paul Eggert
06fd3f4e98 Use gtk_disable_setlocale
* src/pgtkterm.c (pgtk_term_init):
* src/xterm.c (x_term_init):
Use gtk_disable_setlocale rather than fixup_locale.
2025-01-26 23:05:52 -08:00
Paul Eggert
a1e4f6a35c 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.
2025-01-26 23:05:52 -08:00
Paul Eggert
6ff06ff738 Beware large stack growth in pgtk_menu_show
* src/pgtkmenu.c (pgtk_menu_show): USE_SAFE_ALLOCA instead of alloca.
Problem found with --enable-gcc-warnings.
2025-01-26 23:05:52 -08:00
Paul Eggert
17a8bf53f3 Fix x-show-tip bignum crash
* src/pgtkfns.c (compute_tip_xy): Fix crash if user specifies
bignums.  Bug found with --enable-gcc-warnings.
2025-01-26 23:05:51 -08:00
Paul Eggert
c50e8c2424 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.
2025-01-26 23:05:51 -08:00
Paul Eggert
028fae9661 Simplify building of color names in image.c
* src/image.c (make_color_name): New function.
(image_background, image_build_heuristic_mask, png_load_body): Use it.
2025-01-26 23:05:51 -08:00