Subject: bug#62548: closed (Re: bug#62548: [PATCH] project.el: Use project-name to calculate prefixed buffer name)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 09 Apr 2023 01:55:02 +0000

Your bug report

#62548: [PATCH] project.el: Use project-name to calculate prefixed buffer name

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
62548: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62548
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#62548: [PATCH] project.el: Use project-name to calculate prefixed buffer name
From: Dmitry Gutov <[email-masked]>
To: Spencer Baugh <[email-masked]>, [email-masked]
Date: Sun, 9 Apr 2023 04:54:02 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

Version: 30.1

On 30/03/2023 23:26, Spencer Baugh wrote:
> My apologies, my first patch was buggy.  A working patch follows.
> 
> * lisp/progmodes/project.el (project-prefixed-buffer-name):
> Use project-name to calculate prefixed buffer name
> (project-compilation-buffer-name-function):
> Update doc.
> ---
>   lisp/progmodes/project.el | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
> index 11228226592..877d79353aa 100644
> --- a/lisp/progmodes/project.el
> +++ b/lisp/progmodes/project.el
> @@ -1248,8 +1248,10 @@ compilation-read-command
>   
>   (defun project-prefixed-buffer-name (mode)
>     (concat "*"
> -          (file-name-nondirectory
> -           (directory-file-name default-directory))
> +          (if-let ((proj (project-current nil)))
> +              (project-name proj)
> +            (file-name-nondirectory
> +             (directory-file-name default-directory)))
>             "-"
>             (downcase mode)
>             "*"))
> @@ -1261,7 +1263,7 @@ project-compilation-buffer-name-function
>     :version "28.1"
>     :group 'project
>     :type '(choice (const :tag "Default" nil)
> -                 (const :tag "Prefixed with root directory name"
> +                 (const :tag "Prefixed with project name"
>                           project-prefixed-buffer-name)
>                    (function :tag "Custom function")))

Thanks! I've pushed it to master.

Subject: [PATCH] project.el: Use project-name to calculate prefixed buffer name
From: Spencer Baugh <[email-masked]>
To: [email-masked]
Date: Thu, 30 Mar 2023 14:35:53 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Tags: patch

project.el: Use project-name to calculate prefixed buffer name.  This
makes the name more easily customizable and works better for projects
which don't have a meaningful last directory component.

In GNU Emacs 29.0.60 (build 3, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.15.12, Xaw scroll bars) of 2023-03-13 built on
 igm-qws-u22796a
Repository revision: e759905d2e0828eac4c8164b09113b40f6899656
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: CentOS Linux 7 (Core)

Configured using:
 'configure --with-x-toolkit=lucid --with-modules
 --with-gif=ifavailable'

>From 2141d988d376cfd6a572a86c77346815c45cc686 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <[email-masked]>
Date: Thu, 30 Mar 2023 14:34:29 -0400
Subject: [PATCH] Use project-name to calculate prefixed buffer name

* lisp/progmodes/project.el (project-prefixed-buffer-name):
(project-shell):
(project-eshell):
Use project-name to calculate prefixed buffer name
(project-compilation-buffer-name-function):
Update doc.
---
 lisp/progmodes/project.el | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 11228226592..6d058edf878 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1165,8 +1165,9 @@ project-shell
 if one already exists."
   (interactive)
   (require 'comint)
-  (let* ((default-directory (project-root (project-current t)))
-         (default-project-shell-name (project-prefixed-buffer-name "shell"))
+  (let* ((pr (project-current t))
+         (default-directory (project-root pr))
+         (default-project-shell-name (project-prefixed-buffer-name pr "shell"))
          (shell-buffer (get-buffer default-project-shell-name)))
     (if (and shell-buffer (not current-prefix-arg))
         (if (comint-check-proc shell-buffer)
@@ -1183,8 +1184,9 @@ project-eshell
 if one already exists."
   (interactive)
   (defvar eshell-buffer-name)
-  (let* ((default-directory (project-root (project-current t)))
-         (eshell-buffer-name (project-prefixed-buffer-name "eshell"))
+  (let* ((pr (project-current t))
+         (default-directory (project-root pr))
+         (eshell-buffer-name (project-prefixed-buffer-name pr "eshell"))
          (eshell-buffer (get-buffer eshell-buffer-name)))
     (if (and eshell-buffer (not current-prefix-arg))
         (pop-to-buffer eshell-buffer (bound-and-true-p display-comint-buffer-action))
@@ -1246,10 +1248,9 @@ project-query-replace-regexp
 (defvar compilation-read-command)
 (declare-function compilation-read-command "compile")
 
-(defun project-prefixed-buffer-name (mode)
+(defun project-prefixed-buffer-name (pr mode)
   (concat "*"
-          (file-name-nondirectory
-           (directory-file-name default-directory))
+          (project-name pr)
           "-"
           (downcase mode)
           "*"))
@@ -1261,7 +1262,7 @@ project-compilation-buffer-name-function
   :version "28.1"
   :group 'project
   :type '(choice (const :tag "Default" nil)
-                 (const :tag "Prefixed with root directory name"
+                 (const :tag "Prefixed with project name"
                         project-prefixed-buffer-name)
                  (function :tag "Custom function")))
 
-- 
2.30.2