As I known, “C-u M-x shell” can be used to run multiple shells.
But how to define a function to do the same thing as “C-u M-x shell” do ?
As I known, C-u M-x shell can be used to run multiple shells. But
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I used
describe-functionandfind-functionto examine the behaviour ofshell, and itsinteractivedeclaration in particular, and then I just copied the necessary code to turn that into an argument for a non-interactive call to theshellfunction (but wrapping it inget-bufferso as to provide a buffer argument).I’ve actually left out some code which dealt with remote files, because the comments in that code seemed a bit confused. If you weren’t in the habit of using
C-u M-x shellin buffers accessing remote files via Tramp, that omission won’t affect you.That all said, an even simpler (and more complete) approach is simply:
For more information, refer to https://stackoverflow.com/a/9388058/324105
In this instance
current-prefix-argcould be any non-nil value, but I think it’s a good habit to use a value thatC-uactually generates.