Open xuanni opened 3 years ago
Looking at the code it seems this should generate unique names:
(defun projectile-run-eshell (&optional arg)
"Invoke `eshell' in the project's root.
Switch to the project specific eshell buffer if it already exists.
Use a prefix argument ARG to indicate creation of a new process instead."
(interactive "P")
(let ((project (projectile-acquire-root)))
(projectile-with-default-dir project
(let ((eshell-buffer-name (projectile-generate-process-name "eshell" arg project)))
(eshell)))))
I guess I'll have to debug it.
I actually tried looking into this because I've been wanting to throw in some PRs to work on my elisp, but I'm not able to reproduce. I'm using the latest melpa version, opened a file in project 1, opened a file in project 2, did projectile-find-file
to make sure it was picking up the two different projects, then did projectile-run-eshell
while on the file for project 1, it opened in the correct dir, switched to the file for project 2, ran projectile-run-eshell
again, and it opened up a new eshell buffer in the correct dir for project 2.
Info: OS: Manjaro Emacs version: 27.2 Projectile version: 20210930.1757 (melpa)
Looking at the code it seems this should generate unique names:
(defun projectile-run-eshell (&optional arg) "Invoke `eshell' in the project's root. Switch to the project specific eshell buffer if it already exists. Use a prefix argument ARG to indicate creation of a new process instead." (interactive "P") (let ((project (projectile-acquire-root))) (projectile-with-default-dir project (let ((eshell-buffer-name (projectile-generate-process-name "eshell" arg project))) (eshell)))))
I guess I'll have to debug it.
I did some search and used "edebug-defun" to step through the code, looks like in the below snippet, the (base-name (format ... was returning "src" but there is already a < eshell src >, so I guess it jumps to the existing one, instead of creating a new one. I think this base-name call needs another check if it is the same project considering the abs path not just the base dirname. However, I am not an elisp expert.
(defun projectile-generate-process-name (process make-new &optional project) "Infer the buffer name for PROCESS or generate a new one if MAKE-NEW is true. The function operates on the current project by default, but you can also specify a project explicitly via the optional PROJECT param." (let* ((project (or project (projectile-acquire-root))) (base-name (format "*%s %s*" process (projectile-project-name project)))) ;; ==> this base-name is returning "src" (if make-new (generate-new-buffer-name base-name) base-name)))
I actually tried looking into this because I've been wanting to throw in some PRs to work on my elisp, but I'm not able to reproduce. I'm using the latest melpa version, opened a file in project 1, opened a file in project 2, did
projectile-find-file
to make sure it was picking up the two different projects, then didprojectile-run-eshell
while on the file for project 1, it opened in the correct dir, switched to the file for project 2, ranprojectile-run-eshell
again, and it opened up a new eshell buffer in the correct dir for project 2.Info: OS: Manjaro Emacs version: 27.2 Projectile version: 20210930.1757 (melpa)
In order to reproduce this, you need two projects with the same base folder name. Namely, /project1/same_name/ and /project2/same_name. In other words, the two projects have the same root folder name but are stored differently in your file system.
In order to reproduce this, you need two projects with the same base folder name. Namely, /project1/same_name/ and /project2/same_name. In other words, the two projects have the same root folder name but are stored differently in your file system.
You can easily customize the behavior of the project name function to solve this name conflict. I personally also prefer the organisation/project name-style:
(setq projectile-project-name-function (lambda (project-root)
(let ((default-directory project-root))
(file-relative-name (directory-file-name project-root) "../.."))))
Expected behavior
projectile-run-eshell opens a new eshell buffer for every different project
Actual behavior
If an eshell buffer is opened, another eshell command for another project with similar path will only jump to this existing one instead of opening a new one
Steps to reproduce the problem
Create 2 git projects with paths: project 1: /path/to/project1/src/.git project 2: /path/to/project2/src/.git
Inside project 1, M-x projectile-run-eshell, opens a new eshell buffer. Now go to project 2, M-x projectile-run-eshell, instead of opening a new eshell buffer, it jumps to the old eshell buffer.
Environment & Version information
Projectile version information
2.6.0
Emacs version
27.2
Operating system
ubuntu 18.04