From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: was a command called via M-x? Date: Thu, 17 Jul 2014 06:57:28 -0700 (PDT) Message-ID: References: <87ha2gpert.fsf@ericabrahamsen.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1405606306 19240 80.91.229.3 (17 Jul 2014 14:11:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 17 Jul 2014 14:11:46 +0000 (UTC) To: Eric Abrahamsen , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 17 16:11:39 2014 Return-path: 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 ) id 1X7mPJ-0006ON-TW for geh-help-gnu-emacs@m.gmane.org; Thu, 17 Jul 2014 16:11:38 +0200 Original-Received: from localhost ([::1]:44697 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7mPJ-0001J7-Eg for geh-help-gnu-emacs@m.gmane.org; Thu, 17 Jul 2014 10:11:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7mBq-0006jq-Rd for help-gnu-emacs@gnu.org; Thu, 17 Jul 2014 09:57:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X7mBi-0003qT-4J for help-gnu-emacs@gnu.org; Thu, 17 Jul 2014 09:57:42 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:19227) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7mBh-0003qP-UJ for help-gnu-emacs@gnu.org; Thu, 17 Jul 2014 09:57:34 -0400 Original-Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s6HDvUiZ014138 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 17 Jul 2014 13:57:31 GMT Original-Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s6HDvSJb029634 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Thu, 17 Jul 2014 13:57:29 GMT Original-Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s6HDvS4p027496; Thu, 17 Jul 2014 13:57:28 GMT In-Reply-To: <87ha2gpert.fsf@ericabrahamsen.net> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8 (707110) [OL 12.0.6691.5000 (x86)] X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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:98724 Archived-At: > (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)) >=20 > 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.