projectile icon indicating copy to clipboard operation
projectile copied to clipboard

`projectile-go-project-p` doesn't work when under sub-folder of the one has `project marker`

Open ccqpein opened this issue 4 years ago • 7 comments

My project structure is:

|-A
  |- .git
  |- B
    |- go.mod
    |- main.go

Expected behavior

When I open main.go, the projectile-bookmarks.eld in my emacs.d should added /A/B.

Actual behavior

in my projectile-bookmarks.eld, it added /A

Steps to reproduce the problem

M-x projectile-clear-known-projects , then restart emacs.

then open the main.go file located like I showed upper. cat ~/.emacs.d/projectile-bookmarks.eld to see which path added to projectile.

Environment & Version information

Projectile version information

I install it from elpa, but the M-x projectile-version gives me:

Projectile nil

Emacs version

GNU Emacs 29.0.50 (build 1, x86_64-apple-darwin21.2.0, NS appkit-2113.20 Version 12.1 (Build 21C52)) of 2022-01-23

Operating system

macOS Monterey 12.1

ccqpein avatar Jan 25 '22 03:01 ccqpein

I have read doc and play around a bit with projectile.

If, first I manually add

(projectile-register-project-type
   'go
   '("go.mod")
   :project-file "go.mod")

secondly, change projectile-project-root-functions to

'(projectile-root-local
     projectile-root-top-down
     projectile-root-bottom-up
     projectile-root-top-down-recurring)

It works fine (which means add /A/B inside projectile-bookmarks.eld instead of /A).

After that, I get the value details of projectile-project-types. I noticed the marker-files of go is function projectile-go-project-p here.

Then I goto projectile-detect-project-type => projectile-verify-file => projectile-expand-root => projectile-project-root. Then I run (projectile-project-root) and get /A.

ccqpein avatar Jan 25 '22 04:01 ccqpein

I give several (message) inside source code and looks like it runs projectile-project-root right after I open my main.go. Then, put the /A inside projectile-project-root-cache because projectile-root-bottom-up gonna return /A. I think it projectile-root-top-down should return value /A/B before projectile-root-bottom-up but actually it returns nothing.

ccqpein avatar Jan 25 '22 06:01 ccqpein

Thanks, I ran into this problem myself as well. Care to submit a PR?

wyuenho avatar Jul 22 '22 20:07 wyuenho

To be honest, I am not sure if it is a problem or be designed this way.

Because projectile-root-bottom-up's pair custom value projectile-project-root-files-bottom-up are all the folders. And the projectile-project-root-files (projectile-root-top-down uses) are all the project configuration files (especially projectile-register-project-type hard codes a lot of languages' configuration files).

So, if it is designed this way, it isn't a problem. Just the ambiguous meaning of those two functions in doc.

ccqpein avatar Jul 23 '22 02:07 ccqpein