From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Phil Sainty Newsgroups: gmane.emacs.bugs Subject: bug#33037: 27.0.50; [PATCH] Support program switches in 'comint-run' command Date: Sun, 14 Oct 2018 17:42:36 +1300 Message-ID: <4c421a8c-9b14-7981-f4bf-f4e6b33d2876@orcon.net.nz> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------CDCFF1A1B0D0B60585C8804B" X-Trace: blaine.gmane.org 1539492067 7826 195.159.176.226 (14 Oct 2018 04:41:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 14 Oct 2018 04:41:07 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 To: 33037@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 14 06:41:02 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBYD8-0001v9-Ke for geb-bug-gnu-emacs@m.gmane.org; Sun, 14 Oct 2018 06:41:02 +0200 Original-Received: from localhost ([::1]:47080 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBYFE-0005r7-Lq for geb-bug-gnu-emacs@m.gmane.org; Sun, 14 Oct 2018 00:43:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBYF7-0005qi-Tx for bug-gnu-emacs@gnu.org; Sun, 14 Oct 2018 00:43:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gBYF4-000094-P8 for bug-gnu-emacs@gnu.org; Sun, 14 Oct 2018 00:43:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44437) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gBYF4-00008i-KE for bug-gnu-emacs@gnu.org; Sun, 14 Oct 2018 00:43:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gBYF4-0006IM-F4 for bug-gnu-emacs@gnu.org; Sun, 14 Oct 2018 00:43:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Phil Sainty Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 14 Oct 2018 04:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 33037 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.153949217524183 (code B ref -1); Sun, 14 Oct 2018 04:43:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Oct 2018 04:42:55 +0000 Original-Received: from localhost ([127.0.0.1]:48695 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBYEw-0006Hy-UW for submit@debbugs.gnu.org; Sun, 14 Oct 2018 00:42:55 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:37558) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBYEv-0006Hk-AH for submit@debbugs.gnu.org; Sun, 14 Oct 2018 00:42:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gBYEp-0008V4-6b for submit@debbugs.gnu.org; Sun, 14 Oct 2018 00:42:48 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:50089) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gBYEp-0008V0-29 for submit@debbugs.gnu.org; Sun, 14 Oct 2018 00:42:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBYEn-0005q3-Tn for bug-gnu-emacs@gnu.org; Sun, 14 Oct 2018 00:42:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gBYEk-0008TO-NR for bug-gnu-emacs@gnu.org; Sun, 14 Oct 2018 00:42:45 -0400 Original-Received: from smtp-1.orcon.net.nz ([60.234.4.34]:41653) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gBYEk-0008Re-Bt for bug-gnu-emacs@gnu.org; Sun, 14 Oct 2018 00:42:42 -0400 Original-Received: from [150.107.172.16] (port=48208 helo=[192.168.20.103]) by smtp-1.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1gBYEe-0001wM-MO for bug-gnu-emacs@gnu.org; Sun, 14 Oct 2018 17:42:36 +1300 Content-Language: en-GB X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:151233 Archived-At: This is a multi-part message in MIME format. --------------CDCFF1A1B0D0B60585C8804B Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit This patch enables arguments to be passed to the specified program when invoking `comint-run'. Interactively, a prefix argument C-u will make the command prompt for the switches (as a string) after prompting for the program. The switches are processed with `split-string-and-unquote'. I think this is a sensible enhancement, but not necessarily the best user interface. Other possibilities which occur are: 1. Do not require a prefix arg, and simply make this the default prompting behaviour. 2. Do not require a separate prompt, and instead parse the program and its switches out of a single string. Either of those would mean that the user doesn't need to bother with (or remember to use) a prefix argument to enable something which is arguably important enough to happen by default. Option (2) is an issue when PROGRAM contains spaces, as the user would now need to quote that value, which is not currently necessary. Maybe the benefits make that a worthwhile change, though? (i.e. greater ease of use for the 'normal' use-cases where the path to the program does not contain spaces). I suppose option (3) might be "all of the above", with a user option to select the preferred prompting behaviour, but that might be overkill. ...all of which reminds me that I've been meaning to write a similar patch to allow switches to be specified for the `term' and `ansi-term' commands, and a consistent approach in all cases would seem sensible; so that's something else to keep in mind. -Phil --------------CDCFF1A1B0D0B60585C8804B Content-Type: text/x-patch; name="0001-Support-program-switches-in-comint-run-command.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Support-program-switches-in-comint-run-command.patch" >From 3adc0be13880472e74b6015c6948046a25acdb9b Mon Sep 17 00:00:00 2001 From: Phil Sainty Date: Sun, 14 Oct 2018 15:54:05 +1300 Subject: [PATCH] Support program switches in 'comint-run' command * lisp/comint.el (comint-run): Add optional SWITCHES argument. With prefix argument C-u, prompt for SWITCHES. * etc/NEWS: * doc/emacs/misc.texi: Describe new behaviour. --- doc/emacs/misc.texi | 3 ++- etc/NEWS | 4 ++++ lisp/comint.el | 16 ++++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi index 236cb07..fe397f7 100644 --- a/doc/emacs/misc.texi +++ b/doc/emacs/misc.texi @@ -1088,7 +1088,8 @@ Shell Mode @findex comint-run You can use @kbd{M-x comint-run} to execute any program of your choice in a subprocess using unmodified Comint mode---without the -specializations of Shell mode. +specializations of Shell mode. To pass arguments to the program, use +@kbd{C-u M-x comint-run} @node Shell Prompts @subsection Shell Prompts diff --git a/etc/NEWS b/etc/NEWS index 946a823..d2b8bdb 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -366,6 +366,10 @@ better emulate 'M-.' in both Bash and zsh, since the former counts from the beginning of the arguments, while the latter counts from the end. ++++ +*** 'comint-run' can now accept a list of switches to pass to the program. +'C-u M-x comint-run' will prompt for the switches interactively. + ** SQL *** Installation of 'sql-indent' from ELPA is strongly encouraged. diff --git a/lisp/comint.el b/lisp/comint.el index 5928804..5be763e 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -759,16 +759,24 @@ make-comint (apply #'make-comint-in-buffer name nil program startfile switches)) ;;;###autoload -(defun comint-run (program) - "Run PROGRAM in a Comint buffer and switch to it. +(defun comint-run (program &optional switches) + "Run PROGRAM in a Comint buffer and switch to that buffer. + +If SWITCHES are supplied, they are passed to PROGRAM. With prefix argument +\\[universal-argument] prompt for SWITCHES as well as PROGRAM. + The buffer name is made by surrounding the file name of PROGRAM with `*'s. The file name is used to make a symbol name, such as `comint-sh-hook', and any hooks on this symbol are run in the buffer. + See `make-comint' and `comint-exec'." (declare (interactive-only make-comint)) - (interactive "sRun program: ") + (interactive + (list (read-string "Run program: ") + (and (consp current-prefix-arg) + (split-string-and-unquote (read-string "Switches: "))))) (let ((name (file-name-nondirectory program))) - (switch-to-buffer (make-comint name program)) + (switch-to-buffer (apply #'make-comint name program nil switches)) (run-hooks (intern-soft (concat "comint-" name "-hook"))))) (defun comint-exec (buffer name command startfile switches) -- 2.8.3 --------------CDCFF1A1B0D0B60585C8804B--