Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #'projectile-track-known-projects-find-file-hook to 'buffer-list-update-hook #1895

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jtamagnan
Copy link

@jtamagnan jtamagnan commented Jun 21, 2024

Foreword

I originally created #1879 but have since deleted that GitHub account,
as such the associated repository and pull request were closed. The
new version of that PR can be found at #1894.

This PR implements Solution 2 as described in #1894.

Problem

There are certain modes for which the
projectile-find-file-hook-function function does not run by
default. This includes, shell, eshell, and magit. If one
navigates directly to one of these buffers and calls
projectile-relevant-known-projects while
projectile-current-project-on-switch is set to 'keep they will
notice that the first repository in the list is not the one that they
expect

Solution

There are two possible solutions that come immediately to mind. I
want to mention both of them for consideration though naturally
this PR only implements one of them:

  1. Add a new 'front option for
    projectile-current-project-on-switch such that the first item is
    the project associated with the current buffer.
  2. Modify projectile-mode to add the hook to
    buffer-list-update-hook such that the current buffer is always
    added to the list of known-projects.

This PR implements Solution 2.
#1894 implements Solution 1.

Comparision

The main drawback with Solution 1 is that the newly selected project
will not be added to the projects list.

The main drawback of Solutionk 2 is that it will not work on versions
of emacs earlier than 28.1 because buffer-list-update-hook works
differently.


Before submitting a PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):

  • The commits are consistent with our contribution guidelines
  • You've added tests (if possible) to cover your change(s)
  • All tests are passing (eldev test)
  • The new code is not generating bytecode or M-x checkdoc warnings
  • You've updated the changelog (if adding/changing user-visible functionality)
  • You've updated the readme (if adding/changing user-visible functionality)

Thanks!

@jtamagnan jtamagnan changed the title Add #'projectile-track-knonw-projects-find-file-hook to 'buffer-list-update-hook Add #'projectile-track-known-projects-find-file-hook to 'buffer-list-update-hook Jun 21, 2024
@jtamagnan jtamagnan force-pushed the buffer-list-update-hook-approach branch from 1c42b25 to 93f3b14 Compare June 21, 2024 21:22
@jtamagnan jtamagnan force-pushed the buffer-list-update-hook-approach branch 3 times, most recently from c16d5c9 to 451e648 Compare June 28, 2024 18:43
@jtamagnan jtamagnan force-pushed the buffer-list-update-hook-approach branch from 451e648 to f0bedae Compare June 28, 2024 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant