unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: help-gnu-emacs@gnu.org
Subject: Re: was a command called via M-x?
Date: Sat, 19 Jul 2014 20:37:06 +0800	[thread overview]
Message-ID: <8738dxo77x.fsf@ericabrahamsen.net> (raw)
In-Reply-To: e01f121d-a4ef-47b0-ae87-3f49bf2b61d3@default

Drew Adams <drew.adams@oracle.com> 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	other threads:[~2014-07-19 12:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-17  8:31 was a command called via M-x? Eric Abrahamsen
2014-07-17 13:57 ` Drew Adams
2014-07-19 12:37   ` Eric Abrahamsen [this message]

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=8738dxo77x.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=help-gnu-emacs@gnu.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).