all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Suvayu Ali <fatkasuvayu+linux@gmail.com>
To: Nicolas Richard <theonewiththeevillook@yahoo.fr>
Cc: Emacs help <help-gnu-emacs@gnu.org>
Subject: Re: Getting last-command with arguments
Date: Fri, 13 Sep 2013 15:10:38 +0200	[thread overview]
Message-ID: <20130913131038.GJ2369@kuru.dyndns-at-home.com> (raw)
In-Reply-To: <87y571t0pf.fsf@yahoo.fr>

Hi Nicolas,

On Fri, Sep 13, 2013 at 01:34:04PM +0200, Nicolas Richard wrote:
> Suvayu Ali <fatkasuvayu+linux@gmail.com> 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.



  parent reply	other threads:[~2013-09-13 13:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-13 10:06 Getting last-command with arguments Suvayu Ali
2013-09-13 11:34 ` Nicolas Richard
2013-09-13 12:42   ` Stefan Monnier
2013-09-13 13:33     ` Suvayu Ali
2013-09-13 13:10   ` Suvayu Ali [this message]
2013-09-13 13:58     ` Nicolas Richard
2013-09-14  0:12       ` Xue Fuqiao
2013-09-16 13:34         ` Nicolas Richard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130913131038.GJ2369@kuru.dyndns-at-home.com \
    --to=fatkasuvayu+linux@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=theonewiththeevillook@yahoo.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.