bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#50240: 28.0.50; incorrect handling of ignore files in project-files


From: Dmitry Gutov
Subject: bug#50240: 28.0.50; incorrect handling of ignore files in project-files
Date: Mon, 30 Aug 2021 05:22:40 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

On 29.08.2021 11:30, Omar Polo wrote:

Yes, with "./foo" the issue is resolved, but I think a more general fix
in project.el is warranted.

It's quite common (at least for C and Go which I use frequently) to
produce a binary in the root directory of the project with the same name
of the project, for example

        /home/op/w/foo/    <- project root
        /home/op/w/foo/foo <- the binary produced

and I expect users to have "foo" in their ignore file, not "./foo", as
they do for e.g. when using git and vc-git.

Fair enough.

Also, if one day in the future someone decides to remove the specific
treatment of Git and Hg from project-files this issue will bite
vc-git/hg users too.

Unlikely: the special treatment is there foremost for performance. But perhaps we'll get a faster universal method for listing files, who knows.

I guess I can hack something in my custom vc backend to replace an
ignore entry called "<projectname>" with "./<projectname>", but this
would probably need to be done on every vc backend, excluding git and
hg.

For the time being, I'm using the following patch, but I don't
particularly like it.


diff --git a/project.el b/project.el
index ae9bf03..176947e 100644
--- a/project.el
+++ b/project.el
@@ -302,6 +302,12 @@ to find the list of ignores for each directory."
           ;; expanded and not left for the shell command
           ;; to interpret.
           (localdir (file-name-unquote (file-local-name (expand-file-name 
dir))))
+         (projectname (file-name-nondirectory (directory-file-name dir)))
+         (ignores (mapcar (lambda (e)
+                            (if (string= projectname e)
+                                (concat "./" e)
+                              e))
+                          ignores))
           (command (format "%s -H %s %s -type f %s -print0"
                            find-program
                            (shell-quote-argument

Please try this patch instead:

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index ae9bf03571..b267185ab0 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -302,10 +302,9 @@ project--files-in-directory
          ;; expanded and not left for the shell command
          ;; to interpret.
(localdir (file-name-unquote (file-local-name (expand-file-name dir))))
-         (command (format "%s -H %s %s -type f %s -print0"
+         (dfn (directory-file-name localdir))
+         (command (format "%s -H . %s -type f %s -print0"
                           find-program
-                          (shell-quote-argument
-                           (directory-file-name localdir)) ; Bug#48471
                           (xref--find-ignores-arguments ignores localdir)
                           (if files
                               (concat (shell-quote-argument "(")
@@ -324,8 +323,9 @@ project--files-in-directory
                        (unless (zerop status)
(error "File listing failed: %s" (buffer-string))))))))
     (project--remote-file-names
-     (sort (split-string output "\0" t)
-           #'string<))))
+     (mapcar (lambda (s) (concat dfn (substring s 1)))
+             (sort (split-string output "\0" t)
+                   #'string<)))))

 (defun project--remote-file-names (local-files)
"Return LOCAL-FILES as if they were on the system of `default-directory'.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]