projectile icon indicating copy to clipboard operation
projectile copied to clipboard

Add variable to remember most recent project

Open NicholasBHubbard opened this issue 2 years ago • 3 comments

I think it would be useful to provide a variable such as projectile-most-recent-project that remembers the most recent project that you were working in. It is common that I am working on a project and then I switch to a buffer that is related to what I am doing even though it is not a member of any project. Unfortunately when I try to switch projectile buffers again I get "You're not in a project".

If such a variable existed I could easily write my own projectile wrapper functions that default to the most recent project.

I am not the only person that has wanted a way to access the most recent project: #664

I looked into opening a PR that adds this variable, but I could not figure out which function should set this variable so it works reliably across all of projectile. If you could give me some advice on how to do this I would be happy to make the change myself!

NicholasBHubbard avatar Oct 31 '22 16:10 NicholasBHubbard

PR welcome!

I think it'd be probably best to update this somewhere in projectile-switch-project, but making the tracking reliable will be hard as someone can switch between projects just by opening a new file or switching to some open buffers without using projectile-switch-project.

bbatsov avatar Oct 31 '22 19:10 bbatsov

making the tracking reliable will be hard as someone can switch between projects just by opening a new file or switching to some open buffers

This is exactly the problem I ran into when I tried to implement this myself, and this functionality is pointless to add if it does not work when switching buffers and opening files.

NicholasBHubbard avatar Oct 31 '22 19:10 NicholasBHubbard

Well, depends on how people normally use Projectile. I always use switch-project, so something like this will work just fine for me. :D

There's even a hook that'd be handy for this projectile-after-switch-project-hook.

bbatsov avatar Oct 31 '22 20:10 bbatsov