aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.dev>2026-02-15 17:07:42 +0200
committerBozhidar Batsov <bozhidar@batsov.dev>2026-02-15 17:07:42 +0200
commit59ec87e4aeaed623f1928ed1f948c50b26372fcb (patch)
tree4447fe46decb53826da40a9bd7c3caffb4789550
parentdd06dfd912656d41f2c63066aa8bacb898ddf7a2 (diff)
Disambiguate process buffer names for same-named projectsfeature/1815-disambiguate-buffer-names
Fixes #1815 Fixes #1715 When two projects share the same name (e.g. both named "src"), projectile-generate-process-name now detects the collision and falls back to using the abbreviated project path in the buffer name instead of just the project name.
-rw-r--r--projectile.el12
1 files changed, 11 insertions, 1 deletions
diff --git a/projectile.el b/projectile.el
index 6c5306b..23f2458 100644
--- a/projectile.el
+++ b/projectile.el
@@ -1013,7 +1013,17 @@ just return nil."
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))))
+ (name (projectile-project-name project))
+ (base-name (format "*%s %s*" process name))
+ ;; When a buffer with the same name already exists but belongs to a
+ ;; different project root, disambiguate using the project path.
+ (base-name (if (and (not make-new)
+ (let ((buf (get-buffer base-name)))
+ (and buf
+ (not (string= (with-current-buffer buf default-directory)
+ project)))))
+ (format "*%s %s*" process (abbreviate-file-name project))
+ base-name)))
(if make-new
(generate-new-buffer-name base-name)
base-name)))