X-Loop: help-debbugs@HIDDEN Subject: bug#76500: [PATCH] Allow numbered buffer selection for project shell commands Resent-From: Paul Nelson <ultrono@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sun, 23 Feb 2025 11:16:02 +0000 Resent-Message-ID: <handler.76500.B.174030934132052 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 76500 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 76500 <at> debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN Received: via spool by submit <at> 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 <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tm9xU-0008Kt-Ah for submit <at> 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 <ultrono@HIDDEN>) id 1tm9xS-0008Kc-7q for submit <at> 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 <ultrono@HIDDEN>) id 1tm9xK-0002UD-0a for bug-gnu-emacs@HIDDEN; 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 <ultrono@HIDDEN>) id 1tm9xH-0002Cn-Nf for bug-gnu-emacs@HIDDEN; Sun, 23 Feb 2025 06:15:29 -0500 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-5452efeb87aso3575076e87.3 for <bug-gnu-emacs@HIDDEN>; 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 <bug-gnu-emacs@HIDDEN> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Feb 2025 03:15:20 -0800 (PST) From: Paul Nelson <ultrono@HIDDEN> Message-ID: <uxsg7tseo7h8ja.fsf@HIDDEN> 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@HIDDEN; 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 <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> 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 <ultrono@HIDDEN> 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) --=-=-=--
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Paul Nelson <ultrono@HIDDEN> Subject: bug#76500: Acknowledgement ([PATCH] Allow numbered buffer selection for project shell commands) Message-ID: <handler.76500.B.174030934132052.ack <at> debbugs.gnu.org> References: <uxsg7tseo7h8ja.fsf@HIDDEN> X-Gnu-PR-Message: ack 76500 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 76500 <at> debbugs.gnu.org Date: Sun, 23 Feb 2025 11:16:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): bug-gnu-emacs@HIDDEN If you wish to submit further information on this problem, please send it to 76500 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 76500: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D76500 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
Received: (at control) by debbugs.gnu.org; 24 Feb 2025 21:50:19 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 24 16:50:18 2025 Received: from localhost ([127.0.0.1]:43130 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tmgLC-0002VH-D5 for submit <at> 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 <stefankangas@HIDDEN>) id 1tmgL8-0002Qf-0P for control <at> 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 <control <at> debbugs.gnu.org>; 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 <stefankangas@HIDDEN> MIME-Version: 1.0 Date: Mon, 24 Feb 2025 21:50:07 +0000 X-Gm-Features: AWEUYZm_0pnOVugGISq_YNjxR5kNtclgDdO94T_2eTyzKlzSNzMdqcJwU9K3hlE Message-ID: <CADwFkmn7XsPnY0Z+ZmfkF9zXKacKnyz+Q-hbQ=fh85W7CtLisA@HIDDEN> Subject: control message for bug #76500 To: control <at> debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) severity 76500 wishlist quit
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.