Commit graph

12723 commits

Author SHA1 Message Date
Juri Linkov
6f30b9584f Fix tree-sitter ABI version incompatibility in rust-ts-mode
* lisp/progmodes/rust-ts-mode.el (treesit-language-source-alist):
For ABI version 15 add the recommended version "v0.24.0".
2025-04-22 09:49:48 +03:00
João Távora
7ac6b33560 Eglot: use richer diagnostic-making capability of Flymake 1.4.0
* lisp/progmodes/eglot.el (Package-Requires): Require Flymake
1.4.0.
(eglot-handle-notification): Tweak.
2025-04-20 23:20:33 +01:00
João Távora
64f4fbde8a Flymake: bump package version to 1.4.0
* lisp/progmodes/flymake.el (Version): Bump to 1.4.0.

* etc/NEWS: Add entries for recent Flymake improvements.
2025-04-20 23:20:33 +01:00
João Távora
3001d50d9a Flymake: rework, simplify and address problems of recent change (bug#75841)
Various problems were addressed:

- Unbreak Flymake for Emacs 26.3.  Due to use of some Elisp constructs,
  the change completely broke compatibility to Emacs < 29.1.  That
  violated Flymake's status as a :core package as highlighted in its
  description, which has implications for packages depending on it (such
  as Eglot);

- No new two commands are needed (they weren't documented in the manual
  anyway).  The new functionality was integrated in the existing
  flymake-show-buffer-diagnostics;

- Some helper functions aren't needed at all (they weren't marked
  internal anyway);

- The new hook called only when a particular function is called
  non-interactively in a particular way is not useful.  A case for the
  usefulness (if any) of this hook must be made separately.  Such a hook
  should be documented in the manual;

- Added missing recentering after revealing diagnostic in buffer;

- The menu entry "List all problems" was never intended to direct the
  user the user to any particular problem at point;

- The useful new functionality is called out in the manual and NEWS.

* lisp/progmodes/flymake.el (flymake--indicator-overlay-spec):
Use flymake-show-buffer-diagnostics-at-mouse.
(flymake-mode-map): Recover old definition.
(flymake-after-show-buffer-diagnostics-hook): Remove hook.
(flymake-show-buffer-diagnostics): Rework.
(flymake-show-diagnostic, flymake-goto-diagnostic): Rework
docstring.
(flymake-show-buffer-diagnostics-at-event-position)
(flymake-show-buffer-diagnostics-at-event-line): Delete undocumented commands.
(flymake-diagnostics-at-mouse-event)
(flymake-pulse-momentary-highlight-region): Delete non-helpful
helper.

* doc/misc/flymake.texi (listing diagnostics): Mention new
  functionality.
2025-04-20 23:20:33 +01:00
João Távora
77cd3a406b Flymake: address some compatibility problems with older Emacsen
Can't use with-supressed-warnings, introduced in Emacs 27.1.  Also can't
use multi-arg setq-local, probably introduced around the same time.

This commit by itself still doesn't allow Flymake to be loaded in Emacs
< 29.  That fix will come in a later commit.

* lisp/progmodes/flymake.el (flymake--mode-line-counter-map):
Use with-no-warnings.

* lisp/progmodes/flymake.el (flymake--resize-margins): Use setq,
setq-local not needed.
2025-04-20 23:20:33 +01:00
João Távora
53d732d775 Flymake: dynamically resize and layout diagnostic listings
Since 'origin' and 'code' are new separate optional attributes of each
diagnostic, it becomes important to not waste space in these listings
when these are absent.  When a specific column isn't used by any line,
omit it.  Also spare just enough horizontal space to hold the largest
element in each column.

* lisp/progmodes/flymake.el
(flymake--tabulated-setup): New helper.
(flymake-diagnostics-buffer-mode)
(flymake-project-diagnostics-mode): Use flymake--setup-tabulated-listing.
(flymake--fit-diagnostics-window): New helper.
(flymake--tabulated-list-format-base): Rename from
flymake--diagnostics-base-tabulated-list-format.
(flymake--tabulated-setup-1): Rename and rework from
flymake--tabulated-entries-1.
(flymake--diagnostics-buffer-entries): Remove.
(flymake-diagnostics-buffer-mode)
(flymake-project-diagnostics-mode): Simplify.
(flymake--project-diagnostics-entries): Remove.
2025-04-20 23:20:33 +01:00
João Távora
ed1311a62a Flymake: new flymake-diagnostic-format-alist (bug#77439, bug#77480)
* lisp/progmodes/flymake.el (flymake-diagnostic-text): Overhaul.
(flymake-diagnostic-format-alist): New defcustom.
(flymake--diagnostic-format): New util.
(flymake--eol-overlay-summary)
(flymake--highlight-line)
(flymake-eldoc-function): Use flymake--diagnostic-format.
(flymake--tabulated-diagnostic-origin): New helper.
(flymake--tabulated-entries-1): Use flymake--tabulated-diagnostic-origin.
(flymake--diagnostics-base-tabulated-list-format): "Backend" -> "Origin"

* doc/misc/flymake.texi (Customizable variable): Mention new variable.
2025-04-20 23:20:33 +01:00
João Távora
0fe05a920a Flymake: more powerful flymake-make-diagnostic and rework manual
Flymake backends may now explicitly specify an origin and a code for a
diagnostic in addition to the textual description.  This change lays
groundwork for richer diagnostic listings and user options for
summarizing diagnostics, addressing bug#77439 and bug#77480.

* doc/misc/flymake.texi (Flymake API): Rename from "Extending
Flymake".  Rework.
(Inspecting diagnostics): New section.

* lisp/progmodes/flymake.el (flymake--diag): Add origin, code and
message.  Remove text.
(flymake-make-diagnostic): Support new origin, code and message.
(flymake-diagnostic-text): Rework.
2025-04-20 23:20:33 +01:00
Juri Linkov
2585462533 Fix indentation test failure for elixir-ts--indent-rules
* lisp/progmodes/elixir-ts-mode.el (elixir-ts--indent-rules):
Add query for Elixir embedded in Heex (bug#76788).

* lisp/progmodes/heex-ts-mode.el (heex-ts-mode): Append
treesit-simple-indent-rules to elixir-ts--indent-rules.
2025-04-20 20:39:41 +03:00
Vincenzo Pupillo
4428077c2b Fix indentation of "{" on a new line of a function declaration
* lisp/progmodes/js.el (js--treesit-switch-body-helper): New
anchor helper function for the switch_body.
(js--treesit-member-chained-expression-helper): New anchor
helper function for chained calls in member_expression.
(js--treesit-arrow-function-helper): New anchor helper
function for arrow_function.
(js--treesit-indent-rules): Fix rule for the indentation of
"{" when of a new line of a function declaration.  (Bug#76704)
Fix the indentation of the parent of arrow_function, member_expression,
switch_body, ternary_expression and sequence_expression.
2025-04-20 09:14:29 +03:00
Spencer Baugh
cc52c1e1d0 Backport: fix flymake margin indicator fallback logic
Backport 861e7f8b60 to fix bug#77313, so
that fringe indicators are once again reliably the default on frames
that support them.

Do not merge to master.

* lisp/progmodes/flymake.el (flymake-indicator-type)
(flymake-mode): Fix margin fallback behavior.
2025-04-19 17:37:40 +03:00
Michael Albinus
9ea9c5a73e Merge from origin/emacs-30
2a45f0bceb * lisp/progmodes/heex-ts-mode.el (heex-ts): Fix :group name.
9750333dde Fix typescript-ts-mode indentation (bug#77803)
2025-04-19 10:00:04 +02:00
Michael Albinus
2a45f0bceb * lisp/progmodes/heex-ts-mode.el (heex-ts): Fix :group name. 2025-04-19 09:41:58 +02:00
Konstantin Kharlamov
9750333dde
Fix typescript-ts-mode indentation (bug#77803)
Don't align variable names to their declaratory expression.

Before this commit in code like:

    const a = 1,
          b = 2;

the b would get indented to `const'.  Similarly for `var' and
`let'. The expected behavior instead is getting indented to
`typescript-ts-mode-indent-offset'.

* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--indent-rules): Indent identifiers declarations to
`typescript-ts-mode-indent-offset'.
* test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
(Lexical and variable declarations): Update test accordingly.
2025-04-18 16:40:06 -07:00
Juri Linkov
d56e37c83c Embed elixir in heex as well as elixir->heex->elixir (bug#76788).
* lisp/progmodes/elixir-ts-mode.el (elixir-ts--range-rules):
Rename to a shorter name from 'elixir-ts--treesit-range-rules'.
(elixir-ts--font-lock-feature-list, elixir-ts--thing-settings)
(elixir-ts--range-rules): New variables with default values
extracted from 'elixir-ts-mode'.
(elixir-ts-mode): Use 'elixir-ts--font-lock-feature-list',
'elixir-ts--thing-settings', 'elixir-ts--range-rules'
and 'heex-ts--range-rules'.
Use 'treesit-merge-font-lock-feature-list' to merge
'heex-ts--font-lock-feature-list'.

* lisp/progmodes/heex-ts-mode.el
(heex-ts--font-lock-feature-list, heex-ts--range-rules):
New variables.
(heex-ts-mode): Use 'heex-ts--font-lock-feature-list',
'heex-ts--range-rules'.  Merge 'elixir-ts--font-lock-settings',
'elixir-ts--font-lock-feature-list', 'elixir-ts--thing-settings'
for embedding elixir in heex.  Enable the 'sexp' navigation
by default with 'treesit-cycle-sexp-type'.

* lisp/progmodes/c-ts-mode.el (c-ts-mode): Append
'treesit-range-rules' to possibly already existing list in
'treesit-range-settings'.

* lisp/treesit.el (treesit-language-at-point-default):
Optimize to use 'when-let*'.
2025-04-18 19:52:19 +03:00
Juri Linkov
3d3be6dd0e Lock tree-sitter language grammars to verified versions.
* admin/notes/tree-sitter/build-module/build.sh:
Update org for toml/yaml.

* admin/tree-sitter/treesit-admin.el
(treesit-admin--builtin-language-sources):
Add verified versions.

* lisp/progmodes/c-ts-mode.el:
Append language source to treesit-language-source-alist.
(c-ts-mode, c++-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/cmake-ts-mode.el:
Append language source to treesit-language-source-alist.
(cmake-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/csharp-mode.el:
Append language source to treesit-language-source-alist.
(csharp-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/dockerfile-ts-mode.el:
Append language source to treesit-language-source-alist.
(dockerfile-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/elixir-ts-mode.el:
Append language source to treesit-language-source-alist.
(elixir-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/go-ts-mode.el:
Append language source to treesit-language-source-alist.
(go-ts-mode, go-mod-ts-mode, go-work-ts-mode):
Use treesit-ensure-installed.

* lisp/progmodes/heex-ts-mode.el:
Append language source to treesit-language-source-alist.
(heex-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/java-ts-mode.el:
Append language source to treesit-language-source-alist.
(java-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/js.el:
Append language source to treesit-language-source-alist.
(js-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/json-ts-mode.el:
Append language source to treesit-language-source-alist.
(json-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/lua-ts-mode.el:
Append language source to treesit-language-source-alist.
(lua-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/php-ts-mode.el
(php-ts-mode--language-source-alist):
Update versions from comments in ts-modes.
Append to treesit-language-source-alist.
(php-ts-mode-install-parsers):
Use treesit-language-source-alist directly.
(php-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/ruby-ts-mode.el:
Append language source to treesit-language-source-alist.
(ruby-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/rust-ts-mode.el:
Append language source to treesit-language-source-alist.
(rust-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/sh-script.el:
Append language source to treesit-language-source-alist.
(bash-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/typescript-ts-mode.el:
Append language source to treesit-language-source-alist.
(typescript-ts-mode, tsx-ts-mode): Use treesit-ensure-installed.

* lisp/textmodes/css-mode.el:
Append language source to treesit-language-source-alist.
(css-ts-mode): Use treesit-ensure-installed.

* lisp/textmodes/html-ts-mode.el:
Append language source to treesit-language-source-alist.
(html-ts-mode): Use treesit-ensure-installed.

* lisp/textmodes/markdown-ts-mode.el:
Append language source to treesit-language-source-alist.
(markdown-ts-mode): Use treesit-ensure-installed.

* lisp/textmodes/mhtml-ts-mode.el
(mhtml-ts-mode--language-source-alist):
Append to treesit-language-source-alist.
(mhtml-ts-mode-install-parsers):
Use treesit-language-source-alist directly.
(mhtml-ts-mode): Use treesit-ensure-installed.

* lisp/textmodes/toml-ts-mode.el:
Append language source to treesit-language-source-alist.
(toml-ts-mode): Use treesit-ensure-installed.

* lisp/textmodes/yaml-ts-mode.el:
Append language source to treesit-language-source-alist.
(yaml-ts-mode): Use treesit-ensure-installed.

* test/infra/Dockerfile.emba: Add verified versions
to treesit-language-source-alist.
2025-04-18 19:22:50 +03:00
kobarity
4dcd66abd5 Disable echo back instead of setting tty to raw in Inferior Python
* lisp/progmodes/python.el (python-shell-setup-code): Change the
Python setup code.  (Bug#76943)

(cherry picked from commit 4c5c20ddc2)
2025-04-18 14:53:20 +02:00
Yuan Fu
b75c18f3c6
Make sure prog-fill-reindent-defun work for strings too
My previous commit foolishly excluded strings from the
condition, now add them back.

* lisp/progmodes/prog-mode.el (prog-fill-reindent-defun):
Include strings.
2025-04-17 16:18:19 -07:00
kobarity
4c5c20ddc2 Disable echo back instead of setting tty to raw in Inferior Python
* lisp/progmodes/python.el (python-shell-setup-code): Change the
Python setup code.  (Bug#76943)
2025-04-17 14:56:49 +02:00
Yuan Fu
79814379d6
Remove treesit.el dependency from prog-mode.el
prog-mode.el doens't need treesit.el dependency.  And it
shouldn't depend on it.  In principle, treesit.el should
integrate into various parts of Emacs through standard hooks and
variables.

* lisp/progmodes/prog-mode.el:
(prog-fill-reindent-defun): Remove treesit.el functions.  Use
generic functions to check whether the current line has
comments, and make the test more comprehensive.
2025-04-16 22:54:40 -07:00
Yuan Fu
9d43715baa
Fix c-ts-common--fill-paragraph for non-rust modes (bug#77727)
* lisp/progmodes/c-ts-common.el:
(c-ts-common--comment-regexp): Add // and /* to regexp for Rust.
(c-ts-common--line-comment-p): Extract out into new function,
add a check that the parent node is a comment node.
(c-ts-common--fill-paragraph): Extract some code out.
2025-04-16 22:54:17 -07:00
João Távora
c5b97b7b32 Eglot: be aware of LSP version of contextual diagnostics
In certain situations, Eglot has to report to the server parts
of the diagnostics that it itself sent us.  The server may use
this as context to compute code actions, for example.  Eglot
selects diagnostics by asking Flymake, looking for the ones that
contain Eglot-specific cookies.

But when doing so, it is important to also be aware of the LSP
document version these each of these diagnostics pertain to,
since if a diagonstic in the buffer pertains to an older version
of the LSP document (because Flymake fired or the server hasn't
pushed a new set), that diagnostics 'eglot-lsp-data' cookie is
invalid and possibly harmful.

An example is when a diagnostic extends all the way to the end
of the buffer.  If we attempt to fix by shortening the buffer,
an Eldoc-started code actions request may be sent to the server
considering the soon-to-be-deleted Flymake diagnostic as
context.  But that diagnostic's 'eglot-lsp-data' cookie is no
longer valid and when processing that context we try to go past
point-max and burp an annoying error.

Best to check the version of the diagnostic (if we have it) and
ignore the ones that don't match the document version.

* lisp/progmodes/eglot.el (eglot--versioned-identifier): Move up.
(eglot--flymake-diagnostics, eglot--diag-to-lsp-diag): New helpers.
(eglot-handle-notification): Record LSP doc version in diagnostics.
(eglot--code-action-bounds)
(eglot--code-action-params): Use eglot--flymake-diagnostics.
2025-04-17 00:31:38 +01:00
Juri Linkov
a6d746400c Change the default navigation sexp-type in 'elixir-ts-mode'.
* lisp/progmodes/elixir-ts-mode.el (elixir-ts-mode):
Call 'treesit-cycle-sexp-type' at the end to enable navigation across
nodes defined by the tree-sitter thing 'sexp' by default (bug#76788).
2025-04-16 20:32:54 +03:00
Juri Linkov
7574eb82c5 New hook 'outline-after-change-functions' (bug#77256).
* lisp/outline.el (outline-after-change-functions): New variable.
(outline--fix-buttons-after-change):
Run hook 'outline-after-change-functions'.

* lisp/treesit.el (treesit--after-change): Improve docstring.
(treesit-major-mode-setup): Simplify to just add
'treesit--after-change' to 'outline-after-change-functions' hook.

* lisp/progmodes/rust-ts-mode.el (rust-ts-mode): Add explicit
'treesit-outline-predicate' that is like
'treesit-simple-imenu-settings', but also adds "trait_item".
2025-04-16 20:11:34 +03:00
Elías Gabriel Pérez
74842b4cb2 Add block-comment variables to cc-mode.
* lisp/progmodes/cc-cmds.el (c-indent-new-comment-line):
Add block-comment-start and block-comment-end
* lisp/progmodes/cc-mode.el (c-basic-common-init):
Declare block-comment-start and block-comment-end buffer-local.
* lisp/emacs-lisp/lisp-mode.el (lisp-mode-variables): Move
block-comment variables ...
(lisp-mode): ... to here.  (Bug#77424)
2025-04-15 16:16:34 +03:00
Eli Zaretskii
f5b59a8a73 ; Fix last change
* lisp/progmodes/elisp-mode.el (elisp-eldoc-docstring-length-limit):
* etc/NEWS: Fix documentation of last change.  (Bug#77628)
2025-04-13 13:03:03 +03:00
Elías Gabriel Pérez
53bd9f54c6 Add variable for control docstring length in elisp eldoc functions
* etc/NEWS: Announce new variable.
* lisp/progmodes/elisp-mode.el (elisp-eldoc-docstring-length-limit):
New user option.
(elisp-eldoc-funcall-with-docstring): Add "Undocumented" as
docstring if the function has no docstring.
(elisp-eldoc-var-docstring-with-value): Use
`elisp-eldoc-docstring-length-limit'.  (Bug#77628)
2025-04-13 13:02:41 +03:00
Eli Zaretskii
d9ad0c953b ; Fix a typo in last change. 2025-04-13 11:13:36 +03:00
Elías Gabriel Pérez
4c6b1712a4 Add block-comment-start and block-comment-end to supported modes
* lisp/emacs-lisp/lisp-mode.el (lisp-mode-variables):
Add block-comment-start and block-comment-end from here...
* lisp/newcomment.el (block-comment-start, block-comment-end):...
* lisp/nxml/nxml-mode.el (nxml-mode):...
* lisp/progmodes/c-ts-common.el (c-ts-common-comment-setup):...
* lisp/progmodes/go-ts-mode.el (go-work-ts-mode):...
* lisp/progmodes/js.el (js--mode-setup):...
* lisp/progmodes/json-ts-mode.el (json-ts-mode):...
* lisp/progmodes/lua-ts-mode.el (lua-ts-mode):...
* lisp/progmodes/opascal.el (opascal-mode):...
* lisp/progmodes/pascal.el (pascal-mode):...
* lisp/progmodes/typescript-ts-mode.el (tsx-ts-mode):...
* lisp/textmodes/css-mode.el (css-base-mode, scss-mode):...
* lisp/textmodes/sgml-mode.el (sgml-mode): ... to here.
(Bug#77424)
2025-04-13 11:12:59 +03:00
Spencer Baugh
861e7f8b60 flymake: fall back to margins on text terminals
Previously, flymake-indicator-type defaulted to either fringes
or margins.  But fringes should be used on graphical frames, and
margins on TTY frames.  So default to fringes instead, and
simply fall back to margins automatically on text frames.

* lisp/progmodes/flymake.el (flymake-indicator-type): Set to
fringes.  (bug#77313)
(flymake-mode): Fallback to margins if there's no fringes.
* doc/misc/flymake.texi (Customizable variables): Mention
fallback behavior.
* etc/NEWS: Announce fallback behavior.
2025-04-12 14:10:19 +03:00
Juri Linkov
ec62674cb9 Fix treesit-forward-sexp/list navigation in the middle of a node.
* lisp/treesit.el (treesit--forward-list-with-default):
Check the thing 'sexp-default' (bug#76791).

* lisp/progmodes/elixir-ts-mode.el (elixir-ts-mode):
* lisp/progmodes/go-ts-mode.el (go-ts-mode):
* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode):
* lisp/progmodes/sh-script.el (bash-ts-mode):
Add the thing 'sexp-default' to 'treesit-thing-settings'.
2025-04-10 19:20:35 +03:00
Juri Linkov
99a2cb05a4 New command 'treesit-toggle-sexp-mode' (bug#76676).
* lisp/treesit.el (treesit-forward-sexp): Don't use
'treesit-sexp-type-regexp' reserved for list commands
to override their default 'list' thing.
(treesit-down-list, treesit-up-list): Use
'treesit-sexp-type-regexp' instead of 'list'
when it's non-nil.
(treesit-toggle-sexp-mode): New command.

* lisp/progmodes/c-ts-mode.el (c-ts-mode--thing-settings):
Improve 'sexp' thing settings to exclude the top-level
"translation_unit" that just moves to EOF and also "comment".

* lisp/progmodes/elixir-ts-mode.el (elixir-ts--sexp-regexp): Remove.
(elixir-ts--forward-sexp): Remove to use the default 'sexp' navigation.
(elixir-ts--with-parens-0-p, elixir-ts--with-parens-1-p):
New internal functions.
(elixir-ts-mode): Add 'treesit-thing-settings'
instead of 'forward-sexp-function' (bug#76788).

* lisp/progmodes/heex-ts-mode.el (heex-ts--sexp-regexp): Remove.
(heex-ts--forward-sexp): Remove to use the default 'sexp' navigation.
(heex-ts--thing-settings): New variable.
(heex-ts-mode): Use 'heex-ts--thing-settings'
instead of 'forward-sexp-function'.

* lisp/progmodes/java-ts-mode.el (java-ts-mode):
Improve 'sexp' thing to use settings like in c-ts-mode.

* lisp/progmodes/php-ts-mode.el (php-ts-mode):
Improve 'sexp' thing settings to exclude the top-level
"program" that just moves to EOF and also "comment".

* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode):
Improve 'sexp' thing to use settings like in c-ts-mode.

* lisp/textmodes/css-mode.el (css--treesit-thing-settings):
Add 'sexp' thing.  Add "string_value" to 'text' thing.

* lisp/textmodes/html-ts-mode.el (html-ts-mode--treesit-things-settings):
Improve 'sexp' thing to use settings like in c-ts-mode.
Add "doctype" to the 'list' thing.
2025-04-09 21:21:53 +03:00
Juri Linkov
fa247a24a5 Improve 'treesit-outline-search'.
* lisp/treesit.el (treesit-outline-search): Remove
temporary arg 'recursive'.  Use iteration to visit
more ranges until the next outline heading is found.

* lisp/progmodes/php-ts-mode.el (php-ts-mode):
Set 'treesit-outline-predicate' explicitly.
2025-04-09 20:40:09 +03:00
João Távora
3e22c73fb6 Eglot: announce support for diagnostic version checks (bug#77588)
* lisp/progmodes/eglot.el (eglot-client-capabilities): Mention versionSupport.
2025-04-08 22:16:27 +01:00
Juri Linkov
5e0daa1ef7 New function treesit-parsers-at for treesit-language-at (bug#77256).
* doc/lispref/parsing.texi (Multiple Languages): The variable
'treesit-language-at-point-function' is now optional for
multi-language major modes.  Add description of 'treesit-parsers-at'.

* lisp/treesit.el (treesit-language-at-point-function):
Change the the docstring to remove the dissuasion against
deriving the language from parser ranges.
(treesit-language-at): Use the first parser from
'treesit-parsers-at' as the default return value when
'treesit-language-at-point-function' is nil.  Adapt the docstring.
(treesit-node-at): Use 'treesit-parsers-at'.
(treesit-parsers-at): New function.
(treesit-local-parsers-at): Use 'treesit-parsers-at'
with the most part of the body moved to it.
(treesit-local-parsers-on): Replace the overlay property
'treesit-parser' with 'treesit-parser-local-p' in the docstring.
(treesit-up-list, treesit-simple-imenu, treesit-outline-level):
Use 'treesit-parsers-at'.

* lisp/progmodes/c-ts-mode.el (c-ts-mode): Don't set
'treesit-language-at-point-function'.

* lisp/progmodes/elixir-ts-mode.el (elixir-ts--treesit-language-at-point):
Remove.
(elixir-ts-mode): Don't set 'treesit-language-at-point-function'.

* lisp/progmodes/js.el (js--treesit-language-at-point): Remove.
(js-ts-mode): Don't set 'treesit-language-at-point-function'.

* lisp/progmodes/php-ts-mode.el (php-ts-mode--html-language-at-point)
(php-ts-mode--language-at-point): Remove.
(php-ts-mode): Don't set 'treesit-language-at-point-function'.

* lisp/textmodes/mhtml-ts-mode.el (mhtml-ts-mode--language-at-point):
Remove.
(mhtml-ts-mode): Don't set 'treesit-language-at-point-function'.
Use 'treesit-language-at' for mode-line lighter.
2025-04-08 20:40:10 +03:00
Eli Zaretskii
646ccd5e67 Fix prettify-symbols-mode with composition rules
* lisp/progmodes/prog-mode.el
(prettify-symbols--composition-displayable-p): Fix a thinko.
Patch by Visuwesh <visuweshm@gmail.com>.  (Bug#77627)
2025-04-08 19:04:41 +03:00
João Távora
13f439ce98 Eglot: check textDocument/publishDiagnostics version (bug#77588)
* lisp/progmodes/eglot.el (eglot--versioned-identifier): Move up.
(eglot-handle-notification textDocument/publishDiagnostics): Check
eglot--versioned-identifier
2025-04-08 08:46:17 +01:00
Eli Zaretskii
684adc07c2 ; Fix a recent backport
* lisp/progmodes/typescript-ts-mode.el
(treesit-node-child-by-field-name, treesit-node-match-p)
(treesit-node-type): Declare.  Do not merge to master.
2025-04-05 15:09:20 +03:00
Paul Nelson
2d0b5f34a0 Restrict symbol prettification to displayable glyphs
* lisp/international/mule.el (char-displayable-on-frame-p): New
function used to determine whether a character can be
meaningfully displayed on a given frame.
* doc/lispref/display.texi (Fontsets): Document it.
* lisp/progmodes/prog-mode.el
(prettify-symbols--composition-displayable-p): New function used
to restrict to displayable prettification symbols.  This
prevents issues with missing characters appearing as boxes.
(prettify-symbols--make-keywords): Use it.  (Bug#77381)
2025-04-05 12:24:50 +03:00
Elías Gabriel Pérez
8fc18d0968 Optionally display function docstring in eldoc
Allow display (optionally) function docstring in eldoc. (Bug#77124)
* etc/NEWS: Document changes.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-funcall-with-docstring-length): New user option.
(elisp-eldoc-funcall-with-docstring): New function.
2025-04-05 12:08:20 +03:00
Stefan Monnier
cd41247dc1 perl-mode.el: Avoid obsolete font-lock face vars
* lisp/progmodes/perl-mode.el (perl-mode-abbrev-table): Merge defvar
into the definition.
(perl-font-lock-keywords-1, perl-font-lock-keywords-2): Avoid obsolete
font-lock face vars.
2025-04-04 23:53:10 -04:00
Paul Nelson
67c89a675d Add repeat-map for Python indentation commands
* lisp/progmodes/python.el (python-indent-repeat-map): New
keymap for repeating Python indentation commands when using
'repeat-mode' (bug#77417).
2025-04-04 09:42:43 +03:00
Yuan Fu
9869aa1a10
Tighten the criteria for a defun in typescript-ts-mode (bug#77369)
* lisp/progmodes/typescript-ts-mode.el:
(typescript-ts-mode--defun-type-regexp): New
variable (backported from master).
(typescript-ts-mode--defun-predicate): New function.
(typescript-ts-base-mode): Use new predicate.
2025-04-03 16:51:26 -07:00
Visuwesh
839ef39a5e Fix C-x p p for remote directories with no Tramp connection
* lisp/progmodes/project.el (project-switch-project): Allow
Tramp to establish a new connection for remote directories.
(Bug#77425)
2025-04-04 02:19:45 +03:00
Elías Gabriel Pérez
da6da5744b Add 'project-customize-dirlocals'
* etc/NEWS: Add command entry.
* lisp/menu-bar.el (menu-bar-project-menu): Add command entry to
project menu.
* lisp/progmodes/project.el (project-customize-dirlocals):
New command.  (Bug#77229)
2025-04-01 22:36:03 +03:00
Michael Albinus
faa3fbe010 Merge from origin/emacs-30
e6b4c0bceb lisp/emacs-lisp/cl-macs.el (cl-labels): Fix docstring (bu...
7a976d1aaf Fix minor issues in documentation of `use-package'
99ff59bd66 PHP should be in the PATH, either locally or remotely. (b...
26873d5028 Avoid warning when loading 'go-ts-mode'
a702f29a00 ; Fix package-version values
a1fbc51dc7 ; * lisp/which-key.el (which-key-idle-delay): Fix package...

# Conflicts:
#	lisp/progmodes/php-ts-mode.el
#	lisp/which-key.el
2025-03-30 16:17:00 +02:00
Yuan Fu
651418895d
Tighten the criteria for a defun in typescript-ts-mode (bug#77369)
* lisp/progmodes/typescript-ts-mode.el:
(typescript-ts-mode--defun-predicate): New function.
(typescript-ts-base-mode): Use new predicate.
2025-03-29 21:18:24 -07:00
Stefan Monnier
1d07a6d7e3 Use replace-region-contents to replace insert+delete
* lisp/minibuffer.el (completion--replace):
* lisp/emacs-lisp/cl-lib.el (cl--set-buffer-substring):
* lisp/subr.el (replace-string-in-region):
Use `replace-region-contents` instead of insert+delete.

* lisp/help-fns.el (help-fns--signature):
Use `replace-region-contents` instead of `cl--set-buffer-substring`.

* lisp/language/japan-util.el (japanese-replace-region):
Rewrite using `replace-region-contents` and mark obsolete.
(japanese-katakana-region, japanese-hankaku-region):
Use `replace-region-contents` instead.

* lisp/progmodes/flymake-proc.el (flymake-proc--replace-region):
Rewrite using `replace-region-contents` and mark obsolete.
(flymake-proc--check-patch-master-file-buffer):
Use `replace-region-contents` instead.
2025-03-29 17:49:49 -04:00
Stefan Monnier
468c2aebae Replace uses of replace-buffer-contents
* lisp/vc/vc.el (vc-diff-restore-buffer):
* lisp/progmodes/python.el (python--do-isort):
* lisp/progmodes/eglot.el (eglot--apply-text-edits):
* lisp/files.el (revert-buffer-insert-file-contents-delicately):
* lisp/json.el (json-pretty-print): Use `replace-region-contents`.
2025-03-29 17:49:49 -04:00
Vincenzo Pupillo
99ff59bd66 PHP should be in the PATH, either locally or remotely. (bug#76242).
* lisp/progmodes/php-ts-mode.el
(php-ts-mode-php-default-executable): Renamed from
'php-ts-mode-php-executable'.
(php-ts-mode--executable): New function that returns the absolute
filename of the PHP executable, local or remote, based on
'default-directory'.
(php-ts-mode--anchor-prev-sibling): Replaced 'when-let' with
“when-let*.”
(php-ts-mode--indent-defun): Replaced 'when-let' with
'when-let*'.
(php-ts-mode-run-php-webserver): Use the new function
(php-ts-mode-php-default-executable).
(run-php): Use the new function (php-ts-mode-php-default-executable).
2025-03-29 14:32:31 +03:00