From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gabriel Newsgroups: gmane.emacs.bugs Subject: bug#59502: 29.0.50; [PATCH] Dedicated buffers per project Date: Wed, 23 Nov 2022 02:11:36 -0300 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23411"; mail-complaints-to="usenet@ciao.gmane.io" To: 59502@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 23 06:12:32 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oxi3j-0005u3-Gj for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 23 Nov 2022 06:12:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oxi3O-0002RU-Vv; Wed, 23 Nov 2022 00:12:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxi3H-0002OL-B2 for bug-gnu-emacs@gnu.org; Wed, 23 Nov 2022 00:12:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxi3G-0005fQ-P9 for bug-gnu-emacs@gnu.org; Wed, 23 Nov 2022 00:12:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oxi3G-0002Sd-L9 for bug-gnu-emacs@gnu.org; Wed, 23 Nov 2022 00:12:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Gabriel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 23 Nov 2022 05:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 59502 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16691803169444 (code B ref -1); Wed, 23 Nov 2022 05:12:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 Nov 2022 05:11:56 +0000 Original-Received: from localhost ([127.0.0.1]:53218 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxi39-0002SF-DK for submit@debbugs.gnu.org; Wed, 23 Nov 2022 00:11:56 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:42722) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxi34-0002S4-5K for submit@debbugs.gnu.org; Wed, 23 Nov 2022 00:11:53 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxi33-0002Mx-WA for bug-gnu-emacs@gnu.org; Wed, 23 Nov 2022 00:11:50 -0500 Original-Received: from mail-mw2nam12olkn2083.outbound.protection.outlook.com ([40.92.23.83] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxi31-0005dJ-8n for bug-gnu-emacs@gnu.org; Wed, 23 Nov 2022 00:11:49 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YpeBVvzNPCk3E/AKwpSra5PeU4gUafxTGLR/4HjXgWDj+Fg1VQhYit3bLH9WWpHXEQ/vyGaWXomyTR5NJylu4qvE7/uwZiKtSVGh/Xr7bMH2pnsjszHaDg/XipBWbGjX2rbPoGgEctiMRpjl5/v8Zg8wDaokzFesy0aQJLAWevm5SB0dAxkUxZe0cbBBVfDw/cxhFGRLta8vAkQAadcfMC8X39LazQ2vjllPODoQBkOCY+Y2qU01VZI5fjiHblim791GNgSCORNBbYMKBEdKU93+UW9vDcKJIESHz71IVZVFGvUbrSJXQ6ws8wMoUtE4TEsaVYZgVyG4R//ZNLa3OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5v6pkJqSNzBEbdeWN7Z/uH16O3Von6voqZbQtABJvXo=; b=Ehx0ONFDsNlvC361J1Zei4Uah1HpxnXlPCt/jrvv7DvrFWcYx50+grkVpjJFdlgOK1nScmaChzu2TvP8R7+BQ3WhrXfTV3JVWGLevFiBNIBLEVbSXqRhdZv0GL2tUs3l3aGtoeaBAqcrDyu/uX7nHYGVnQOZAQgMal6joo/1jt9/zg4nx/toPWbg69Izyvy8jTyjZMZbAlqkNYocmyNoKGQZ9aQwQdlmktNmjWGavIDdgJ0mVktEI2hR4nhvi4cT6Sv7uEkUJE9t6DD4qw2XQbOmVhVVbXvKfuLowVCFS28lyKdgkPX0TJ1y/dPtF3K5YamBZKhqcSxRmYHPQQ6K7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5v6pkJqSNzBEbdeWN7Z/uH16O3Von6voqZbQtABJvXo=; b=j6oawAxH/6Q0hu7RoMChk9GB8vS+p+8Q0zvcp/XJ54xRsyo7jQhCaHM+m+I13ZqV8USpaULfP1KoXgLnYQ8zoUVSEHlcm01sBwF+y/zq8LNCitzjRD99SsaX/PNN/rAeWMCQuxKZQn8AyxDAVoHiFFKGs39ZtbLLFmgXftTi2dNFMFNfvV55JGXhl1vTB2TAfx1+NtszKx0Cn8kYtQjPialVS6ZC508hXT55QXoYHsztzq6jcG8NCFZaFO6teztED9NUqYCcT4OTyU88HZujQb6+UsrP91XDITH598CEb5j50uaZjXAarqTwwsX+oRXsINMUEBqOvCKpkxMLd+JSeA== Original-Received: from SJ0PR06MB8609.namprd06.prod.outlook.com (2603:10b6:a03:40c::11) by MWHPR06MB2909.namprd06.prod.outlook.com (2603:10b6:300:11d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.17; Wed, 23 Nov 2022 05:11:41 +0000 Original-Received: from SJ0PR06MB8609.namprd06.prod.outlook.com ([fe80::33ae:d3a7:24ae:5c6f]) by SJ0PR06MB8609.namprd06.prod.outlook.com ([fe80::33ae:d3a7:24ae:5c6f%4]) with mapi id 15.20.5857.017; Wed, 23 Nov 2022 05:11:41 +0000 X-TMN: [01O3SeMMhuknMLp+ymPZwGuBuEEGuZTXJhJ5lX0nVkxLNzgCD3TG1U/r8+vZZN3l] X-ClientProxiedBy: CP6P284CA0003.BRAP284.PROD.OUTLOOK.COM (2603:10d6:103:1aa::12) To SJ0PR06MB8609.namprd06.prod.outlook.com (2603:10b6:a03:40c::11) X-Microsoft-Original-Message-ID: <87wn7mcl13.fsf@hotmail.com> X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR06MB8609:EE_|MWHPR06MB2909:EE_ X-MS-Office365-Filtering-Correlation-Id: c4825c33-471c-4ff8-23d3-08dacd1134d3 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L1mOdbwoVmwLfOBVg5GC1KrUtLlmfVFDdXXUEOL6XNvNaGI+S8+80Ai1lt6Iy6gUsoZW/syeEVCYNGipHObMJaz58Jkwp/g6msDQ1t+VJpCW0fAQjHO6L35P9COiqFXX/lUqOMXJunexsqvXcQv+tE9BfST5Iv6QBUTcmiKzJochsRk5U2QFthePHbI7VqQ2RChJsMHf+vx8mSdyR9LaaGPelLurxig5ACzFGQzc6iCN5+qVJBT2JF/cXigP1LKX2pHF7xzo/Gg/60mlIXcDqsyrBQeKm9qE37uG1fbnioO7lDu3Kpz0vkg2FjGpL9idTAueYXLaLa90+YSV+tAR2j6vHZFmtbuPyxPKyJyyVbayEfMEbaAw6TiniQi5b5iRGzAqk/fiSS6LPOfZgWmhu8Zj7KKu36SE2xhOKZ4ImzCTmxG1oO/hohrK54Hid8cdAimDpbMuunu5/lOIehJfeWamcJNKphI8w9cJ2gKFlTbsNxwW6I+gXCz26s+Nwy8/Ms9Pg8OmdZL222oDLUWpYW0Vq/1XYB48bs4I+B9ULwMgVj4/Pzm4QGu988UK1XjeyXHPf6GWVeDGMxNX+ktngm13x/pthgwmuHjO07UbtFA= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XDs4zirakfyPZ2WIs3svliS28Ahm4eZmrXToidEahohb1zppc7sC52Iwp09qgLkpaBW0n5VkMEUcOFTS3qsonL69uMtRXmmRI050Y6vucrw+pvJEewDQaw3MHICiOKVU9UlnJnqUjD4nZTIz0IKQWWsmX3RhMg1ckXPWE8r3p+2CwXlcMODcnPL15JX96Vu7lGOqLhUZVneQMHUV0OvZdCmkFcVj7ohW0Y2KLkDvF+gU7YpGs0qbaIETQVAZ0qi3ey4cb09wFe+yx60F1mrMYBDdT9CDAAciXTHfCqqsHvMCTx8J6X7nxkh11tXV1OANdSoIlM1S33svGXaXOMQW3sv7rNRMM9mrw1wvIEzwU0/gu5Kesxn8tRh3NLVW5S3So3faW9KFEaoNfhGqxqcWoefEg88jXjQsbfgOb8fogo1/SD0yMLd74aLGkiYC+7rkxCj3hjsZMgPzHt8g9judU5lOH+KEykr+X7J5KT2iigKpnY0b5ECkWUtQuAXmM+Wmmn1pYqmr9774JxfCiI7f++lmpTcnipfVuGm4J010EH/9TZ2Vw91jrNAJM8ITXydoV3AoetQ8c+ZzeV7yWZnqDb4TRs3+qjJ0g93APswPGNKy8xJoEjFiv9tVDlpwL4T+O5x0Y4n7cS6qg1jmJPJM5/tLXNWMUVMeJHP4LmRxMDpq53vbSTVwQMCBha+tcWNqNRgrFwOX75xjwnmIefHsPQnBTkG/prsy4vU/5hmkB1+im7GWlwlUCMQUyR phLTA38pGhTChsjQHWPSfta0Vgd02x8asphOUXep4bLTmoO/1AfsK9MKBcmKpQepro4pBpFxvhaFlCiJDkFU/1dT+fMwtrndv5 X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-89723.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: c4825c33-471c-4ff8-23d3-08dacd1134d3 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR06MB8609.namprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 05:11:41.7939 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR06MB2909 Received-SPF: pass client-ip=40.92.23.83; envelope-from=gabriel376@hotmail.com; helo=NAM12-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:248707 Archived-At: --=-=-= Content-Type: text/plain Severity: wishlist Description: Currently, xref commands in project.el (`project-find-regexp' and `project-or-external-find-regexp') use a "default" xref buffer (through a call to `xref-show-xrefs'). It's a "default" buffer because it uses a constant name ("*xref*") for the xref buffers created (see `xref-buffer-name'). If a user is working with two or more projects, any xref command will override a previous "*xref*" buffer. Thus, it's required that the user first manually rename any existing xref buffer prior to executing a new xref command, in order to keep the xref buffers of other projects. The same is true for "*Buffer List*", "*Shell Command Output*" and "*Async Shell Command*" buffers. Currently, project.el already support prefix names for compilation, shell and eshell commands (see `project-prefixed-buffer-name' and `project-compilation-buffer-name-function'). The "*vc-dir*" buffer created by `project-vc-dir' is handled by uniquify.el (`vc-dir-prepare-status-buffer' uses `create-file-buffer'). In summary, project.el currently has the following behavior and customization options: | Project Command | Generated Buffer | Current Behavior | Customization Options | |-----------------------------------+--------------------------+-------------------------------+--------------------------------------------| | `project-find-regexp' | "*xref*" | Use a default buffer | Not available | | `project-or-external-find-regexp' | "*xref*" | Use a default buffer | Not available | | `project-list-buffers' | "*Buffer List*" | Use a default buffer | Not available | | `project-kill-buffers' | "*Buffer List*" | Use a default buffer | Not available | | `project-shell-command' | "*Shell Command Output*" | Use a default buffer | Not available | | `project-async-shell-command' | "*Async Shell Command*" | Use a default buffer | Not available | | `project-compile` | "*compilation*" | Use a default buffer | `project-compilation-buffer-name-function' | | `project-vc-dir' | "*vc-dir*" | Use a default buffer | Through uniquify.el defcustom's | | `project-shell' | "*shell*" | Use a project prefixed buffer | Not available | | `project-eshell' | "*eshell*" | Use a project prefixed buffer | Not available | My suggestion is to improve the consistency of how project-related buffers are created and named, providing sufficient customization options for users. Solutions: 1) Make all project-related buffers use by default `project-prefixed-buffer-name'. This is similar to how `project-shell' and `project-eshell' behaves today. The downsides are the lack of customization options for users and the introduction of behavior changes related to how some project-related buffers are currently named. 2) Create dedicated defcustom's for each project-related buffer. This is similar to how `project-compile' behaves today, by allowing users to customize the option `project-compilation-buffer-name-function'. The downside is the excessive number of new defcustom's. 3) Create a single defcustom to compute the name of project-related buffers. This is similar to how `project-compile' behaves today, but would be a more general-purpose customization option. This is currently my preferred solution (see the attached patch). I tried to make it simple, consistent and without introducing behavior changes related to how project-related buffers are currently named, but I am not really happy with the implementation. An example of how users could customize this option is presented below: (setopt project-buffer-name-function (lambda (name) (format "*%s-%s*" (project-name (project-current)) name))) --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-user-option-project-buffer-name-function.patch >From 1bd545fac60f955c1d8b6de2db3a0aca6b9d32c5 Mon Sep 17 00:00:00 2001 From: Gabriel do Nascimento Ribeiro Date: Wed, 23 Nov 2022 01:50:21 -0300 Subject: [PATCH 1/1] Add user option `project-buffer-name-function' * lisp/buff-menu.el (Buffer-menu-buffer-name): New constant to store the default buffer name. (list-buffers-noselect): Use the new constant. * lisp/vc/vc-dir.el (vc-dir-buffer-name): New constant to store the default buffer name. (vc-dir): Use the new constant. * lisp/progmodes/project.el (project-buffer-name-function): New user option to allow customization of project-related buffer names. (project-compilation-buffer-name-function): Make obsolete. (project-buffer-name-default): New function to compute the name of project-related buffers. (project-find-regexp, project-or-external-find-regexp, project-vc-dir) (project-shell, project-eshell, project-async-shell-command) (project-shell-command, project-compile, project-list-buffers) (project-kill-buffers): Use the new user option `project-buffer-name-function' to compute the buffer name. * etc/NEWS: Announce the changes. --- etc/NEWS | 8 +++++ lisp/buff-menu.el | 7 +++-- lisp/progmodes/project.el | 65 ++++++++++++++++++++++++++++++--------- lisp/vc/vc-dir.el | 7 ++++- 4 files changed, 69 insertions(+), 18 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 5a65896d69..b3e1b5e3c4 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2263,6 +2263,14 @@ matches. --- *** New function 'xref-show-xrefs'. ++++ +*** New user option 'project-buffer-name-function'. +This control the name of project-related buffers. + +--- +*** 'project-compilation-buffer-name-function' is now obsolete. +Use the new user option 'project-buffer-name-function' instead. + ** File notifications +++ diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el index aa5f70edf2..e6b91682dd 100644 --- a/lisp/buff-menu.el +++ b/lisp/buff-menu.el @@ -95,6 +95,9 @@ Buffer-menu-use-frame-buffer-list :group 'Buffer-menu :version "22.1") +(defconst Buffer-menu-buffer-name "*Buffer List*" + "Name of the output buffer for `buffer-menu' and related commands.") + (defvar-local Buffer-menu-files-only nil "Non-nil if the current Buffer Menu lists only file buffers. This is set by the prefix argument to `buffer-menu' and related @@ -634,11 +637,11 @@ list-buffers-noselect that filters out buffers from the list of buffers. See more at `Buffer-menu-filter-predicate'." (let ((old-buffer (current-buffer)) - (buffer (get-buffer-create "*Buffer List*"))) + (buffer (get-buffer-create Buffer-menu-buffer-name))) (with-current-buffer buffer (Buffer-menu-mode) (setq Buffer-menu-files-only - (and files-only (>= (prefix-numeric-value files-only) 0))) + (and files-only (>= (prefix-numeric-value files-only) 0))) (setq Buffer-menu-filter-predicate filter-predicate) (list-buffers--refresh buffer-list old-buffer) (tabulated-list-print)) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 751e240a56..d706bd128f 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -818,7 +818,8 @@ project-find-regexp caller-dir nil t))) (project--files-in-directory dir nil - (grep-read-files regexp)))))) + (grep-read-files regexp))))) + (xref-buffer-name (funcall project-buffer-name-function "xref"))) (xref-show-xrefs (apply-partially #'project--find-regexp-in-files regexp files) nil))) @@ -846,7 +847,8 @@ project-or-external-find-regexp (files (project-files pr (cons (project-root pr) - (project-external-roots pr))))) + (project-external-roots pr)))) + (xref-buffer-name (funcall project-buffer-name-function "xref"))) (xref-show-xrefs (apply-partially #'project--find-regexp-in-files regexp files) nil))) @@ -1024,7 +1026,8 @@ project-dired (defun project-vc-dir () "Run VC-Dir in the current project's root." (interactive) - (vc-dir (project-root (project-current t)))) + (let ((vc-dir-buffer-name (funcall project-buffer-name-function "vc-dir"))) + (vc-dir (project-root (project-current t))))) (declare-function comint-check-proc "comint") @@ -1038,13 +1041,13 @@ project-shell (interactive) (require 'comint) (let* ((default-directory (project-root (project-current t))) - (default-project-shell-name (project-prefixed-buffer-name "shell")) - (shell-buffer (get-buffer default-project-shell-name))) + (buffer-name (funcall project-buffer-name-function "shell")) + (shell-buffer (get-buffer buffer-name))) (if (and shell-buffer (not current-prefix-arg)) (if (comint-check-proc shell-buffer) (pop-to-buffer shell-buffer (bound-and-true-p display-comint-buffer-action)) (shell shell-buffer)) - (shell (generate-new-buffer-name default-project-shell-name))))) + (shell (generate-new-buffer-name buffer-name))))) ;;;###autoload (defun project-eshell () @@ -1056,7 +1059,7 @@ project-eshell (interactive) (defvar eshell-buffer-name) (let* ((default-directory (project-root (project-current t))) - (eshell-buffer-name (project-prefixed-buffer-name "eshell")) + (eshell-buffer-name (funcall project-buffer-name-function "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)) @@ -1067,7 +1070,9 @@ project-async-shell-command "Run `async-shell-command' in the current project's root directory." (declare (interactive-only async-shell-command)) (interactive) - (let ((default-directory (project-root (project-current t)))) + (let ((default-directory (project-root (project-current t))) + (shell-command-buffer-name-async (funcall project-buffer-name-function + "Async Shell Command"))) (call-interactively #'async-shell-command))) ;;;###autoload @@ -1075,7 +1080,9 @@ project-shell-command "Run `shell-command' in the current project's root directory." (declare (interactive-only shell-command)) (interactive) - (let ((default-directory (project-root (project-current t)))) + (let ((default-directory (project-root (project-current t))) + (shell-command-buffer-name (funcall project-buffer-name-function + "Shell Command Output"))) (call-interactively #'shell-command))) (declare-function fileloop-continue "fileloop" ()) @@ -1136,6 +1143,32 @@ project-compilation-buffer-name-function (const :tag "Prefixed with root directory name" project-prefixed-buffer-name) (function :tag "Custom function"))) +(make-obsolete-variable 'project-compilation-buffer-name-function + 'project-buffer-name-function + "29.1") + +(defcustom project-buffer-name-function 'project-buffer-name-default + "Function to compute the name of a project buffer. +Function receives one argument, the base buffer name as string. +It should return the buffer name as string." + :version "29.1" + :group 'project + :type 'function) + +(defun project-buffer-name-default (name) + "Function to compute buffer names for project commands." + (pcase name + ("compilation" (compilation--default-buffer-name name)) + ("shell" (project-prefixed-buffer-name name)) + ("eshell" (project-prefixed-buffer-name name)) + ("Shell Command Output" shell-command-buffer-name) + ("Async Shell Command" shell-command-buffer-name-async) + ("Buffer List" Buffer-menu-buffer-name) + ("xref" xref-buffer-name) + ("vc-dir" vc-dir-buffer-name) + (t (format "*%s-%s*" + (project-name (project-current)) + name)))) ;;;###autoload (defun project-compile () @@ -1143,9 +1176,9 @@ project-compile (declare (interactive-only compile)) (interactive) (let ((default-directory (project-root (project-current t))) - (compilation-buffer-name-function - (or project-compilation-buffer-name-function - compilation-buffer-name-function))) + (compilation-buffer-name-function (lambda (_) + (funcall project-buffer-name-function + "compilation")))) (call-interactively #'compile))) (defcustom project-ignore-buffer-conditions nil @@ -1231,13 +1264,13 @@ project-display-buffer-other-frame ;;;###autoload (defun project-list-buffers (&optional arg) "Display a list of project buffers. -The list is displayed in a buffer named \"*Buffer List*\". By default, all project buffers are listed except those whose names start with a space (which are for internal use). With prefix argument ARG, show only buffers that are visiting files." (interactive "P") - (let ((pr (project-current t))) + (let ((pr (project-current t)) + (Buffer-menu-buffer-name (funcall project-buffer-name-function "Buffer List"))) (display-buffer (if (version< emacs-version "29.0.50") (let ((buf (list-buffers-noselect arg (project-buffers pr)))) @@ -1365,6 +1398,8 @@ project-kill-buffers (interactive) (let* ((pr (project-current t)) (bufs (project--buffers-to-kill pr)) + (Buffer-menu-buffer-name (funcall project-buffer-name-function + "Buffer List")) (query-user (lambda () (yes-or-no-p (format "Kill %d buffers in %s? " @@ -1377,7 +1412,7 @@ project-kill-buffers (project-kill-buffers-display-buffer-list (when (with-current-buffer-window - (get-buffer-create "*Buffer List*") + (get-buffer-create Buffer-menu-buffer-name) `(display-buffer--maybe-at-bottom (dedicated . t) (window-height . (fit-window-to-buffer)) diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 037de415e6..ff7ac2e025 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -118,6 +118,10 @@ vc-dir-status-ignored ;; To distinguish files and directories. directory) +;;;###autoload +(defconst vc-dir-buffer-name "*vc-dir*" + "Name of the output buffer for `vc-dir' command.") + (defvar vc-ewoc nil) (defvar vc-dir-process-buffer nil @@ -1446,7 +1450,8 @@ vc-dir (unless backend (setq backend (vc-responsible-backend dir))) (let (pop-up-windows) ; based on cvs-examine; bug#6204 - (pop-to-buffer (vc-dir-prepare-status-buffer "*vc-dir*" dir backend))) + (pop-to-buffer (vc-dir-prepare-status-buffer vc-dir-buffer-name + dir backend))) (if (derived-mode-p 'vc-dir-mode) (vc-dir-refresh) ;; FIXME: find a better way to pass the backend to `vc-dir-mode'. -- 2.34.1 --=-=-= Content-Type: text/plain Please share your comments or suggestions. --- Gabriel --=-=-=--