Commit graph

12723 commits

Author SHA1 Message Date
Jostein Kjønigsen
7265be09ce sh-script.el: Improve consistency in variable-use fontification.
sh-mode--treesit-settings: Ensure all variable use is treated the
same way.
Before this patch the following commands would all be treated differently:

    echo "${var}"
    echo "$var"
    echo ${var}
    echo $var

Now they are treated the same.
* lisp/progmodes/sh-script.el (sh-mode--treesit-settings): Tweak
rules.  (Bug#78167)
2025-05-10 13:21:32 +03:00
João Távora
7617c7a6e4 Eglot: fix navigation in eglot-hierarchy-mode (bug#78250)
* lisp/progmodes/eglot.el (eglot--hierarchy-label):  Take PARENT-URI. Rework.
(eglot--hierarchy-2): Rework.
2025-05-08 23:13:28 +01:00
João Távora
64eb60bd91 Flymake: tweak 'fancy' eol diagnostic display
When calculating the face for boxdraw chars, protect against
diagnostics with an empty first line.  Also don't inherit from
:default, which seems to mess up the background color when using
hl-line-mode.

* lisp/progmodes/flymake.el (flymake--eol-draw-fancy): Tweak
2025-05-08 23:13:28 +01:00
James Cherti
4e1fe56e31 Mark !%:.^~, as punctuation rather than symbol constituents
In Bash, the characters !%:.^~, are not valid in variable names. In sh,
they are not permitted in either function or variable names. Treating
them as punctuation is convenient, as they are rarely used in function
names and never in variable names. Even among commands, their usage is
uncommon. The only character among these that is commonly seen in
command names is '.', although it is rarely used in function names.

Marking these characters as punctuation, rather than symbol
constituents, enhances the accuracy of symbol detection.

* lisp/progmodes/sh-script.el: Mark !%:.^~, as punctuation in the
  sh-mode-syntax-table syntax table.

Copyright-paperwork-exempt: yes
2025-05-07 15:04:07 -04:00
Elijah Gabe Pérez
852d50ecfc Eglot: bind mouse-1 to margin and mode-line code actions
* lisp/progmodes/eglot.el (eglot-mode-line-action-suggestion):
advertise mouse-1.
(eglot-diagnostics-map): Bind left-margin mouse-1
(eglot-code-action-suggestion): Advertise mouse 1.  Simplify.

Co-authored-by: João Távora <joaotavora@gmail.com>
2025-05-06 10:58:52 +01:00
Jostein Kjønigsen
9261d353cc Fix test-regressions in python-ts-mode
* lisp/progmodes/python.el (python--treesit-settings): Use more
specific selectors for constants.

* test/lisp/progmodes/python-tests.el
(python-ts-mode-nested-types-face-1)
(python-ts-mode-union-types-face-1)
(python-ts-mode-union-types-face-2): None is now a constant.
2025-05-05 09:45:36 +02:00
Juri Linkov
815dea7b59 Avoid duplication in defining tree-sitter grammar sources.
* lisp/progmodes/php-ts-mode.el: Require 'html-ts-mode'.
(php-ts-mode--language-source-alist): Remove duplicate source info
for html, css, javascript, jsdoc.
(php-ts-mode-install-parsers): Install pre-defined grammars.
(php-ts-mode): Move 'require' to the top.

* lisp/textmodes/mhtml-ts-mode.el
(mhtml-ts-mode--language-source-alist): Remove variable
since 'treesit-language-source-alist' is pre-filled by
requiring 'html-ts-mode', 'css-mode', 'js'.
(mhtml-ts-mode-install-parsers): Install pre-defined grammars.

* test/infra/Dockerfile.emba: Remove 'mhtml-ts-mode'
that doesn't define own grammars.
2025-05-04 20:50:40 +03:00
João Távora
660ebdddf6 Eglot: allow other keys in window/logMessage (bug#77948)
* lisp/progmodes/eglot.el (eglot-handle-notification window/logMessage): Fix.
2025-05-04 08:27:43 +01:00
Matthew Tromp
ee8b4eaca1 Add `next-error' support for flymake diagnostics buffers
This adds `next-error' support for flymake diagnostics buffers.
Buffers created with `flymake-show-buffer-diagnostics' and
`flymake-show-project-diagnostics' are now next-error enabled,
and `next-error' and `previous-error' will navigate through
their listed diagnostics.
* lisp/progmodes/flymake.el (flymake-current-diagnostic-line)
(flymake--diagnostics-next-error): Add.
(flymake-show-diagnostic, flymake-show-buffer-diagnostics)
(flymake-show-project-diagnostics): Set next-error-last-buffer.
(flymake--tabulated-setup): Set next-error-function.
(Bug#77809)

Copyright-paperwork-exempt: yes
2025-05-03 11:51:11 +03:00
Eli Zaretskii
3f8f738d1d ; * lisp/progmodes/cc-fonts.el (cl-delete-duplicates): Declare. 2025-05-02 08:59:14 +03:00
Juri Linkov
cd557d6f64 Improve elixir-ts--thing-settings.
* lisp/progmodes/elixir-ts-mode.el (elixir-ts--thing-settings):
Add extra grouping "keywords" to named sexp nodes.
Add "," to anonymous sexp nodes.  Use bos/eos.

* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode):
Use bos/eos for anonymous sexp nodes for better disambiguation.

* test/lisp/progmodes/heex-ts-mode-tests.el
(heex-ts-mode-test-indentation): Skip the test when 'elixir' is
missing since 'heex-ts-mode' depends on the 'elixir' grammar.
2025-05-01 21:03:34 +03:00
Juri Linkov
5684a38086 Avoid adding duplicate items to 'treesit-language-source-alist'.
* lisp/textmodes/mhtml-ts-mode.el:
* lisp/progmodes/php-ts-mode.el:
Use 'add-to-list' on items in language-source-alist
that should check for duplicate items.

* test/infra/Dockerfile.emba: Move multi-language mhtml-ts-mode and
php-ts-mode to the end to give their dependent grammars a lower priority.

* test/lisp/progmodes/js-tests.el (js-ts-mode-test-indentation):
Skip the test when 'jsdoc' is missing since 'js-ts-mode' depends
on the 'jsdoc' grammar.
2025-05-01 20:55:33 +03:00
Alan Mackenzie
8ddb8b0e45 Implement C23 features:
Improve the handling of #error and #warning in C and C++ Modes.

* lisp/progmodes/cc-engine.el (c-looking-at-c++-attribute)
(c-enclosing-c++-attribute, c-forward-sws, c-backward-sws):
Handle attributes in C as they have been handled in C++.
(c-forward-align-clause-throw-if-invalid): New macro.
(c-forward-type): Handle alignas, alignof, and _BitInt, putting
a catch block around most of the function to catch invalid uses
of these new keywords.
(c-in-id-arglist): New function.
(c-forward-decl-or-cast-1): Recognize a "maybe" type identifier
as a type in arglists when there is no parameter identifier
associated with it.

* lisp/progmodes/cc-fonts.el (c-font-lock-cpp-messages): New
function.
(c-cpp-matchers): Move the handling of "invalid" comment
delimiters outside of the block handling CPP directives.
Remove the inline handling of #error and #warning, using the
new function c-font-lock-cpp-messages instead.
(c-get-fontification-context): Handle alignof, alignas,
_BitInt.
(c-font-lock-declarations): Adapt fontification of K&R
parameters to the C23 nameless parameter scheme.

* lisp/progmodes/cc-langs.el (c-has-quoted-numbers)
(c-stmt-boundary-skip-chars)
(c-recognize-post-brace-list-type-p, c-modifier-kwds)
(c-constant-kwds): Handle C the same as the existing C++
handling.
(c-cpp-message-directives-re, noncontinued-line-end)
(c-cpp-messages-re, c-cpp-message-match-no): New
c-lang-consts/vars.
(c-cpp-include-directives): New directive embed.
(c-cpp-expr-directives): New directives elifdef, elifndef.
(c-primitive-type-kwds): New types, _Decimal*, bool, char*_t,
nullptr_t.
(c-typeof-kwds): New keyword typeof_unqual.
(c-type-with-paren-kwds, c-type-with-paren-key): New
c-lang-const/vars.
(c-type-modifier-with-parens-kwds)
(c-type-modifier-with-parens-key, c-type-internal-paren-kwds)
(c-type-internal-paren-key): New c-lang-const/vars.
(c-type-modifier-prefix-kwds, c-type-start-kwds): Amend with
the above new c-lang-consts.
(c-no-type-with-equals-kwds, c-no-type-with-equals-key): New
c-lang-const/vars.
(c-modifier-kwds): Add constexpr, auto, and thread_local to the
C value.
(c-paren-nontype-kwds): Add static_assert to the C value.
(c-constant-kwds): Add nullptr to the C value.
(c-regular-keywords-regexp): Include c-type-with-paren-kwds.
(c-recognize-nameless-type-decls): New c-lang-const/var.

* lisp/progmodes/cc-mode.el (c-leave-cc-mode-mode): Also clear
c-digit-separator properties.
2025-05-01 16:12:18 +00:00
Jostein Kjønigsen
b9632a9049
Fix compilation-mode matches for csharp-mode (bug#78128)
* lisp/progmodes/csharp-mode.el:
(csharp-compilation-re-dotnet-error):
(csharp-compilation-re-dotnet-warning): Ignore leading whitespace.
2025-05-01 00:54:33 -07:00
Jostein Kjønigsen
2964d51c9c
Improve python-ts-mode fontification (bug#78129)
Fontification based on selectors & code-conventions:

- Lambda parameters: variable declarations
- For in statements: variable declarations
- Import statements: variable declerations
- Constants: All upper case alphanumerical identifiers
- Types: CamelCase alphanumerical identifiers
- Enums: Enum-values as constants.

* lisp/progmodes/python.el:
(python--treesit-settings): Improve queries.
2025-05-01 00:54:33 -07:00
Jostein Kjønigsen
6c35ae0827
Improve csharp-ts-mode fontification (bug#78130)
Improves:
- fontification of generic types with namespace-prefixes
- function-call parameters
- variable use in string interpolation
- implicitly typed parameters in lambda-expressions
- index-expressions
- variables used in return-statements
- variables used in binary expressions

* lisp/progmodes/csharp-mode.el:
(csharp-ts-mode--font-lock-settings): Improve queries.
2025-05-01 00:54:32 -07:00
Jostein Kjønigsen
ebeaa728b6
Fix compilation-mode matches for csharp-mode (bug#78128)
* lisp/progmodes/csharp-mode.el:
(csharp-compilation-re-dotnet-error):
(csharp-compilation-re-dotnet-warning): Ignore leading whitespace.
2025-05-01 00:50:05 -07:00
João Távora
dd5ae0f3ba Eglot: tweak previous change (clear Flymake 'Wait' state)
When we don't have anything to give to Flymake, we still want to
signal we're alive so the mode-line doesn't show a confusing
'Wait'.

* lisp/progmodes/eglot.el (eglot--report-to-flymake): Clear 'Wait'
state.
2025-04-30 22:45:44 +01:00
Alan Mackenzie
766adfa8a7 Fix typo in bug#19867 correction (CC Mode indentation bugs)
* lisp/progmodes/cc-align.el (c-lineup-item-after-paren-at-boi):
Replace an erroneous skip-syntax-backward with
skip-chars-backward.
2025-04-30 18:51:37 +00:00
Juri Linkov
b06046edcf Fix the match data in elisp-outline-search.
* lisp/progmodes/elisp-mode.el (elisp-outline-search):
Add 'save-match-data' since 'syntax-ppss' garbles the match data.
2025-04-30 20:34:52 +03:00
Juri Linkov
dbd1688237 Add python tree-sitter grammar data to 'treesit-language-source-alist'.
* lisp/progmodes/python.el (python-ts-mode):
Use 'treesit-ensure-installed' when it's fboundp.
2025-04-30 20:28:05 +03:00
Sean Whitton
606e7b73ba cperl-mode-map: Don't bind C-j
* lisp/progmodes/cperl-mode.el (cperl-mode-map): Don't bind C-j.
The default global mode bindings will DTRT depending on whether
or not electric-indent-mode is on.
2025-04-30 17:28:22 +08:00
Robert Pluim
9b560a54c3 Fix custom type of 'flymake-show-diagnostics-at-end-of-line'
*
lisp/progmodes/flymake.el (flymake-show-diagnostics-at-end-of-line):
Add 'fancy' value to custom type.

* etc/NEWS: "variable" -> "user option".

(Bug#78148)
2025-04-30 10:52:28 +02:00
Juri Linkov
746a3cb314 Ignore parens in strings for outline headings in emacs-lisp-mode.
* lisp/outline.el (outline-font-lock-keywords): For non-nil
outline-search-function return a lambda that calls the function,
then sets the match data to the end of the line that is equivalent
to adding ".*" in the regexp.  Then search functions don't need to
match ".*" themselves.

* lisp/progmodes/elisp-mode.el (elisp-outline-search):
New function to skip leading parens in strings when searching
for outline headings.
(emacs-lisp-mode): Set buffer-local 'outline-search-function' to
'elisp-outline-search'.
https://lists.gnu.org/archive/html/emacs-devel/2025-04/msg00934.html
2025-04-29 19:55:48 +03:00
João Távora
825ea052ad Flymake: promptly delete eol overlay if source overlay changed
In the vast majority of cases, changing the source overlay
invalidates the content of the end-of-line overlay, so best to
delete it asap.

* lisp/progmodes/flymake.el (flymake--delete-overlay): Use
'flymake--eol-ov'
(flymake--highlight-line): Use some overlay modification hooks.
2025-04-29 12:39:52 +01:00
João Távora
7ae275f04c Eglot: improve diagnostic-reporting performance
After a change in the buffer has occured, it is often the case
that Flymake is quicker to ask for diagnostics than the server
is to supply them to us.  If we're still stuck with old outdated
diagnostics, don't forward them to Flymake, even if it eagerly
asks us for them.

* etc/EGLOT-NEWS (Changes in upcoming Eglot): Announce changes.

* lisp/progmodes/eglot.el
(eglot--diagnostics): Rework.
(eglot--report-to-flymake): Also take version.
(eglot-handle-notification textDocument/publishDiagnostics)
(eglot--managed-mode)
(eglot-flymake-backend): Tweak call to eglot--report-to-flymake.
2025-04-29 12:23:06 +01:00
Po Lu
8970c9589b * lisp/progmodes/grep.el (grep-hello-file): Fix another typo. 2025-04-29 12:54:50 +08:00
Po Lu
ac40a65f75 * lisp/progmodes/grep.el (grep-hello-file): Fix typos. 2025-04-29 12:54:32 +08:00
Po Lu
3279194bf2 Port Grep argument autodetection to Android
* lisp/progmodes/grep.el (grep-hello-file): On Android, copy
sample text to a real directory.
2025-04-29 08:28:19 +08:00
Sean Whitton
c0491a8b80 ; project-vc-include-unregistered: Add FIXME about renaming. 2025-04-28 10:46:48 +08:00
Tim Landscheidt
4765a3b3f2 Fix ruby lint output regexps
* doc/misc/flymake.texi (An annotated example backend):
Fix regexp.

* lisp/progmodes/ruby-mode.el (ruby-flymake-simple)
(ruby-flymake-rubocop): Fix regexp
(https://lists.gnu.org/archive/html/emacs-devel/2025-04/msg00851.html).
2025-04-28 03:05:41 +03:00
João Távora
0262e3e158 Flymake: Experimental 'fancy' flymake-show-diagnostics-at-end-of-line
* doc/misc/flymake.texi (Customizable variables): Describe new
flymake-show-diagnostics-at-end-of-line.

* etc/NEWS: Mention 'flymake-show-diagnostics-at-end-of-line'.

* lisp/progmodes/flymake.el
(flymake-show-diagnostics-at-end-of-line): Update docstring.

* lisp/progmodes/flymake.el (flymake--eol-overlay-summary):
Rework.  Move to separate section.
(flymake--update-eol-overlays): Rework.  Use 'display'.  Move to
separate section.
(flymake--eol-draw-fancy-1, flymake--eol-draw-fancy): New helpers.
(flymake-end-of-line-diagnostics-face): Remove box.
2025-04-27 13:03:19 +01:00
Jostein Kjønigsen
67e8351bdb csharp-mode.el: Improve fontification of string-interpolation exprs
* lisp/progmodes/csharp-mode.el
(csharp-ts-mode--font-lock-settings): Remove too wide selector,
causing non-string content to be fonitified as strings.  Add
additional eselectors to highlight variables inside
interpolation-expressions too.  (Bug#78008)
2025-04-26 16:25:11 +03:00
Paul Nelson
f808f637f5 Add "forward history" support for some debuggers
* lisp/progmodes/gud.el (gud-query-cmdline): Add an optional
default-list parameter to allow passing a list of "forward
history" suggestions to the minibuffer.
(perldb, pdb, guiler): Use buffer file name to suggest a default
debugging command via "forward history".

* doc/emacs/building.texi (Starting GUD): Document the new
feature.

(Bug#77989)
2025-04-26 16:21:21 +03:00
Paul Nelson
dd3429526a Don't consider "Grep finished" lines as matches for file names
* lisp/progmodes/grep.el
(grep-compilation-transform-finished-rules): New variable
containing rules to prevent "Grep finished" lines from being
misinterpreted as matches for file names.
(grep-mode): Add these rules to
'compilation-transform-file-match-alist' (bug#77732).
2025-04-26 15:34:54 +03:00
Liu Hui
46776cae05 Fix filename completion in Python shell (bug#77853)
'comint-filename-completion' may complete the filename at
wrong locations.  Users who want proper filename completion
should use specialized completion backends (e.g. Jedi).
* lisp/progmodes/python.el (inferior-python-mode): Remove
'comint-filename-completion' in 'comint-dynamic-complete-functions'.
2025-04-26 14:59:48 +03:00
kobarity
9ae82726d8 Add cache to Python block navigation functions
* lisp/progmodes/python.el (python-nav-cache)
(python-nav-cache-tick): New variables.
(python-nav-cache-get, python-nav-cache-set)
(python-nav-with-cache): New functions.
(python-nav-beginning-of-block, python-nav-end-of-block): New
wrapper functions.
(python-nav--beginning-of-block): Renamed from
'python-nav-beginning-of-block'.
(python-nav--end-of-block): Renamed from
'python-nav-end-of-block'.  (Bug#77620)
2025-04-26 14:20:31 +03:00
kobarity
d753c88494 Performance optimization of 'python-info-statement-ends-block-p'
* lisp/progmodes/python.el (python-info-statement-ends-block-p):
Add a comparison of the indentation of the next statement with
the indentation of the current statement.  (Bug#77620)
2025-04-26 14:19:17 +03:00
kobarity
55cf15e163 Fix Python block end predicates (bug#77941)
* lisp/progmodes/python.el (python-info-statement-ends-block-p)
(python-info-end-of-block-p): Add consideration of comments.
* test/lisp/progmodes/python-tests.el
(python-info-statement-ends-block-p-3)
(python-info-end-of-block-p-3): New tests.
2025-04-26 14:17:31 +03:00
Sean Whitton
bacde21fde ; typescript-ts-mode-multivar-indent-style: Add missing group. 2025-04-26 11:47:23 +08:00
Sean Whitton
94d8f5b94f ; typescript-ts-mode-multivar-indent-style: Use different example.
This prevents it becoming a hyperlink in *Help* buffers.
2025-04-26 11:46:18 +08:00
Sean Whitton
5a043bf3df ; typescript-ts-mode-multivar-indent-style: Fix use of apostrophes. 2025-04-26 11:43:49 +08:00
Yuan Fu
3393644b71
Add multivar indent style in typescript-ts-mode (bug#77803)
* lisp/progmodes/typescript-ts-mode.el:
(typescript-ts-mode-multivar-indent-style): New option.
(typescript-ts-mode--indent-rules): Support both styles.
2025-04-25 17:39:55 -07:00
Eli Zaretskii
eb6531ba94 Allow to disable 'lexical-binding'
* lisp/progmodes/elisp-mode.el (elisp-enable-lexical-binding):
Optionally, allow to disable 'lexical-binding'.
2025-04-24 15:56:23 +03:00
João Távora
01f97fabfe Eglot: require bug-fixed Flymake 1.4.1 (bug#77856)
* lisp/progmodes/eglot.el (Package-Requires) Require Flymake 1.4.1.
2025-04-23 08:35:30 +01:00
João Távora
79cef45a12 Flymake: more concise flymake--tabulated-list-format-base
* lisp/progmodes/flymake.el (flymake--tabulated-list-format-base): Tweak
2025-04-23 08:35:30 +01:00
João Távora
a25fc9a518 Flymake: fix flymake-make-diagnostic for numeric code (bug#77856)
* lisp/progmodes/flymake.el (flymake-make-diagnostic): Tighten up
type requirements.
(Version): Bump to 1.4.1
2025-04-23 08:35:30 +01:00
Juri Linkov
add8bf000a Replace some 'treesit-query-compile' with 'treesit-query-valid-p'.
* admin/tree-sitter/treesit-admin.el
(treesit-admin--verify-major-mode-queries)
(treesit-admin--validate-mode-lang):
* lisp/progmodes/csharp-mode.el
(csharp-ts-mode--test-this-expression)
(csharp-ts-mode--test-interpolated-string-text)
(csharp-ts-mode--test-string-content)
(csharp-ts-mode--test-type-constraint)
(csharp-ts-mode--test-type-of-expression)
(csharp-ts-mode--test-typeof-expression)
(csharp-ts-mode--test-name-equals)
(csharp-ts-mode--test-if-directive)
(csharp-ts-mode--test-method-declaration-type-field):
* lisp/progmodes/php-ts-mode.el
(php-ts-mode--test-namespace-name-as-prefix-p)
(php-ts-mode--test-namespace-aliasing-clause-p)
(php-ts-mode--test-namespace-use-group-clause-p)
(php-ts-mode--test-visibility-modifier-operation-clause-p)
(php-ts-mode--test-property-hook-clause-p):
* lisp/progmodes/typescript-ts-mode.el
(tsx-ts-mode--font-lock-compatibility-bb1f97b):
Use the newer equivalent 'treesit-query-valid-p'
instead of 'treesit-query-compile' with 'ignore-errors'.
2025-04-22 21:01:28 +03:00
Juri Linkov
8fb45fcaed Fix all issues for the case when tree-sitter is disabled.
* lisp/treesit.el (treesit-declare-unavailable-functions):
Declare 'treesit-language-abi-version' and 'treesit-library-abi-version'.

* lisp/progmodes/elixir-ts-mode.el (elixir-ts--range-rules):
* lisp/progmodes/heex-ts-mode.el (heex-ts--range-rules):
* lisp/progmodes/rust-ts-mode.el (treesit-language-source-alist):
Guard with 'treesit-available-p'.
2025-04-22 19:32:36 +03:00
Sean Whitton
4808f785cc Revert addition of electric-block-comment-mode & follow-up commits
As presently under discussion in bug#77823, the intended new
functionality is not really about comments at all.
Remove it for now to allow us to redesign from a clean slate,
and to deal with the regression reported in bug#77823.

This reverts the following three changesets:

Author:     Elías Gabriel Pérez <eg642616@gmail.com>
AuthorDate: Mon Mar 17 12:56:52 2025 -0600

  New minor mode: `electric-block-comment-mode'

Author:     Elías Gabriel Pérez <eg642616@gmail.com>
AuthorDate: Mon Mar 31 17:58:16 2025 -0600

  Add block-comment-start and block-comment-end to supported modes

Author:     Elías Gabriel Pérez <eg642616@gmail.com>
AuthorDate: Sun Apr 13 12:26:08 2025 -0600

  Add block-comment variables to cc-mode
2025-04-22 20:47:56 +08:00