Commit graph

13099 commits

Author SHA1 Message Date
Steven Allen
27af6bfdfb Fix arguments to project--buffer-check when reading a project buffer
* lisp/progmodes/project.el (project--read-project-buffer): Pass the
buffer object to `project--buffer-check', not the (BUF-NAME . BUF-OBJ)
cons.
2026-02-23 15:21:56 +00:00
Stefan Monnier
3a2a095dff Fix broken FOO-mode-indent-offset convention
Variable names to control indentation have never been
standardized, but over the years some conventions have naturally
arisen, mostly the use of `FOO-indent-offset`,
`FOO-basic-offset`, or `FOO-indent-level` for `FOO-mode`.

When the new TS modes were introduced, a mistake was made that
I failed to catch at the time, where those modes used
`FOO-mode-indent-offset` instead of the "standard" `FOO-indent-offset`.
In order to save packages like `editorconfig-mode` and `indent-bars-mode`
from having to cater to yet-another-convention, rename those
vars to what they should have been all along.

* lisp/editorconfig.el (editorconfig-indentation-alist): Remove the
ad-hoc entries for the deviating modes using `FOO-mode-indent-offset`.

* lisp/textmodes/toml-ts-mode.el (toml-ts-indent-offset):
* lisp/textmodes/mhtml-ts-mode.el (mhtml-ts-js-css-indent-offset)
(mhtml-ts--js-css-indent-offset):
* lisp/textmodes/html-ts-mode.el (html-ts-indent-offset):
* lisp/progmodes/typescript-ts-mode.el (typescript-ts-indent-offset):
* lisp/progmodes/php-ts-mode.el (php-ts-indent-offset)
(php-ts-js-css-indent-offset, php-ts-html-indent-offset):
* lisp/progmodes/json-ts-mode.el (json-ts-indent-offset):
* lisp/progmodes/java-ts-mode.el (java-ts-indent-offset)
(java-ts-method-chaining-indent-offset):
* lisp/progmodes/go-ts-mode.el (go-ts-indent-offset):
* lisp/progmodes/csharp-mode.el (csharp-ts-indent-offset):
* lisp/progmodes/cmake-ts-mode.el (cmake-ts-indent-offset):
* lisp/progmodes/c-ts-mode.el (c-ts-indent-offset):
Rename `FOO-mode-indent-offset` to `FOO-indent-offset`,
with obsolete alias.
2026-02-22 18:48:57 -05:00
Basil L. Contovounesios
d01a33662c Improve m4-mode font lock
Emacs 28 started fontifying several 'composite' (non-builtin) GNU M4
macros which, while listed under '(m4) Macro index', are not defined
by GNU M4, and are included in its manual for illustrative purposes.

These macro keywords range from clearly misleading (e.g., 'example',
which the GNU M4 manual explicitly describes as nonexistent),
to common in Autoconf's M4sugar layer (e.g., 'm4_quote'),
to variations thereof (e.g., 'foreachq').

It is arguably too late to revert all of these additions, so this
patch selects a handful to remove, and categorizes the rest; this
should make it easier to hide some categories behind a font lock
level or user option in the future, if desired.

This patch reverts the Emacs 28 addition of 'example', and removes
the older 'file', 'line', and 'gnu' macros.  GNU M4 renamed 'gnu' to
'__gnu__' already in 1990; and I couldn't find references to the
other two which exist as '__file__' and '__line__', respectively.

The remaining macros are partitioned into three sets: built-in,
M4sugar-like, and other (bug#80412).  For discussion, see also:
https://lists.gnu.org/r/emacs-devel/2025-10/msg00357.html

* lisp/progmodes/m4-mode.el (m4-program-options): Remove stale
commentary.
(m4--macro-list): Remove, replacing with...
(m4--builtin, m4--autoconf, m4--composite): ...these new rx
definitions.  All uses changed.  Remove 'example', 'file', 'gnu',
and 'line' as keywords.
(m4-font-lock-keywords): For consistency with real #-comments,
fontify dnl macro with font-lock-comment-delimiter-face, and only
the rest of its line with font-lock-comment-face.  Fontify argument
references with font-lock-variable-use-face rather than
font-lock-variable-name-face.  Use font lock faces rather than their
eponymous but obsolete variables.  Remove redundant entries for $@
and $*.  Prefer shy regexp groups where applicable.
(m4-mode-syntax-table): Quote syntactically special characters.
(m4-m4-buffer): DRY using m4-m4-region.
(m4-m4-region): Take region bounds as optional arguments, as
recommended under '(elisp) The Mark'.  Quote shell command.
Support non-contiguous regions.
(m4-current-defun-name): Recognize m4 backtick in addition to
Autoconf bracket.  Prefer shy regexp groups where applicable.
(m4-mode): Simplify font-lock-defaults.

* test/lisp/progmodes/m4-mode-resources/font-lock.m4:
* test/lisp/progmodes/m4-mode-tests.el: New test files.
2026-02-22 17:10:17 +01:00
Liu Hui
f2b99c4c0b Use a custom Pdb class in the Python shell
The custom Pdb class enables native completion in pdb by
wrapping the pdb's native completer.  It also makes necessary
function definitions like __PYTHON_EL_* available between pdb
frames, and enables non-native completion/ffap/eldoc
functionalities when debugging inside python modules.

* lisp/progmodes/python.el (python-shell-send-setup-code): Fix
the separator between python-shell-setup-codes.
(python-shell-completion-native-setup): Move common completion
setup code ...
(python-shell-completion-setup-code): ... here.
(python-shell-completion-at-point): Enable native completion for
pdb and respect the delimiter of pdb completer.
(python-shell-pdb-setup-code): New variable.
(python-shell-comint-watch-for-first-prompt-output-filter): Send
setup codes only once.
(python-ffap-module-path, python-eldoc--get-doc-at-point): Stop
sending setup code in every function call.
* test/lisp/progmodes/python-tests.el (python-tests--pdb-1)
(python-shell-pdb-1): New test.
* etc/NEWS: Mention the change.  (bug#80182)
2026-02-21 16:51:28 +02:00
Basil L. Contovounesios
027a33f81b Use git ls-files --deduplicate in project.el (bug#80409)
* lisp/progmodes/project.el (vc-git-project-list-files): Prefer
git ls-files --deduplicate, available since Git 2.31 (2021), over
delete-consecutive-dups.  Prefer string-prefix-p and string-suffix-p
over slower and more error-prone regexp matching.  Prefer
string-match-p over string-match when either will do.
2026-02-20 02:12:22 +02:00
kobarity
71d7ea23db Remove (featurep 'project) guards in python.el
* lisp/progmodes/python.el: Since they are included in emacs 29.1,
remove the Package-Requires for seq, project, and flymake.
(require 'project): Remove 'noerror argument.
(python-shell-get-process-name): Remove (featurep 'project).
Use 'project-name'.
(run-python)
(python--import-sources): Remove (featurep 'project).  (Bug#80405)
2026-02-19 19:36:52 +02:00
Dmitry Gutov
988e898749 project--delete-zombie-projects: Bind tramp-error-show-message-timeout to nil
* lisp/progmodes/project.el (project--delete-zombie-projects):
Bind tramp-error-show-message-timeout to nil, to instruct Tramp
not to display the "failed to connect" and its message, hiding the
current prompt (bug#80340).
2026-02-17 03:48:22 +02:00
Heinz Fridolin
e2bf7ce8b6 project.el: Fix in submodules with nonexistent git root (bug#80402)
project-try-vc--search in a submodule directory tries to find the git
root directory, so the local variable root would be set to nil if it
didn't exist. Calling project--vc-merge-submodules-p on nil would lead
to a crash, so now the while loop aborts beforehand.
2026-02-15 18:23:51 +02:00
Vili Aapro
9a5eafa8c3 elisp--highlight-function-argument: Handle special syntax correctly
* lisp/progmodes/elisp-mode.el
(elisp--highlight-function-argument): Handle special usage
syntax correctly when scanning usage arguments using
'forward-sexp' (bug#8432).  Before binding 'origin', skip over
blanks, so as not to highlight them, and to move immediately
before any possible opening square brackets.  After binding
'origin' and before calling 'forward-sexp', skip over opening
square brackets, so as to highlight them.  After calling
'forward-sexp' and before setting 'start' and 'end', skip over
closing square brackets and periods, so as to highlight them.
2026-02-15 11:16:11 +00:00
Vili Aapro
8c39a17eef elisp--highlight-function-argument: Use forward-sexp
* lisp/progmodes/elisp-mode.el
(elisp--highlight-function-argument): Use 'forward-sexp' to move
over usage arguments, handling parenthesized argument patterns
monolithically (bug#8432).  Set 'start' and 'end' to the
beginning and end, respectively, of the usage argument.
2026-02-15 11:16:11 +00:00
Vili Aapro
7d2303aef8 elisp--highlight-function-argument: Use temporary buffer
* lisp/progmodes/elisp-mode.el
(elisp--highlight-function-argument): Insert 'args' into
temporary buffer to prepare for better handling of usage
arguments (bug#8432).  Move point after the first opening
parenthesis of the arguments string.  In the loop, let `origin'
track the point.  No functional change.
2026-02-15 11:16:11 +00:00
Yikai Zhao
cdf360059f Fix project-buffers error on buffers with nil default-directory
* lisp/progmodes/project.el (project-buffers):
Check that default-directory is non-nil (bug#80390).
2026-02-15 04:22:45 +02:00
Sean Whitton
bc763572a9 vc-find-backend-function: Require vc for default implementations
* lisp/vc/vc-hooks.el (vc-find-backend-function): Require vc for
default implementations (bug#80254).  Report and fix due to
Daniel Mendler <mail@daniel-mendler.de>.
2026-02-14 15:03:52 +00:00
Eli Zaretskii
114fab51c0 Fix 'eglot-imenu'
* lisp/progmodes/eglot.el (eglot--imenu-SymbolInformation): Fix
call to 'plist-get'.  Patch by Lester Longley <lester@ieee.org>.
(Bug#80367)

Copyright-paperwork-exempt: yes
2026-02-14 14:22:08 +02:00
João Távora
541040d4c8 Eglot: fix neocmakelsp invocation
See https://github.com/joaotavora/eglot/issues/1578

* lisp/progmodes/eglot.el (eglot-server-programs): Fix neocmakelsp
2026-02-13 11:28:44 +00:00
kobarity
06395ba77d Revert "Use 'project-name-cached' in 'python-shell-get-process-name'"
This reverts commit 482748592f.

Commit 583a112169 removed
'project-name-cached' and also resolved bug#80045.
2026-02-13 09:43:29 +02:00
Stefan Monnier
bc9a53616a make-mode.el: Avoid obsolete font-lock-*-face` variables
* lisp/progmodes/make-mode.el (makefile-make-font-lock-keywords)
(makefile-makepp-font-lock-keywords): Use `font-lock-*-face`
faces rather than variables.
2026-02-11 15:35:03 -05:00
Dmitry Gutov
d62370a0ec Improve project-vc-*cache-timeout docstrings
* lisp/progmodes/project.el: (project-vc-cache-timeout)
(project-vc-non-essential-cache-timeout): Improve docstrings (bug#78545).
2026-02-10 18:56:49 +02:00
Dmitry Gutov
583a112169 Do cache and timed invalidation in "VC-aware" project backend
* lisp/progmodes/project.el: Describe the new cache in Commentary,
the "VC-aware project" section.
(project-vc-cache-timeout)
(project-vc-non-essential-cache-timeout): New variables.
(project--get-cached, project--set-cached):
New functions.
(project-try-vc, project--value-in-dir): Use them.
(project--read-dir-locals): New function, extracted from the
above.  Return the full alist, to be saved to cache at once.
(project--clear-cache): New function.
(project-remember-projects-under)
(project-forget-zombie-projects, project-forget-projects-under):
Use it.
(project-uniquify-dirname-transform, project-mode-line-format):
Bind 'non-essential' to choose the longer caching strategy.
(project-name-cache-timeout, project-name-cached): Remove.
(project-mode-line-format): Switch to calling 'project-name'
directly, with the new caching in use.

Co-authored-by: Juri Linkov <juri@linkov.net>
2026-02-10 02:54:14 +02:00
Dmitry Gutov
8cb9aaec0f Amend previous to avoid remote call in project--remove-from-project-list
* lisp/progmodes/project.el (project--remove-from-project-list):
Don't call 'abbreviate-file-name', expect it to be abbreviated
already.  The file might be on an inaccessible filesystem.
(project-current): Call abbreviate-file-name here (bug#80340).
2026-02-10 02:54:14 +02:00
Dmitry Gutov
8ddf2d2925 project--delete-zombie-projects: Handle "Tramp failed to connect"
* lisp/progmodes/project.el (project--delete-zombie-projects):
Handle file-error when DIR is remote and unreachable (bug#80340).
2026-02-09 00:56:08 +02:00
Matthew Bauer
78fc5e2833 Eglot: Add "static-ls" to Haskell LSP list
This is an alternative language server for Haskell.  Intended to be
faster and not use as much memory as haskell-language-server.
Making it a backup with lower precedence if both exist.
* lisp/progmodes/eglot.el (eglot-server-programs): Add "static-ls".
(Bug#80351)
2026-02-08 08:38:08 +02:00
kobarity
3107c66c84 Change the type of 'python-eldoc-function-timeout' to number
* etc/NEWS: Announce the change.
* lisp/progmodes/python.el (python-eldoc-function-timeout):
Change the type.  (Bug#80045)
2026-02-07 14:44:27 +02:00
kobarity
482748592f Use 'project-name-cached' in 'python-shell-get-process-name'
* lisp/progmodes/python.el
(python-shell-get-project-name): New function.
(python-shell-get-process-name): Use it.  (Bug#80045)

Co-authored-by: Liu Hui <liuhui1610@gmail.com>
2026-02-07 14:41:48 +02:00
kobarity
3d7e78b810 Revert "Performance improvement of 'python-shell-get-process'"
This reverts commit 83b4f1ba26.
We concluded that it is better to use 'project-name-cached'.
(Bug#80045)
2026-02-07 14:41:10 +02:00
Dmitry Gutov
df517aa958 etags-regen--build-program-options: Expand the error message text
* lisp/progmodes/etags-regen.el (etags-regen--build-program-options):
Expand the error message text.
2026-02-07 02:07:30 +02:00
Dmitry Gutov
cc9fea52a3 etags--xref-backend: Move the definition to autoloads
* lisp/progmodes/etags.el (etags--xref-backend):
Move the definition to autoloads, so that etags.el doesn't have to
be loaded before it really is used.
2026-02-07 02:06:52 +02:00
Dmitry Gutov
90d3fdaffc Allow using xref-find-references without visiting a tags table
* lisp/progmodes/xref.el (xref-find-backend):
Allow returning nil (bug#43086).
(xref-backend-definitions, xref-backend-apropos):
Signal user-error when no backend is available.  The error text
suggests a few built-in Xref backends.
(xref-backend-identifier-completion-table): Default to nil.
(xref--no-backend-available): New helper function.

* lisp/progmodes/etags.el (etags--xref-backend):
Return nil when no tags table is visited.
2026-02-06 05:56:52 +02:00
João Távora
ec5479f0b5 Eglot: fix thinko in eglot--async-request
Just because a specific request of a specific "hint" is
cancelled doesn't mean we can cancel the other's too.  Also
eglot-advertise-cancellation = nil was subtly broken.

This manifested itself mostly in Eglot semantic tokens.

* lisp/progmodes/eglot.el (eglot--async-request): Fix thinkos.
2026-02-05 22:39:19 +00:00
Mattias Engdegård
ac07913bd8 ; * lisp/progmodes/elisp-mode.el: slightly better rescanning point
Suggested by Stefan Monnier.
2026-02-01 13:25:28 +01:00
Mattias Engdegård
385bcc6117 Fix lazy doc string fontify bug in elisp-byte-code-mode (bug#80292)
* lisp/progmodes/elisp-mode.el (elisp-byte-code-syntax-propertize):
Reset point to just after the start of the previous match so that we
don't skip past the end of the lazy string, which can happen if it's
zero-length; that could lead to an infinite loop.
2026-01-31 18:58:29 +01:00
João Távora
d0daaead22 Eglot: recall diagnostics froms unopened files on session start
This is exclusively for the benefit of rust-analyzer, which
sends publishDiagnostics for all project files upfront, and
never republishes them on 'didOpen'.

See https://github.com/joaotavora/eglot/issues/1531.

* lisp/progmodes/eglot.el (eglot--flymake-handle-push): Simplify.
Don't flymake-list-only-diagnostics here.
Save original diagnostic in flymake-list-only-diagnostics setting.
(eglot--on-shutdown): Cleanup flymake-list-only-diagnostics.
(eglot--flymake-report-push+pulled): Hack in data from
flymake-list-only-diagnostics.
2026-01-30 12:55:32 +00:00
Juri Linkov
077b33ef7d * lisp/progmodes/eglot.el (eglot-server-programs): Use "elp" for erlang-mode.
erlang_ls has been archived in favour of erlang-language-platform.
Suggested by Alan & Kim Zimmerman <alan.zimm@gmail.com> (bug#79943).
2026-01-30 09:53:30 +02:00
Dmitry Gutov
3937833fff xref-find-backend: Error instead of returning nil
* lisp/progmodes/xref.el (xref-find-backend):
Signal error when we can't find a backend to use (bug#80246).
2026-01-29 17:11:45 +02:00
Dmitry Gutov
dfc2a66ad8 xref-matches-in-directory and xref-matches-in-files: More consistency
* lisp/progmodes/xref.el (xref--parse-hits, xref--sort-hits):
Extract from xref-matches-in-directory and xref-matches-in-files.
Use in both for better consistency between these functions.
2026-01-28 23:48:04 +02:00
Dmitry Gutov
d44b855b0c xref-matches-in-directory: Don't error on "Binary file ... matches"
* lisp/progmodes/xref.el (xref-matches-in-directory):
Consider the "Binary file ... matches" message (bug#80246).
2026-01-28 22:10:34 +02:00
Daniel Mendler
32cffe1707 Customizable xref-references-in-directory backend
Optionally use find and grep directly instead of going through the
Semantic framework (bug#80246).

* lisp/progmodes/project.el (project--vc-ignores): Require 'vc' to
ensure that vc-default-ignore-completion-table is available.

* lisp/progmodes/xref.el (xref-references-in-directory-function):
New user option.
(xref-references-in-directory): Call it.
(xref-references-in-directory-grep): Implementation based on find/grep.
(xref-references-in-directory-semantic): Implementation using Semantic.
(xref-matches-in-directory): Add new argument DELIMITED.

Co-authored-by: Dmitry Gutov <dmitry@gutov.dev>
2026-01-28 04:38:58 +02:00
Philip Kaludercic
bff916d7f9
Have default 'compile-command' run make in parallel
* lisp/progmodes/compile.el (compile-command): Change default
value.

(Bug#80065)
2026-01-25 12:26:19 +01:00
Dmitry Gutov
3573116d3e ; Fix indentation in project.el 2026-01-24 06:48:29 +02:00
Dmitry Gutov
b7d4681908 Stop project-query-replace-regexp failing on directory symlinks
* lisp/progmodes/project.el (project--files-safe): New function.
(project-search, project-query-replace-regexp): Use it (bug#78209).
2026-01-24 06:45:32 +02:00
João Távora
f2250ba244 Eglot: simplify Imenu setup again
See https://github.com/joaotavora/eglot/issues/1569.

* lisp/progmodes/eglot.el (eglot--managed-mode): Tweak.

* etc/EGLOT-NEWS: Tweak.
2026-01-21 23:09:19 +00:00
João Távora
10b132006e Eglot: display more readable server-originated messages
* lisp/progmodes/eglot.el (eglot--format-server-message): New helper.
(eglot-handle-notification<window/showMessage>)
(eglot-handle-request<window/showMessageRequest>): Use it.
2026-01-21 23:08:39 +00:00
Juri Linkov
8063921808 Fix down-list navigation in python-ts-mode
* lisp/progmodes/python.el (python-ts-mode):
Set 'treesit-sexp-thing-down-list' to 'list' to override
sexp navigation with list navigation (bug#72478).

* lisp/emacs-lisp/lisp.el (up-list): Mention 'up-list-function' in docstring.
2026-01-21 20:02:56 +02:00
Binbin Ye
8ea6f6da77 Add JSON path utility command to json-ts-mode
* lisp/progmodes/json-ts-mode.el (json-ts--get-path-at-node)
(json-ts--path-to-jq, json-ts--path-to-python): New functions.
(json-ts-jq-path-at-point): New command for getting JSON path at point.

* test/lisp/progmodes/json-ts-mode-tests.el: New file.
Add tests for the utility command.

* etc/NEWS: Announce new command 'json-ts-jq-path-at-point' (bug#80190).
2026-01-21 19:27:03 +02:00
João Távora
9d8e1af6f4 Eglot: fix textDocument/prepareRename support
Can't send prepareRename requests willy-nilly.

See https://github.com/joaotavora/eglot/issues/1554.

* lisp/progmodes/eglot.el (eglot--rename-interactive): Fix.
(eglot-client-capabilities): Advertise "prepareSupport".

* etc/EGLOT-NEWS: Mention change.
2026-01-21 12:26:24 +00:00
João Távora
f643ad53c7 Eglot: set imenu-create-index-function without advice
See https://github.com/joaotavora/eglot/issues/1569.

* lisp/progmodes/eglot.el (eglot--managed-mode): Stomp on
imenu-create-index-function conditionally.
(eglot-imenu): Don't check eglot-server-capable here.

* etc/EGLOT-NEWS: Mention change.
2026-01-21 12:26:24 +00:00
João Távora
d3548aea96 Eglot: limit the number of file watches
Some language servers request file watching for a very large number of
directories (e.g. Python virtualenvs), which can exhaust system
resources and cause slow startup.

https://github.com/joaotavora/eglot/issues/1568

* lisp/progmodes/eglot.el (eglot-max-file-watches): New variable.
(eglot--count-file-watches): New function.
(eglot--watch-globs): Use them to limit watches.  Signal jsonrpc-error
when limit is reached.
(eglot-watch-files-outside-project-root): Fix docstring punctuation.

* etc/EGLOT-NEWS: Mention change.
2026-01-21 12:26:24 +00:00
João Távora
a3ea65a984 Eglot: support more complex workspace edits (create/rename/delete)
Advertise support for file resource operations in workspace edits.
Implement create, rename, and delete file operations.  Rework
confirmation UI to handle mixed operation types.

* lisp/progmodes/eglot.el (eglot--lsp-interface-alist): Add
CreateFile, RenameFile, DeleteFile interfaces.
(eglot-client-capabilities): Advertise resourceOperations and
failureHandling.
(eglot-handle-request<workspace/applyEdit>): Return failureReason.
(eglot--apply-text-edits): Tweak error message.
(eglot--propose-changes-as-diff): Adjust for new prepared format.
Return buffer.
(eglot--apply-workspace-edit): Rework.  Handle file operations.

* etc/EGLOT-NEWS: Mention change.
2026-01-21 12:26:24 +00:00
João Távora
f02a120f18 Eglot: overhaul eglot-confirm-server-edits defcustom
Now also accepts file operation kinds as keys in the alist form.

* lisp/progmodes/eglot.el (eglot-confirm-server-edits): Rework
default value, docstring and defcustom type.
(eglot--confirm-server-edits): Also check for operation-kind-based
entries.
2026-01-21 12:26:24 +00:00
João Távora
b40e89e523 Eglot: default eglot-advertise-cancellation to t
The current 2026 landscape suggests servers (especially gopls
and ocamllsp) take advantage of this, so let's give it to them
by default.

* lisp/progmodes/eglot.el (eglot-advertise-cancellation):
Default to t.

* etc/EGLOT-NEWS: Mention change.
2026-01-21 12:26:24 +00:00