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

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

Re: was a command called via M-x?


From: Eric Abrahamsen
Subject: Re: was a command called via M-x?
Date: Sat, 19 Jul 2014 20:37:06 +0800
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4.50 (gnu/linux)

Drew Adams <address@hidden> writes:

>> (let* ((command-name (symbol-name this-command))
>>        (pref-arg current-prefix-arg)
>>        (keys (this-command-keys))
>>        (key-string (key-description keys))
>>        (title-string (if pref-arg
>>                          (format "%s %s" pref-arg key-string)
>>                        (format "%s" key-string))))
>>   (alert command-name :title title-string))
>> 
>> I don't want to just check for "RET" and replace it with "M-x", because
>> the command might very well have been called with "RET". Do I have any
>> other way of knowing for sure that the command was called using
>> `execute-extended-command'? last-command doesn't seem to get it
>> either...
>
> You might want to show more of how your code is invoked etc.
>
> `execute-extended-command' changes `this-command'.  The command invoked
> by `execute-extended-command' is instead the value of `real-this-command',
> and you can get its key binding (if there is one) using:
> (where-is-internal real-this-command overriding-local-map t) instead of
> (this-command-keys).
>
> But if you want `execute-extended-command' or `M-x' instead of that
> information, then you will probably need to either advise that function
> or (depending on when you need the info) advise `read-extended-command',
> recording for yourself the fact that `execute-extended-command' was
> invoked.

Hmm, that's sounding like maybe more work than it's worth. Let me clean
up the module as it is, and have another hard look at it.

Thanks,
Eric




reply via email to

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