unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Eric Abrahamsen <eric@ericabrahamsen.net>, help-gnu-emacs@gnu.org
Subject: RE: was a command called via M-x?
Date: Thu, 17 Jul 2014 06:57:28 -0700 (PDT)	[thread overview]
Message-ID: <e01f121d-a4ef-47b0-ae87-3f49bf2b61d3@default> (raw)
In-Reply-To: <87ha2gpert.fsf@ericabrahamsen.net>

> (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.



  reply	other threads:[~2014-07-17 13:57 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 [this message]
2014-07-19 12:37   ` Eric Abrahamsen

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=e01f121d-a4ef-47b0-ae87-3f49bf2b61d3@default \
    --to=drew.adams@oracle.com \
    --cc=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).