1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-04 05:11:15 -07:00
Commit graph

494 commits

Author SHA1 Message Date
Basil L. Contovounesios
ada12edeb7 Better project-find-file error in empty project
* lisp/progmodes/project.el (project--read-file-name): Signal a
user-error and don't call project-read-file-name-function if the
file name collection is empty, since the default options for
project-read-file-name-function expect a cons (bug#80509).
(project-find-file-in): Avoid redundant consing for
vc-directory-exclusion-list in default case of include-all=nil.
2026-02-28 16:58:45 +01:00
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
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
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
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
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
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
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
Eli Zaretskii
18f9f0bdc9 ; Update Project documentation due to recent changes
* etc/NEWS:
* doc/emacs/maintaining.texi (Projects):
* lisp/progmodes/project.el (project-mode-line): Update
documentation due to changes in bug#78545.
2026-01-15 08:52:20 +02:00
Juri Linkov
1e6d8e6750 * lisp/progmodes/project.el: Improve performance of 'project-mode-line'.
(project-name-cache-timeout): New variable.
(project-name-cached): New function (bug#78545).
(project-mode-line): New value 'non-remote'.
(project-mode-line-format): Don't show the remote project's name
when 'project-mode-line' is 'non-remote'.  Use 'project-name-cached'.
2026-01-14 20:07:23 +02:00
Stefan Monnier
65090ec691 (project-files): Revert part of commit 6c832af157
* lisp/progmodes/project.el (project-files): Don't add `ignores` twice.
2026-01-09 13:51:33 -05:00
João Távora
b8ff1c1fae * lisp/progmodes/project.el (Version): Bump to 0.11.2
(bug#79809)
2026-01-04 14:12:02 +00:00
Dmitry Gutov
89879654e5 Fix indentation in some project.el functions
* lisp/progmodes/project.el
(vc-git-project-list-files, project--vc-ignores)
(project-prompt-project-dir): Fix indentation.
2026-01-02 02:59:22 +02:00
Dmitry Gutov
c678963fb1 project-files<vc>: Fix 'void-function vc-git--program-version'
* lisp/progmodes/project.el (project-try-vc--search): Re-add the
loading of vc-<backend> feature just removed from `project-files'.
2026-01-02 02:50:46 +02:00
Sean Whitton
c31f6adc31 ; Add 2026 to copyright years. 2026-01-01 12:54:34 +00:00
Dmitry Gutov
6c832af157 Allow project-vc-ignores to be applied in more cases
Discussed in
https://lists.gnu.org/archive/html/emacs-devel/2025-12/msg00903.html.

* lisp/progmodes/project.el (project-files) <vc>: Look up the
value of 'project-vc-ignores' inside DIR rather than project root.
This allows this variable to be applied in external dirs as well.
(project-ignores) <vc>: Do likewise.
(project--value-in-dir): Ensure that DIR has a trailing slash.
The caller might pass the value without slash if produced
differently.

* test/lisp/progmodes/project-tests.el
(project-vc-ignores-in-external-directory): New test.
(project-vc-supports-files-in-subdirectory): Update the test,
considering the subtle change in behavior: the directory DIR
directly includes a .dir-locals.el which sets project-vc-ignores,
which wasn't previously applied because it wasn't set in the root.
2026-01-01 04:13:30 +02:00
Stefan Monnier
c12b9edcd4 project-vc: Provide default implementation of project-list-files
Rework the implementation of `project-files<vc>` so as to
delegate more to the `project-list-files` operation, including
the default implementation.

This can change the behavior in some cases, because it changes
which ignore settings apply where and also it can now use
a dedicated VC backend implementation even for directories
that are outside of the project's root.  But the effect should
hopefully be marginal and rather positive by making the behavior
more "regular".

* lisp/progmodes/project.el (project-vc--backend): New function.
(project-files) <vc>: Use it.  Call VC's `project-list-files` operation
for all dirs with a backend and remove the `vc-not-supported` fallback.
Inline the `project--dir-ignores` call.
(vc-default-project-list-files): New function, extracted from
`project-files<vc>`.
(vc-git-project-list-files): Use it instead of signaling `vc-not-supported`.
(project--vc-ignores): New function, extracted from `project-ignores<vc>`.
Remove the `vc-not-supported` since the operation has a default
implementation.  Use DIR's `ignore-completion-table` regardless
if we're at the root of the project.
(project-ignores) <vc>: Use it.
2025-12-31 00:12:59 -05:00
Eli Zaretskii
4fe28df3cd ; * lisp/progmodes/project.el (vc-git-project-list-files): Fix a typo. 2025-12-19 09:56:58 +02:00
Dmitry Gutov
500f1478f7 Re-introduce fallback to 'find' for extra ignores with older Git
* lisp/progmodes/project.el (vc-git-project-list-files):
Fall back to 'find' when Git is older than 1.13 and EXTRA-IGNORES
is non-nil (bug#79809).
2025-12-19 02:47:36 +02:00
Dmitry Gutov
de5b8c70fb Revert "vc-git-project-list-files: Restore support for Git < 2.13"
This reverts commit 821c0d36df.

Despite re-enacting what the modern Git versions seem to do under the
covers, the effect is not the same: filtering works differently.
2025-12-19 02:26:59 +02:00
Dmitry Gutov
75a1403ff3 Fix "No such file or directory" "vc-nil" in project-files
* lisp/progmodes/project.el (project-files):
Fix vc-nil backend error (bug#80013).
2025-12-18 03:48:58 +02:00
Dmitry Gutov
821c0d36df vc-git-project-list-files: Restore support for Git < 2.13
* lisp/progmodes/project.el (vc-git-project-list-files):
Restore support for Git < 2.13 (discussed in bug#79809).
2025-12-18 01:43:28 +02:00
Dmitry Gutov
f8cf01134b project-files: Add the 'else' case to the previous change
* lisp/progmodes/project.el (project-files): Add the 'else' case
to the previous change (for DIRS outside of project root).
2025-12-14 04:34:16 +02:00
Dmitry Gutov
583856c437 Make project--vc-list-files extensible
* lisp/progmodes/project.el (project--vc-list-files):
Call backend function 'project-list-files'.
(project-files): Catch 'vc-not-supported' and default to
'project--files-in-directory' using the current project.
(vc-git-project-list-files, vc-hg-project-list-files):
New functions, extracted from 'project--vc-list-files'.
(https://lists.gnu.org/archive/html/emacs-devel/2025-12/msg00290.html)
2025-12-14 03:50:11 +02:00
Dmitry Gutov
48a4444977 Relax the condition on the values of DIRS in project-files
* lisp/progmodes/project.el (project-files):
Use 'file-in-directory-p' to dispatch to 'project--vc-list-files'
when listing subdirectory files too (bug#79809).
2025-12-14 02:26:36 +02:00
Sean Whitton
0f90cc033d ; * lisp/progmodes/project.el (project-compile): Fix last change. 2025-11-30 18:32:51 +00:00
Sean Whitton
5167989b2a Cache VC incoming revisions
* lisp/vc/vc-hooks.el (vc-file-setprop): Use cl-pushnew.
(vc--repo-setprop, vc--repo-getprop, vc--repo-clearprops): New
functions.
* lisp/vc/vc.el (vc--incoming-revision): Cache incoming
revisions.
* src/fns.c (Fput): State that VALUE is returned.
2025-11-30 18:20:50 +00:00
Sean Whitton
16b19ceb28 project-compile: Don't let-bind compile-command
* lisp/progmodes/project.el (project-compile): Handle ignoring
compile-command from a vc-compilation-mode buffer in a way that
does not involve let-binding compile-command.
2025-11-30 17:36:33 +00:00
Dmitry Gutov
702b16f999 Fix project-prompt-project-name with (choose a dir)
* lisp/progmodes/project.el (project-prompt-project-name):
Use correct equality check (bug#79894).
2025-11-27 12:27:22 +02:00
Sean Whitton
8b241f93b7 project-compile: Ignore compile-command from vc-compilation-mode
* lisp/progmodes/project.el (project-compile): Ignore
compile-command from vc-compilation-mode (bug#79658).
* lisp/vc/vc-dispatcher.el (vc-compilation-mode-hook): New
variable.
(vc-compilation-mode): Promote to its own derived mode.  Don't
use define-derived-mode in order to preserve the BACKEND
argument to this function.  Don't give it its own major mode
map, et cetera, for now.
2025-11-06 12:57:35 +00:00
Sean Whitton
889ae269b0 ; project-prompt-project-name: Fix pcase usage. 2025-10-01 11:27:25 +01:00
Sean Whitton
6ef6b517aa VC: Allow deleting or moving current working tree
* lisp/progmodes/project.el (project-prompter)
(project-prompt-project-dir, project-prompt-project-name):
* lisp/vc/vc.el (vc--prompt-other-working-tree): New ALLOW-EMPTY
optional argument.
(delete-working-tree, move-working-tree): Specify that callers
must ensure DIRECTORY is not the current working tree.
(vc-delete-working-tree, vc-move-working-tree): Pass ALLOW-EMPTY
non-nil to vc--prompt-other-working-tree.  Bind
'default-directory' to another working tree when operating on
the current working tree.
(vc-delete-working-tree): Extra prompt when asked to delete the
current working tree.  When deleting the current working tree,
call 'bury-buffer' one or more times at the end.
2025-09-30 16:12:14 +01:00
Dmitry Gutov
a060bdec82 Better 'project-buffer' completion category defaults in Emacs <= 30
* lisp/progmodes/project.el: Fall back to adding 'project-buffer'
to 'completion-category-defaults' if 'define-completion-category'
is not available (bug#79409).
2025-09-10 02:26:31 +03:00
Eshel Yaron
6b6cfa8e40
; * lisp/progmodes/project.el: Restore backward compatibility. 2025-09-08 17:30:52 +02:00
Sean Whitton
15939846a0 Make C-x v w w work in Log View mode, to change working directory
* lisp/vc/diff-mode.el (diff-find-matching-buffer): Rename ...
* lisp/progmodes/project.el
(project-change-to-matching-directory): ... to here.  All uses
changed.
* lisp/vc/log-view.el (project-change-to-matching-directory):
Declare.
(log-view-mode): Use it.
* doc/emacs/vc1-xtra.texi (Other Working Trees): Document the
change.
2025-09-08 11:50:36 +01:00
Dmitry Gutov
c36259e479 project--read-project-buffer: Fix creating new buffer
* lisp/progmodes/project.el (project--read-project-buffer):
Fix the case of entering new buffer name (bug#77312).
2025-09-07 04:56:00 +03:00
Eshel Yaron
60a22185b7
Support completion category inheritance
* lisp/minibuffer.el (define-completion-category): New function.
(completion-category-get): New function, implements completion
category property lookup with (multiple) inheritance.
(completion-metadata-get, completion--styles)
(completion--cycle-threshold): Use it.
(completion-category-defaults): Mention it in docstring.
Remove entry for 'project-buffer' category, and instead...
* lisp/progmodes/project.el: ...have 'project-buffer' inherit
from 'buffer'.
* test/lisp/minibuffer-tests.el
(completion-category-inheritance): New test.
* etc/NEWS: Announce support for category inheritance.
2025-09-03 21:01:43 +02:00
Dmitry Gutov
bb0ede711e Have project-switch-to-buffer use a distinct completion category
* etc/NEWS: Mention the change.

* lisp/minibuffer.el (completion-category-defaults):
Add an entry for it.

* lisp/progmodes/project.el (project--buffers-completion-table):
Return category 'project-buffer'.
2025-08-24 03:23:48 +03:00
Dmitry Gutov
0e37977546 Follow-up to previous changes in project--read-project-buffer
* lisp/progmodes/project.el (project--buffers-completion-table):
New function, use it to implement the no-internal/internal
fallback logic from 'internal-complete-buffer', apply the
category and cycle-sort-function (bug#77312).
(project--read-project-buffer): Use it.  Skip 'read-buffer' in
favor of 'completing-read'.  But make sure to honor
read-buffer-completion-ignore-case and use format-prompt when
the function is available.  Unify two execution paths.
2025-08-24 03:23:48 +03:00
Elías Gabriel Pérez
ade6608e25 project: Improve pruning of zombie projects.
* etc/NEWS: Update 'project-prune-zombie-projects' entry.
* lisp/progmodes/project.el (project-prune-zombie-projects):
Change default value (bug#77566).
(project--ensure-read-project-list, project--write-project-list)
(project-prompt-project-dir, project-prompt-project-name):
Rework for use 'project-prune-zombie-projects' value.
(project-forget-zombie-projects): Move code...
(project--delete-zombie-projects): ... to this new function.
2025-08-21 20:22:33 +03:00
Sean Whitton
12354bcfdc VC other working trees: avoid reordering project--list
* lisp/progmodes/project.el (project--remember-dir)
(project-remember-project): New STABLE argument.
* lisp/vc/vc.el (vc-add-working-tree)
(vc--prompt-other-working-tree, vc-move-working-tree): Use it.
2025-08-08 13:30:41 +01:00
Sean Whitton
c501ed7dc1 Generalize finding project matching files to other major modes
* lisp/progmodes/project.el
(project-find-matching-buffer-function): New variable.
(project-find-matching-file): Delete.
(dired-current-directory): Declare.
(project-find-matching-file-or-directory): New function.  Like
the old 'project-find-matching-file', but also handle Dired
buffers (bug#79126).  When matching file/directory does not
exist, try going up in the directory tree until we find
something that does.
(project-find-matching-buffer): New command.
* lisp/vc/vc.el (vc-switch-working-tree): Use it (bug#79126).
* etc/NEWS: Announce new command and new variable.
2025-08-08 11:17:53 +01:00
Paul Nelson
6b2856f9ca Allow numbered buffer selection for project-shell
* lisp/progmodes/project.el (project-shell, project-eshell):
When a numeric prefix is supplied, the command switches to or
creates a session buffer whose name has that number as a suffix.
For instance, C-2 yields "*name-of-project-shell<2>*".  As
before, a plain universal argument C-u creates a new session
with an automatically generated numeric suffix.  This change
makes the behavior of the project-shell commands consistent with
how M-x eshell handles numeric prefixes.
* etc/NEWS: Announce the change. (bug#76500)
2025-08-06 04:46:49 +03:00
Sean Whitton
9e48d1f49a project-prompter: New PREDICATE and REQUIRE-KNOWN arguments
* lisp/progmodes/project.el (project-prompter)
(project-prompt-project-dir, project-prompt-project-name): New
PREDICATE and REQUIRE-KNOWN optional arguments.
* lisp/vc/vc.el (project-prompter): Declare.
(vc--prompt-other-working-tree): New function.
(vc-switch-working-tree, vc-delete-working-tree)
(vc-move-working-tree): Use it to prompt for the other working
tree in a way that respects 'project-prompter' (bug#79024).
* etc/NEWS: Announce all three optional arguments.  Rework
description of new optional argument to 'project-current'.
2025-08-04 20:59:02 +01:00