From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Suvayu Ali Newsgroups: gmane.emacs.help Subject: Re: Getting last-command with arguments Date: Fri, 13 Sep 2013 15:10:38 +0200 Message-ID: <20130913131038.GJ2369@kuru.dyndns-at-home.com> References: <20130913100626.GG2369@kuru.dyndns-at-home.com> <87y571t0pf.fsf@yahoo.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1379077922 28197 80.91.229.3 (13 Sep 2013 13:12:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 13 Sep 2013 13:12:02 +0000 (UTC) Cc: Emacs help To: Nicolas Richard Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Sep 13 15:12:05 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 1VKTAK-0008NC-VH for geh-help-gnu-emacs@m.gmane.org; Fri, 13 Sep 2013 15:12:05 +0200 Original-Received: from localhost ([::1]:46963 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKTAK-0006Ec-Gl for geh-help-gnu-emacs@m.gmane.org; Fri, 13 Sep 2013 09:12:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKT96-000568-2L for help-gnu-emacs@gnu.org; Fri, 13 Sep 2013 09:10:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VKT90-0000Xt-Rt for help-gnu-emacs@gnu.org; Fri, 13 Sep 2013 09:10:47 -0400 Original-Received: from mail-ee0-x234.google.com ([2a00:1450:4013:c00::234]:35510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKT90-0000Xf-CK for help-gnu-emacs@gnu.org; Fri, 13 Sep 2013 09:10:42 -0400 Original-Received: by mail-ee0-f52.google.com with SMTP id c41so559368eek.39 for ; Fri, 13 Sep 2013 06:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=hDqfWiBJoLi9hV32CvDClozOvVgtV7GiOoPMchbTj5s=; b=RoNj7xQqyodbiG46A3v0nvlNgiZhpsrMV5pQVAbJChAehDtErE4TtBL9ooNTZ1Wxbs sxpPe4MyNchLwYSVcE6hNicqGxAyvqVcwUa/XUKk/ZcfL/rcVYiA3sE2d71FS3NPPKI8 sFHhtBnhFvpB3jSlW24TKTYLPPNedQ4C5C42d1zPlAnjJRzdA5QIsAzowvjfA3iHjPOg 3bP8P8Ms6NeHXJ5QIRbOW6h991zmbIgUa7cFzvFFT7PF3kMRzDWjDVVAk4SkE3e8wMi2 gNQuTccc1lB6X988ZG4Si2ew8Wq9j0S6mUFo51Ai5zC+qBFGtmY0xjYtA5b5iNL6jiPN 4dqQ== X-Received: by 10.14.198.197 with SMTP id v45mr3281209een.52.1379077841565; Fri, 13 Sep 2013 06:10:41 -0700 (PDT) Original-Received: from kuru.dyndns-at-home.com ([2001:610:120:3001:f2de:f1ff:fe37:c76c]) by mx.google.com with ESMTPSA id a43sm14802218eep.9.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:10:40 -0700 (PDT) Content-Disposition: inline In-Reply-To: <87y571t0pf.fsf@yahoo.fr> User-Agent: Mutt/1.5.21 (2012-12-30) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c00::234 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:93380 Archived-At: Hi Nicolas, On Fri, Sep 13, 2013 at 01:34:04PM +0200, Nicolas Richard wrote: > Suvayu Ali writes: > > I am conditionally repeating the last command from inside an elisp > > function. So I look at `last-command' and decide. But now I want to > > see the original arguments: say the command was, M-2 M-x my-command RET, > > then I want to know 2 was passed to `my-command'. I am not sure how I > > can do that. > > The variable current-prefix-arg has that information. Thanks a lot. But did you mean last-prefix-arg instead? I want the prefix arg that was passed to last-command. After your hint, I read (info "(elisp) Prefix Command Arguments"). This is pseudo-code for what I'm trying to do: (defun my-cmd-1 (&optional args) nil) (defun my-cmd-2 (&optional args) (if (eq last-command 'my-cmd-1) (progn (setq this-command 'my-cmd-1) (my-cmd-1 last-prefix-arg) (setq prefix-arg last-prefix-arg)) ;; <-- this bit doesn't seem to work (some-command arg))) Then I call my-cmd-1, now if I call my-cmd-2 right after, it repeats my-cmd-1. If I do something else in between, the my-cmd-2 just calls some-command. I hope my intentions are clearer now. Cheers, -- Suvayu Open source is the future. It sets us free.