unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#55632: [PATCH] Add new user option project-vc-find-tracked-only
@ 2022-05-25  9:08 Jan Synáček
  2022-05-27 11:01 ` Lars Ingebrigtsen
  2022-05-27 13:55 ` Dmitry Gutov
  0 siblings, 2 replies; 16+ messages in thread
From: Jan Synáček @ 2022-05-25  9:08 UTC (permalink / raw)
  To: 55632

[-- Attachment #1: Type: text/plain, Size: 744 bytes --]

Tags: patch

Tags: patch


Currently, `project-find-file' always includes untracked files, which is
not always the desired behavior. This patch adds a new user option to
make only find the actual project files. By default, the variable is set
to nil, which means the behavior is not changed.

In GNU Emacs 28.1.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.6)
 of 2022-05-21 built on jsynacek-home
Repository revision: 9e7c0cf57d522b50423880f3a846c52c5509fef9
Repository branch: emacs-28
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Arch Linux

Configured using:
 'configure --with-imagemagick --with-json --with-native-compilation
 --prefix=/home/jsynacek/emacs'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-new-user-option-project-vc-find-tracked-only.patch --]
[-- Type: text/patch, Size: 3569 bytes --]

From e1562448ca0d95188c4dc9712c8aa4575a5a3bdd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Syn=C3=A1=C4=8Dek?= <jan.synacek@gmail.com>
Date: Wed, 25 May 2022 10:53:55 +0200
Subject: [PATCH] Add new user option project-vc-find-tracked-only

* doc/emacs/maintaining.texi (Projects): Document it.
* lisp/progmodes/project.el (project--vc-list-files): Use it.
---
 doc/emacs/maintaining.texi |  6 ++++--
 etc/NEWS                   |  5 +++++
 lisp/progmodes/project.el  | 16 +++++++++++-----
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index 3ddea0ae58..c33b649490 100644
--- a/doc/emacs/maintaining.texi
+++ b/doc/emacs/maintaining.texi
@@ -1664,8 +1664,10 @@ Projects
 support additional types of projects.
 
   Which files do or don't belong to a project is also determined by
-the project back-end.  For example, the VC back-end doesn't consider
-``ignored'' files (@pxref{VC Ignore}) to be part of the project.
+the project back-end.  For example, the VC back-end only considers
+``ignored'' files (@pxref{VC Ignore}) to be part of the project if
+the value of the variable @code{project-vc-find-tracked-only} is
+non-nil.
 
 @menu
 * Project File Commands::   Commands for handling project files.
diff --git a/etc/NEWS b/etc/NEWS
index 857f300384..abae05749c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1678,6 +1678,11 @@ Enabling this minor mode turns on hiding header material, like
 'elide-head' does; disabling it shows the header.  The commands
 'elide-head' and 'elide-head-show' are now obsolete.
 
++++
+*** New user option 'project-vc-find-tracked-only'.
+If set to non-nil, 'project-find-file' only considers tracked, that is
+not ignored, files.
+
 ---
 ** The autoarg.el library is now marked obsolete.
 This library provides the 'autoarg-mode' and 'autoarg-kp-mode' minor
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 6c50135358..836d6a1574 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -382,6 +382,11 @@ project-vc-merge-submodules
   :package-version '(project . "0.2.0")
   :safe #'booleanp)
 
+(defcustom project-vc-find-tracked-only nil
+  "Non-nil makes `project-find-file' consider only tracked files."
+  :type 'boolean
+  :safe #'booleanp)
+
 ;; FIXME: Using the current approach, major modes are supposed to set
 ;; this variable to a buffer-local value.  So we don't have access to
 ;; the "external roots" of language A from buffers of language B, which
@@ -512,8 +517,9 @@ project--vc-list-files
            (args '("-z"))
            (vc-git-use-literal-pathspecs nil)
            files)
-       ;; Include unregistered.
-       (setq args (append args '("-c" "-o" "--exclude-standard")))
+       (setq args (append args
+                          '("-c" "--exclude-standard")
+                          (unless project-vc-find-tracked-only '("-o"))))
        (when extra-ignores
          (setq args (append args
                             (cons "--"
@@ -565,9 +571,9 @@ project--vc-list-files
        (delete-consecutive-dups files)))
     (`Hg
      (let ((default-directory (expand-file-name (file-name-as-directory dir)))
-           args)
-       ;; Include unregistered.
-       (setq args (nconc args '("-mcardu" "--no-status" "-0")))
+           (args (list (concat "-mcard" (unless project-vc-find-tracked-only "u"))
+                       "--no-status"
+                       "-0")))
        (when extra-ignores
          (setq args (nconc args
                            (mapcan
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-06-04  9:40 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-25  9:08 bug#55632: [PATCH] Add new user option project-vc-find-tracked-only Jan Synáček
2022-05-27 11:01 ` Lars Ingebrigtsen
2022-05-27 13:55 ` Dmitry Gutov
2022-05-29 21:41   ` Dmitry Gutov
2022-05-30 11:00     ` jan.synacek
2022-05-31 22:49       ` Dmitry Gutov
2022-06-02 19:01         ` jan.synacek
2022-06-02 19:19           ` Eli Zaretskii
2022-06-02 23:45             ` Dmitry Gutov
2022-06-03  5:44               ` Eli Zaretskii
2022-06-04  0:37                 ` Dmitry Gutov
2022-06-04  6:29                   ` Eli Zaretskii
2022-06-04  9:40                     ` Dmitry Gutov
2022-05-30 10:08   ` jan.synacek
2022-05-31 22:57     ` Dmitry Gutov
2022-06-01 15:21       ` jan.synacek

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).