From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.org!not-for-mail
From: Eric Abrahamsen <eric@ericabrahamsen.net>
Newsgroups: gmane.emacs.help
Subject: Re: was a command called via M-x?
Date: Sat, 19 Jul 2014 20:37:06 +0800
Message-ID: <8738dxo77x.fsf@ericabrahamsen.net>
References: <87ha2gpert.fsf@ericabrahamsen.net>
	<e01f121d-a4ef-47b0-ae87-3f49bf2b61d3@default>
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: ger.gmane.org 1405773468 3757 80.91.229.3 (19 Jul 2014 12:37:48 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 19 Jul 2014 12:37:48 +0000 (UTC)
To: help-gnu-emacs@gnu.org
Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jul 19 14:37:41 2014
Return-path: <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org>
Envelope-to: geh-help-gnu-emacs@m.gmane.org
Original-Received: from lists.gnu.org ([208.118.235.17])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org>)
	id 1X8TtU-00033L-AM
	for geh-help-gnu-emacs@m.gmane.org; Sat, 19 Jul 2014 14:37:40 +0200
Original-Received: from localhost ([::1]:54189 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org>)
	id 1X8TtT-0001UH-NV
	for geh-help-gnu-emacs@m.gmane.org; Sat, 19 Jul 2014 08:37:39 -0400
Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33512)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geh-help-gnu-emacs@m.gmane.org>) id 1X8TtE-0001UB-CB
	for help-gnu-emacs@gnu.org; Sat, 19 Jul 2014 08:37:29 -0400
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <geh-help-gnu-emacs@m.gmane.org>) id 1X8Tt8-0004Kt-Op
	for help-gnu-emacs@gnu.org; Sat, 19 Jul 2014 08:37:24 -0400
Original-Received: from plane.gmane.org ([80.91.229.3]:48447)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geh-help-gnu-emacs@m.gmane.org>) id 1X8Tt8-0004Kp-Hu
	for help-gnu-emacs@gnu.org; Sat, 19 Jul 2014 08:37:18 -0400
Original-Received: from list by plane.gmane.org with local (Exim 4.69)
	(envelope-from <geh-help-gnu-emacs@m.gmane.org>) id 1X8Tt7-0002ss-P2
	for help-gnu-emacs@gnu.org; Sat, 19 Jul 2014 14:37:17 +0200
Original-Received: from 111.197.167.73 ([111.197.167.73])
	by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
	id 1AlnuQ-0007hv-00
	for <help-gnu-emacs@gnu.org>; Sat, 19 Jul 2014 14:37:17 +0200
Original-Received: from eric by 111.197.167.73 with local (Gmexim 0.1 (Debian))
	id 1AlnuQ-0007hv-00
	for <help-gnu-emacs@gnu.org>; Sat, 19 Jul 2014 14:37:17 +0200
X-Injected-Via-Gmane: http://gmane.org/
Original-Lines: 36
Original-X-Complaints-To: usenet@ger.gmane.org
X-Gmane-NNTP-Posting-Host: 111.197.167.73
User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4.50 (gnu/linux)
Cancel-Lock: sha1:onfUjTlzl9o0u3vLDaRk/QJxFM8=
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 80.91.229.3
X-BeenThere: help-gnu-emacs@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Users list for the GNU Emacs text editor <help-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/help-gnu-emacs>,
	<mailto:help-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/help-gnu-emacs>
List-Post: <mailto:help-gnu-emacs@gnu.org>
List-Help: <mailto:help-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/help-gnu-emacs>,
	<mailto:help-gnu-emacs-request@gnu.org?subject=subscribe>
Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org
Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org
Xref: news.gmane.org gmane.emacs.help:98789
Archived-At: <http://permalink.gmane.org/gmane.emacs.help/98789>

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