From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: master f8b2a01a9e: * lisp/shell.el (shell): Query shell file name from `interactive` Date: Sat, 28 May 2022 11:31:04 -0400 Message-ID: References: <165365729037.13166.16983049289085077158@vcs2.savannah.gnu.org> <20220527131450.B347BC01683@vcs2.savannah.gnu.org> <87zgj2vwtz.fsf@gmx.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8831"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Michael Albinus Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat May 28 17:32:43 2022 Return-path: Envelope-to: ged-emacs-devel@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 1nuyQe-0001jR-41 for ged-emacs-devel@m.gmane-mx.org; Sat, 28 May 2022 17:32:36 +0200 Original-Received: from localhost ([::1]:39884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nuyQc-0003vQ-LR for ged-emacs-devel@m.gmane-mx.org; Sat, 28 May 2022 11:32:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuyPI-000344-JB for emacs-devel@gnu.org; Sat, 28 May 2022 11:31:12 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:65165) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuyPF-0003xU-1w for emacs-devel@gnu.org; Sat, 28 May 2022 11:31:10 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 2B1A480810; Sat, 28 May 2022 11:31:07 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 79CED80781; Sat, 28 May 2022 11:31:05 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1653751865; bh=+iP38DHuOpenG8IEI6fR+N894KsULE4nrhfGhzLeN/g=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=VjGT3Qg6/FXaJaTFmjDDVY1/iUJ8B/z7nyGr1MTiFDwaDL1BbjkgY4nBSEMfwPnj3 oqV8muIqkjNms/rbvY+WolYjNqnyiBIMtzIz+/XOykT0Kvh6cGl49ielFrveouOvVo Y/tDVO5ZpuciHidYUnYhmmtJ9IpdEKWDb9ZuBOeSq+iEYxilCMBe8ZIqxM9uyGas8m j2FVXvDlVFoCZtnjpYEWrVp2gGzDZFAKnWOnT3QOpm/jBqnG3BsVxcLnl3alhc95u1 rpRiDWKjmEsdd6SrKb7x1X9iIPpSHXrzkAn6NuhSposVknhRZcAFYoKDLqDXMGw1f1 xwA+I4qO/OEzQ== Original-Received: from alfajor (modemcable034.207-20-96.mc.videotron.ca [96.20.207.34]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 40AED120172; Sat, 28 May 2022 11:31:05 -0400 (EDT) In-Reply-To: (Stefan Monnier's message of "Sat, 28 May 2022 10:12:45 -0400") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:290338 Archived-At: Stefan Monnier [2022-05-28 10:12:45] wrote: >> This misses the `with-connection-local-variables' wrapper in the >> `interactive' form. Is this intended? It would be a serious regression. > Oh, I missed that, sorry, Does the patch below look correct to you? It also tries to address the FIXME while we're at it. Stefan 2022-05-28 Stefan Monnier * lisp/shell.el (shell): Make sure we set the `default-directory` of the actual shell buffer after querying the user. Apply connection-local variables when prompting the user for a remote shell file-name. diff --git a/lisp/shell.el b/lisp/shell.el index 1fcd1a1d1cc..8bcc578406a 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -755,38 +755,47 @@ shell \(Type \\[describe-mode] in the shell buffer for a list of commands.)" (interactive - (list - (and current-prefix-arg - (prog1 - (read-buffer "Shell buffer: " - ;; If the current buffer is an inactive - ;; shell buffer, use it as the default. - (if (and (eq major-mode 'shell-mode) - (null (get-buffer-process (current-buffer)))) - (buffer-name) - (generate-new-buffer-name "*shell*"))) - (if (file-remote-p default-directory) - ;; It must be possible to declare a local default-directory. - ;; FIXME: This can't be right: it changes the default-directory - ;; of the current-buffer rather than of the *shell* buffer. - (setq default-directory - (expand-file-name - (read-directory-name - "Default directory: " default-directory default-directory - t nil)))))) - ;; On remote hosts, the local `shell-file-name' might be useless. - (when (and (file-remote-p default-directory) - (null explicit-shell-file-name) - (null (getenv "ESHELL"))) - ;; `expand-file-name' shall not add the MS Windows volume letter - ;; (Bug#49229). - (replace-regexp-in-string - "^[[:alpha:]]:" "" - (file-local-name - (expand-file-name - (read-file-name "Remote shell path: " default-directory - shell-file-name t shell-file-name - #'file-remote-p))))))) + (let* ((buffer + (and current-prefix-arg + (read-buffer "Shell buffer: " + ;; If the current buffer is an inactive + ;; shell buffer, use it as the default. + (if (and (eq major-mode 'shell-mode) + (null (get-buffer-process + (current-buffer)))) + (buffer-name) + (generate-new-buffer-name "*shell*"))))) + (buf (if (or buffer (not (derived-mode-p 'shell-mode)) + (comint-check-proc (current-buffer))) + (get-buffer-create (or buffer "*shell*")) + ;; If the current buffer is a dead shell buffer, use it. + (current-buffer)))) + + (with-current-buffer buf + (when (and buffer (file-remote-p default-directory)) + ;; It must be possible to declare a local default-directory. + (setq default-directory + (expand-file-name + (read-directory-name + "Default directory: " default-directory default-directory + t nil)))) + (list + buffer + ;; On remote hosts, the local `shell-file-name' might be useless. + (with-connection-local-variables + (when (and (file-remote-p default-directory) + (null explicit-shell-file-name) + (null (getenv "ESHELL"))) + ;; `expand-file-name' shall not add the MS Windows volume letter + ;; (Bug#49229). + (replace-regexp-in-string + "^[[:alpha:]]:" "" + (file-local-name + (expand-file-name + (read-file-name "Remote shell path: " default-directory + shell-file-name t shell-file-name + #'file-remote-p)))))))))) + (setq buffer (if (or buffer (not (derived-mode-p 'shell-mode)) (comint-check-proc (current-buffer))) (get-buffer-create (or buffer "*shell*"))