From unknown Mon Jun 16 23:47:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#76500: [PATCH] Allow numbered buffer selection for project shell commands Resent-From: Paul Nelson Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 23 Feb 2025 11:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 76500 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 76500@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.174030934132052 (code B ref -1); Sun, 23 Feb 2025 11:16:02 +0000 Received: (at submit) by debbugs.gnu.org; 23 Feb 2025 11:15:41 +0000 Received: from localhost ([127.0.0.1]:59567 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tm9xU-0008Kt-Ah for submit@debbugs.gnu.org; Sun, 23 Feb 2025 06:15:40 -0500 Received: from lists.gnu.org ([2001:470:142::17]:51960) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tm9xS-0008Kc-7q for submit@debbugs.gnu.org; Sun, 23 Feb 2025 06:15:39 -0500 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 1tm9xK-0002UD-0a for bug-gnu-emacs@gnu.org; Sun, 23 Feb 2025 06:15:30 -0500 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tm9xH-0002Cn-Nf for bug-gnu-emacs@gnu.org; Sun, 23 Feb 2025 06:15:29 -0500 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-5452efeb87aso3575076e87.3 for ; Sun, 23 Feb 2025 03:15:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740309322; x=1740914122; darn=gnu.org; h=mime-version:date:message-id:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=Q34uuHOXBReTgPJfveM2Qs8ofpxlJm1MBhFdmy9WHUE=; b=VTfKy5S83C2GDI0xyZyUy8iipd9RBbOZtqeLlQtNTnt1S31ZDqdX98QY7L8dACluGe fsM9Gw1UW0E/jtyau3s9+LK+SqdtTYfuMpBDrPSUFz/dqvwobAsMwWsF98nm/TtHXFAI qyh59dgHg48wBC3+cWarUKgeoF18r+WlP1QdcGZMjIhSie/5LhbdLKp9TsaTwcGwr316 mgWTnr/WwzMjLrRsiUgelsjULHDyURpBLcpsNfbSi1uVfoMn5Et9ncWqh/96N5ucl9g7 sGvGtcu+W4Q4WVw+5rX6FgQTCv8HudprQw7C/AkkVaWtF6cDkOTrzEtc+THE2iiuXS2a 0Rqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740309322; x=1740914122; h=mime-version:date:message-id:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Q34uuHOXBReTgPJfveM2Qs8ofpxlJm1MBhFdmy9WHUE=; b=NVMnW5Ctban8p62/ypACyPT/cbO4rty7GziSGE6TCpi/Ch0W2LJYxpV4McJVFnfSoJ a5hbnU/7jCibBDqGqUfAWSoD8p5wl4hcHVXFSRFZpHPaXM86s7z16RPo5MIfF4BeUh9A rfPvPOOBxUvDcR6j6B9qrWA+B4qOP1wYZolSZQPUfveOqBPsQWTQg0UJbdNlunL1j9TF aXbT8nTTyNJbc5LXEfFNlgWfnAfj5nROYp0GaZ8WFO/rPCITfhIvsk3lx35po8DggjgF SGbGD4aCte0jz7rRfg1t8nF2elQEmeX6tBgBj0be7I9QPsp80noYRRZZx4x/X8oWGibz uJNw== X-Gm-Message-State: AOJu0YyjaSEMB2130nZ2UCPYiqjh0fY4ZmixO3YXIdi3n4Wgo5n57ju2 YIx2kyxu6lgeCcQvGmT8YTbZhohOW+Q9TyOTpBSDDSflcon8OnxVx38le+pW X-Gm-Gg: ASbGncuXq22rlAuSc7xzte3P1Nd3ava+7HYaUgKs7wmQ4P8aD2NSBY0cBBYc5YjVY+s IYZRzS8NO97T2kmqcqNOiODTFRw8x80VodijLZFYatsiS7cvSR8UKt9a3OD3ryoxl8iCfKMwjYJ lx+7j2uvYucXgT3EqXCO6qkGo55GRiRvcFKqvPn3j2xvhduszwwckvTjPmSGl6APBB1nxHAZsmH PKXZz0h+S+Rjdmfqq2d7dMrMVkR+gw6qzNaKWll20dSaskch4cew5csP+UhYOPFap/KYyLy+jCj c6G+KF0RWI66JFCpyOo0IHcWbm9A5Vpnrr/23qm/yyawnVCp2SE9R995Rt+e3HUkxgE= X-Google-Smtp-Source: AGHT+IGl1ZpZFH/+TnAFJQOskBG14BTbwLqEDGe9NEi8dHNQ3HDCclwqzm4KPpozwvuJBYoJQ8R5Ew== X-Received: by 2002:a05:6512:1307:b0:545:2a7f:8f79 with SMTP id 2adb3069b0e04-54838ef04b8mr4483679e87.16.1740309321961; Sun, 23 Feb 2025 03:15:21 -0800 (PST) Received: from localhost (0x573d6745.static.cust.fastspeed.dk. [87.61.103.69]) by smtp.gmail.com with UTF8SMTPSA id 2adb3069b0e04-54839796e66sm649805e87.106.2025.02.23.03.15.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Feb 2025 03:15:20 -0800 (PST) From: Paul Nelson Message-ID: Date: Sun, 23 Feb 2025 12:15:18 +0100 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=ultrono@gmail.com; helo=mail-lf1-x129.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable This patch for project.el adds numeric prefix buffer naming to the project-shell and project-eshell commands, aligning their behavior with that of eshell. Without any prefix, these commands switch to or create a shell session. With a plain C-u, the current behavior is to create a new session with an automatically generated numeric suffix (e.g. "*foo-shell<2>*"), but after switching away from that buffer, there=E2=80=99s no convenient way to switch back. This patch changes that: when given a numeric prefix (e.g. C-2), the command will switch to or create the session buffer with the corresponding suffix. Implementation notes: - project-eshell: The current implementation duplicates some functionality provided by eshell. By removing this redundancy, the numeric prefix behavior is inherited "for free". - project-shell: The revised implementation borrows from that of eshell. Any comments or feedback would be welcome. Thanks, best, Paul --=-=-= Content-Type: text/plain Content-Disposition: inline >From 73bb69e0c473668d9d10b5345963f707b8c0dc46 Mon Sep 17 00:00:00 2001 From: Paul Nelson Date: Fri, 21 Feb 2025 11:49:46 +0100 Subject: [PATCH] Allow numbered buffer selection for project shell commands * project.el (project-shell, project-eshell): When a numeric prefix is supplied (e.g. C-2), the command will switch to or create a session buffer whose name is suffixed with that number, e.g. "*name-of-project-shell<2>*". As before, a plain universal argument C-u creates a new session with an automatically generated numeric suffix. This change makes the behavior consistent with eshell's handling of numeric prefixes. * etc/NEWS: Announce the change. --- etc/NEWS | 7 +++++++ lisp/progmodes/project.el | 36 +++++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 82a653c4e1e..2b4efa41488 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -302,6 +302,13 @@ It can be used when switching between projects with similar file trees (such as Git worktrees of the same repository). It supports being invoked standalone or from the 'project-switch-commands' dispatch menu. +--- +*** 'project-shell' and 'project-eshell' support numeric prefix buffer naming. +They now accept numeric prefix arguments to select or create numbered +shell sessions. For example, 'C-2 C-x p s' switches to or creates a +buffer named "*name-of-project-shell<2>*". By comparison, a plain +universal argument as in 'C-u C-x p s' always creates a new session. + ** Registers *** New functions 'buffer-to-register' and 'file-to-register'. diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 35bf66c9ffb..04c202a6232 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1397,36 +1397,46 @@ project-shell "Start an inferior shell in the current project's root directory. If a buffer already exists for running a shell in the project's root, switch to it. Otherwise, create a new shell buffer. -With \\[universal-argument] prefix arg, create a new inferior shell buffer even -if one already exists." + +With a nonnumeric prefix arg, create a new inferior shell buffer even if +one already exists. + +With a numeric prefix arg, switch to the session with that number, or +create it if it doesn't already exist." (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))) + (base-name (project-prefixed-buffer-name "shell")) + (shell-buffer-name + (cond ((numberp current-prefix-arg) + (format "%s<%d>" base-name current-prefix-arg)) + (current-prefix-arg + (generate-new-buffer-name base-name)) + (t base-name))) + (shell-buffer (get-buffer shell-buffer-name))) (if (and shell-buffer (not current-prefix-arg)) (if (comint-check-proc shell-buffer) (pop-to-buffer shell-buffer (append display-buffer--same-window-action '((category . comint)))) (shell shell-buffer)) - (shell (generate-new-buffer-name default-project-shell-name))))) + (shell shell-buffer-name)))) ;;;###autoload (defun project-eshell () "Start Eshell in the current project's root directory. If a buffer already exists for running Eshell in the project's root, switch to it. Otherwise, create a new Eshell buffer. -With \\[universal-argument] prefix arg, create a new Eshell buffer even -if one already exists." + +With a nonnumeric prefix arg, create a new Eshell buffer even if one +already exists. + +With a numeric prefix arg, switch to the session with that number, or +create it if it doesn't already exist." (interactive) (defvar eshell-buffer-name) (let* ((default-directory (project-root (project-current t))) - (eshell-buffer-name (project-prefixed-buffer-name "eshell")) - (eshell-buffer (get-buffer eshell-buffer-name))) - (if (and eshell-buffer (not current-prefix-arg)) - (pop-to-buffer eshell-buffer (append display-buffer--same-window-action - '((category . comint)))) - (eshell t)))) + (eshell-buffer-name (project-prefixed-buffer-name "eshell"))) + (eshell current-prefix-arg))) ;;;###autoload (defun project-async-shell-command () -- 2.39.3 (Apple Git-145) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 24 16:50:18 2025 Received: (at control) by debbugs.gnu.org; 24 Feb 2025 21:50:19 +0000 Received: from localhost ([127.0.0.1]:43130 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tmgLC-0002VH-D5 for submit@debbugs.gnu.org; Mon, 24 Feb 2025 16:50:18 -0500 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]:59580) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tmgL8-0002Qf-0P for control@debbugs.gnu.org; Mon, 24 Feb 2025 16:50:14 -0500 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-5dec996069aso7911051a12.2 for ; Mon, 24 Feb 2025 13:50:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740433808; x=1741038608; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=ZnYcaescRx9NKQeLUmiWPEl8yU5+0EiBJ7dIgn0tkvE=; b=RJwb4yI8wbw5l4vRhaluWOPsTUcNY0NaPA//bAy+d2fbzYwuaUWFgkrzS1o50mf1g7 nhMOcLBODXW23j8JS382TAwA7uB3svRXlPXlbvaqVLjBgKnc75hg5fG5Uk3R8+tPIKno /MGu8eCn5nV92qxIbvXRGUHROys40fM7LPXKbN8he1RRsib4byq4FaPulicL1gxMjFTh 6ZW7WZg9x3uFdyK1u2I3YZ0+wVLuRo1IYgaLF2uuCDm314aSbNKjoYkKCMc9HMjoL9x5 rKuVUC+Lid4tiYRYj3SAISawsiW9mxS0uTvGQnBjWh4lhSvvBiihdVV6OA0kQqc3DSUp zyug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740433808; x=1741038608; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ZnYcaescRx9NKQeLUmiWPEl8yU5+0EiBJ7dIgn0tkvE=; b=ETlYh/PMiD7D9m3To4KmSTfude75c8DaGqdovxBmEHx65J0jj4Fvlmb7mmujjSExVV IJhXS70LCt/XsatSlnYVzX4vP9jpcaQcAUgcCMNAZRy+/V3NyqKeBKlZExdaOa/SIJFz vziK78eBo3ew51jc19pUBPXaMv72wIOTHgGBvBuGRNrisb1avQ8n78Tg98kOlDyyQLdR wGP8QzgAHbU9MqGaVGZkIM8RBX/OtDw4PsMVqT3+OWwW5tLZBjk5z+s480yZNEnvF1mB nUd91bjlKJaIdgBmt+wLgRiYnTfMxgRnVSsU9BcFEfR5ldubB249orBU1mHVX222Y79n FycA== X-Gm-Message-State: AOJu0YzyNs87/zqmmQoFeZ+dEks3sbOliHsJMoXOnCyKS80g6oeYTCCx q50y8rOIpv4zB+oD8cbcgf7INlqDqseX/nt4KFIX4z3IU4vK88IShwEmZP5dqTlSLYdEFHS9fPd GAJLJLZde8HpGjBvx3cMqEokfAGrVCslulUI= X-Gm-Gg: ASbGncuuqHMk/9gQSqXnk7ipBbXXqVG2QuIJoo8Q3UuCFXmp+khlYs12nErQMfwqy7t OSKC9y8y41TSmD/va/nNXRONt6TX6W4Ws1AKbgTdvfes2qzdWvgGqLFyXR7mo3c046vCbTR+5Nm Fa3dKnriKDTA== X-Google-Smtp-Source: AGHT+IGks5+B6h/Ly8eJwxAzZ2tIHpJlUantdTbZkxkaBuxSWvYsKVRQT8rlUBGxrh/SIHhjhZH2mJfbuLUFFHUIqkg= X-Received: by 2002:a05:6402:3592:b0:5dc:cfc5:9305 with SMTP id 4fb4d7f45d1cf-5e0b721dfafmr16144550a12.25.1740433807826; Mon, 24 Feb 2025 13:50:07 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 24 Feb 2025 21:50:07 +0000 From: Stefan Kangas MIME-Version: 1.0 Date: Mon, 24 Feb 2025 21:50:07 +0000 X-Gm-Features: AWEUYZm_0pnOVugGISq_YNjxR5kNtclgDdO94T_2eTyzKlzSNzMdqcJwU9K3hlE Message-ID: Subject: control message for bug #76500 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) severity 76500 wishlist quit From unknown Mon Jun 16 23:47:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#76500: [PATCH] Allow numbered buffer selection for project shell commands Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 27 Feb 2025 07:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 76500 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Paul Nelson Cc: 76500@debbugs.gnu.org Received: via spool by 76500-submit@debbugs.gnu.org id=B76500.174064199720894 (code B ref 76500); Thu, 27 Feb 2025 07:40:02 +0000 Received: (at 76500) by debbugs.gnu.org; 27 Feb 2025 07:39:57 +0000 Received: from localhost ([127.0.0.1]:57832 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tnYUv-0005Qw-4N for submit@debbugs.gnu.org; Thu, 27 Feb 2025 02:39:57 -0500 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:33997) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tnYUs-0005QZ-2r for 76500@debbugs.gnu.org; Thu, 27 Feb 2025 02:39:54 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id B3BA843193; Thu, 27 Feb 2025 07:39:45 +0000 (UTC) From: Juri Linkov In-Reply-To: Organization: LINKOV.NET References: Date: Thu, 27 Feb 2025 09:38:57 +0200 Message-ID: <87ldtrzvji.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-State: clean X-GND-Score: 0 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdekieeklecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucenucfjughrpefhvfevufgjohhffffkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucggtffrrghtthgvrhhnpeffgeetfeevlefhleejfeeuheeiudeitdffhfdutdekfeffgffhveehteegueekheenucfkphepledurdduvdelrddutdehrdduudejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledurdduvdelrddutdehrdduudejpdhhvghlohepmhgrihhlrdhgrghnughirdhnvghtpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhgspghrtghpthhtohepvddprhgtphhtthhopeejieehtddtseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepuhhlthhrohhnohesghhmrghilhdrtghomh X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > This patch for project.el adds numeric prefix buffer naming to the > project-shell and project-eshell commands, aligning their behavior with > that of eshell. > [...] > Any comments or feedback would be welcome. I think this would be a useful addition like e.g. a numeric argument allows selecting an Info buffer with 'C-2 C-h i', etc.