From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: repeat the last single shell command Date: Thu, 18 Jul 2013 15:11:30 +0200 Message-ID: <878v14t3lp.fsf@thinkpad.tsdh.de> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1374153135 30382 80.91.229.3 (18 Jul 2013 13:12:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 18 Jul 2013 13:12:15 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 18 15:12:16 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Uzo0F-00025c-DM for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Jul 2013 15:12:15 +0200 Original-Received: from localhost ([::1]:38747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uzo0E-0007ye-SQ for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Jul 2013 09:12:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uzo04-0007yW-Eo for help-gnu-emacs@gnu.org; Thu, 18 Jul 2013 09:12:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uzo02-0007WK-Fs for help-gnu-emacs@gnu.org; Thu, 18 Jul 2013 09:12:04 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:54927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uzo02-0007UV-91 for help-gnu-emacs@gnu.org; Thu, 18 Jul 2013 09:12:02 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Uznzp-0001m9-0N for help-gnu-emacs@gnu.org; Thu, 18 Jul 2013 15:11:49 +0200 Original-Received: from tsdh.uni-koblenz.de ([141.26.67.142]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 18 Jul 2013 15:11:49 +0200 Original-Received: from tsdh by tsdh.uni-koblenz.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 18 Jul 2013 15:11:49 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 59 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: tsdh.uni-koblenz.de User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:rfkBDza6FBYV4B4fyM4/KXEJBhc= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:92229 Archived-At: Luca Ferrari writes: Hi Luca, > this should be trivial, but I'm not able to find an easy and simple > way of running again the last single shell command (M-!). I know I can > use the shell ring to get back the last command, like M-P so that I > have to: > > M-! M-p RET > > but I guess there is a smarter way. And I don't want to open a full > shell, this is supposed to let me test quickly a shell script. You can do `C-x M-:' which is: ,----[ C-h k C-x M-: ] | C-x M-: runs the command repeat-complex-command, which is an interactive | compiled Lisp function in `simple.el'. | | It is bound to , , C-x M-:, C-x M-ESC. | | (repeat-complex-command ARG) | | Edit and re-evaluate last complex command, or ARGth from last. | A complex command is one which used the minibuffer. | The command is placed in the minibuffer as a Lisp form for editing. | The result is executed, repeating the command as changed. | If the command has been changed or is not the most recent previous | command it is added to the front of the command history. | You can use the minibuffer history commands M-n and M-p | to get different commands to edit and resubmit. `---- Well, that's actually not really faster to type... You can capture the last shell command using an advice, and have a command for repeating it, though. --8<---------------cut here---------------start------------->8--- (defvar th-last-shell-command) (defadvice shell-command (before th-capture-shell-command (command &optional output-buffer error-buffer) activate) (setq th-last-shell-command (list command output-buffer error-buffer))) (defun th-repeat-last-shell-command () (interactive) (if th-last-shell-command (apply #'shell-command th-last-shell-command) (message "There's no last shell command!"))) --8<---------------cut here---------------end--------------->8--- Then you can bind `th-repeat-last-shell-command' to some key that's convenient to you. Bye, Tassilo