help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting last-command with arguments


From: Suvayu Ali
Subject: Re: Getting last-command with arguments
Date: Fri, 13 Sep 2013 15:10:38 +0200
User-agent: Mutt/1.5.21 (2012-12-30)

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]