From owner-freebsd-questions Mon Feb 21 7:46:31 2000 Delivered-To: freebsd-questions@freebsd.org Received: from europe.std.com (europe.std.com [199.172.62.20]) by hub.freebsd.org (Postfix) with ESMTP id 1971437BF4A for ; Mon, 21 Feb 2000 07:46:26 -0800 (PST) (envelope-from lowell@world.std.com) Received: from world.std.com (lowell@world-f.std.com [199.172.62.5]) by europe.std.com (8.9.3/8.9.3) with ESMTP id KAA28757; Mon, 21 Feb 2000 10:46:07 -0500 (EST) Received: (from lowell@localhost) by world.std.com (8.9.3/8.9.3) id KAA08401; Mon, 21 Feb 2000 10:46:06 -0500 (EST) Date: Mon, 21 Feb 2000 10:46:06 -0500 (EST) Message-Id: <200002211546.KAA08401@world.std.com> From: Lowell Gilbert To: mark.ovens@uk.radan.com, freebsd-questions@freebsd.org In-reply-to: <38B15713.F501C93B@uk.radan.com> (message from Mark Ovens on Mon, 21 Feb 2000 15:17:39 +0000) Subject: Re: Running shell commands in Emacs References: <38B120A2.7E104808@uk.radan.com> <38B15713.F501C93B@uk.radan.com> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Date: Mon, 21 Feb 2000 15:17:39 +0000 From: Mark Ovens Lowell Gilbert wrote: > > Mark Ovens writes: > > > Is it possible to run a shell command from within emacs and have the > > output written to the current buffer at the cursor position, as the ex > > command ``r!'' in vi?, which is useful for adding the output of ``uname > > -a'' or ``dmesg'' into an e-mail, for instance. > > > > I know there is ``shell-command'' but that writes the output to a new > > buffer (*Shell Command Output*) so you then have to cut 'n' paste. > > If you specify the (optional) second parameter to shell-command, the > output will be inserted in the current buffer. "C-u shell-command" Where do I type that? You need to run "M-x shell-command", then enter the command at the "Shell command: " prompt. I didn't think it was possible to enter the second parameter when running interactively. Oops. Typo on my part -- "C-u M-x shell-command" will work. Sorry about that. And, of course, as you correctly imply, writing a wrapper function for shell-command to do this by default is a pretty simple matter (it would be trivial, except for the interactive behaviour of prompting for the command). Another approach I've used, when I didn't necessarily want all of the command's output, is to use a keyboard macro to go to the shell output buffer, kill some of the output from there, switch back to the original buffer, and yank it into the spot where I wanted it. - Lowell To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message