From cf685f8f9f2aa2628b1be65f640dee65219b55a1 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Fri, 6 Jun 2025 05:38:55 +0300 Subject: [PATCH] project-switch-to-buffer: Don't disambiguate too much * lisp/progmodes/project.el (project--read-project-buffer): Use the new function from 'uniquify' to generate buffer names that are just unique to the current project, not globally (bug#77312). (cherry picked from commit 1c465fc0879b68b1cd7a05c033f6bb82fd5fa3aa) --- lisp/progmodes/project.el | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index b551e8b06fb..61694c3ec6a 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1488,13 +1488,28 @@ general form of conditions." (and (memq (cdr buffer) buffers) (not (project--buffer-check - (cdr buffer) project-ignore-buffer-conditions))))) - (buffer (read-buffer - "Switch to buffer: " - (when (funcall predicate (cons other-name other-buffer)) - other-name) - nil - predicate))) + buffer project-ignore-buffer-conditions))))) + (buffer + (if (and (fboundp 'uniquify-get-unique-names) + uniquify-buffer-name-style) + ;; Forgo the use of `buffer-read-function' (often nil) in + ;; favor of uniquifying the buffers better. + (let* ((unique-names (uniquify-get-unique-names buffers)) + (other-name (when (funcall predicate (cons other-name other-buffer)) + (car (rassoc other-buffer unique-names)))) + (result (completing-read + "Switch to buffer: " + unique-names + predicate + nil nil nil + other-name))) + (assoc-default result unique-names #'equal result)) + (read-buffer + "Switch to buffer: " + (when (funcall predicate (cons other-name other-buffer)) + other-name) + nil + predicate)))) ;; XXX: This check hardcodes the default buffer-belonging relation ;; which `project-buffers' is allowed to override. Straighten ;; this up sometime later. Or not. Since we can add a method -- 2.39.5