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 16:22:39 +0200 Message-ID: <87r4ewrlqo.fsf@thinkpad.tsdh.de> References: <878v14t3lp.fsf@thinkpad.tsdh.de> <8738rcx8hq.fsf@yahoo.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1374157377 17615 80.91.229.3 (18 Jul 2013 14:22:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 18 Jul 2013 14:22:57 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Nicolas Richard Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 18 16:22:58 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 1Uzp6g-0000Ko-1r for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Jul 2013 16:22:58 +0200 Original-Received: from localhost ([::1]:36421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uzp6f-0008WR-KX for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Jul 2013 10:22:57 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45445) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uzp6V-0008VH-4x for help-gnu-emacs@gnu.org; Thu, 18 Jul 2013 10:22:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uzp6P-0006zO-OH for help-gnu-emacs@gnu.org; Thu, 18 Jul 2013 10:22:47 -0400 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:37595) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uzp6P-0006zK-HT for help-gnu-emacs@gnu.org; Thu, 18 Jul 2013 10:22:41 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by deliver.uni-koblenz.de (Postfix) with ESMTP id 4FA983D600C; Thu, 18 Jul 2013 16:22:41 +0200 (CEST) X-Virus-Scanned: amavisd-new at uni-koblenz.de Original-Received: from deliver.uni-koblenz.de ([127.0.0.1]) by localhost (deliver.uni-koblenz.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id f4zQpJkEfLuz; Thu, 18 Jul 2013 16:22:41 +0200 (CEST) X-CHKRCPT: Envelopesender noch tsdh@gnu.org Original-Received: from thinkpad.tsdh.de (tsdh.uni-koblenz.de [141.26.67.142]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by deliver.uni-koblenz.de (Postfix) with ESMTPSA id 1F2573D6006; Thu, 18 Jul 2013 16:22:40 +0200 (CEST) In-Reply-To: <8738rcx8hq.fsf@yahoo.fr> (Nicolas Richard's message of "Thu, 18 Jul 2013 16:12:17 +0200") User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 141.26.64.15 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:92236 Archived-At: Nicolas Richard writes: > Tassilo Horn writes: >> You can capture the last shell command using an advice, and have a >> command for repeating it, though. > > Since a history is maintained accross invocations, there must be a > variable holding that, already. Its name is shell-command-history ; > its (car) holds the last command. Indeed, so --8<---------------cut here---------------start------------->8--- (defun th-repeat-last-shell-command () (interactive) (if (car shell-command-history) (apply #'shell-command (car shell-command-history)) (message "There's no last shell command!"))) --8<---------------cut here---------------end--------------->8--- is enough. Bye, Tassilo