* bug#62548: [PATCH] project.el: Use project-name to calculate prefixed buffer name
@ 2023-03-30 18:35 Spencer Baugh
2023-03-30 20:26 ` Spencer Baugh
0 siblings, 1 reply; 3+ messages in thread
From: Spencer Baugh @ 2023-03-30 18:35 UTC (permalink / raw)
To: 62548
[-- Attachment #1: Type: text/plain, Size: 658 bytes --]
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'
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Use-project-name-to-calculate-prefixed-buffer-name.patch --]
[-- Type: text/patch, Size: 2691 bytes --]
From 2141d988d376cfd6a572a86c77346815c45cc686 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@janestreet.com>
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#62548: [PATCH] project.el: Use project-name to calculate prefixed buffer name
2023-03-30 18:35 bug#62548: [PATCH] project.el: Use project-name to calculate prefixed buffer name Spencer Baugh
@ 2023-03-30 20:26 ` Spencer Baugh
2023-04-09 1:54 ` Dmitry Gutov
0 siblings, 1 reply; 3+ messages in thread
From: Spencer Baugh @ 2023-03-30 20:26 UTC (permalink / raw)
To: 62548
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")))
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#62548: [PATCH] project.el: Use project-name to calculate prefixed buffer name
2023-03-30 20:26 ` Spencer Baugh
@ 2023-04-09 1:54 ` Dmitry Gutov
0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Gutov @ 2023-04-09 1:54 UTC (permalink / raw)
To: Spencer Baugh, 62548-done
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-09 1:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-30 18:35 bug#62548: [PATCH] project.el: Use project-name to calculate prefixed buffer name Spencer Baugh
2023-03-30 20:26 ` Spencer Baugh
2023-04-09 1:54 ` Dmitry Gutov
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).