emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 2daeea7 1/2: Support program switches in 'comint-ru


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master 2daeea7 1/2: Support program switches in 'comint-run' command
Date: Thu, 11 Jul 2019 12:27:19 -0400 (EDT)

branch: master
commit 2daeea78335f4dbfd4d61fd3e179b41b48922104
Author: Phil Sainty <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Support program switches in 'comint-run' command
    
    * etc/NEWS:
    * doc/emacs/misc.texi: Describe new behaviour (bug#33037).
    * lisp/comint.el (comint-run): Add optional SWITCHES argument.
    With prefix argument C-u, prompt for SWITCHES.
---
 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 cfc50d3..9339626 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -1099,7 +1099,8 @@ the directory tracking feature, and a few user commands.
 @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 532babd..89111b1 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -754,6 +754,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
 
 *** SQL Indent Minor Mode
diff --git a/lisp/comint.el b/lisp/comint.el
index 55e6486..049e9e7 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -760,16 +760,24 @@ Returns the (possibly newly created) process buffer."
   (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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]