all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: help-gnu-emacs@gnu.org
Subject: was a command called via M-x?
Date: Thu, 17 Jul 2014 16:31:50 +0800	[thread overview]
Message-ID: <87ha2gpert.fsf@ericabrahamsen.net> (raw)

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
  




             reply	other threads:[~2014-07-17  8:31 UTC|newest]

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

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

  git send-email \
    --in-reply-to=87ha2gpert.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.