Stefan Kangas <stefankangas@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at submit) by debbugs.gnu.org; 23 Feb 2025 11:15:41 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 23 06:15:40 2025 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> To: bug-gnu-emacs@HIDDEN Subject: [PATCH] Allow numbered buffer selection for project shell commands Message-ID: <uxsg7tseo7h8ja.fsf@HIDDEN> X-Debbugs-Cc: 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-Debbugs-Envelope-To: submit 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) --=-=-=--
Paul Nelson <ultrono@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#76500
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.