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: was a command called via M-x?
Date: Thu, 17 Jul 2014 16:31:50 +0800
Message-ID: <87ha2gpert.fsf@ericabrahamsen.net>
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: ger.gmane.org 1405585719 17467 80.91.229.3 (17 Jul 2014 08:28:39 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 17 Jul 2014 08:28:39 +0000 (UTC)
To: help-gnu-emacs@gnu.org
Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 17 10:28:32 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 1X7h3E-0002mD-OO
	for geh-help-gnu-emacs@m.gmane.org; Thu, 17 Jul 2014 10:28:28 +0200
Original-Received: from localhost ([::1]:42844 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 1X7h3E-00064L-7L
	for geh-help-gnu-emacs@m.gmane.org; Thu, 17 Jul 2014 04:28:28 -0400
Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40172)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geh-help-gnu-emacs@m.gmane.org>) id 1X7h2w-000637-7K
	for help-gnu-emacs@gnu.org; Thu, 17 Jul 2014 04:28:17 -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 1X7h2o-0000J2-Nj
	for help-gnu-emacs@gnu.org; Thu, 17 Jul 2014 04:28:10 -0400
Original-Received: from plane.gmane.org ([80.91.229.3]:55227)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geh-help-gnu-emacs@m.gmane.org>) id 1X7h2o-0000Iy-Gs
	for help-gnu-emacs@gnu.org; Thu, 17 Jul 2014 04:28:02 -0400
Original-Received: from list by plane.gmane.org with local (Exim 4.69)
	(envelope-from <geh-help-gnu-emacs@m.gmane.org>) id 1X7h2l-0002ZX-1y
	for help-gnu-emacs@gnu.org; Thu, 17 Jul 2014 10:27:59 +0200
Original-Received: from 111.197.164.178 ([111.197.164.178])
	by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
	id 1AlnuQ-0007hv-00
	for <help-gnu-emacs@gnu.org>; Thu, 17 Jul 2014 10:27:59 +0200
Original-Received: from eric by 111.197.164.178 with local (Gmexim 0.1 (Debian))
	id 1AlnuQ-0007hv-00
	for <help-gnu-emacs@gnu.org>; Thu, 17 Jul 2014 10:27:59 +0200
X-Injected-Via-Gmane: http://gmane.org/
Original-Lines: 32
Original-X-Complaints-To: usenet@ger.gmane.org
X-Gmane-NNTP-Posting-Host: 111.197.164.178
User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4.50 (gnu/linux)
Cancel-Lock: sha1:C22vbOAYwZZ6HXy51QbhaWtY3m0=
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:98716
Archived-At: <http://permalink.gmane.org/gmane.emacs.help/98716>

I've written most of a tiny library, built on top of alert.el, that's
supposed to be used for demonstration screencasts: it watches for
interactive function calls, and pops the name of the function up as a
libnotify bubble if certain conditions are met (or logs it to a buffer
etc etc, anything that alert can do). It's pretty much done, except for
one last question.

I want the bubbles to show the command name, the prefix arg, and the key
sequence that was used to call the command. All that works fine, except
if the command was called via M-x, ie `execute-extended-command'. In
that case, `this-command-keys' returns "RET", which isn't quite right --
I'd rather it showed "M-x" or whatever. This is the basics of how it
works (this is put into the post-command-hook):

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

Thanks,
Eric