unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* was a command called via M-x?
@ 2014-07-17  8:31 Eric Abrahamsen
  2014-07-17 13:57 ` Drew Adams
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Abrahamsen @ 2014-07-17  8:31 UTC (permalink / raw)
  To: help-gnu-emacs

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
  




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-07-19 12:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-17  8:31 was a command called via M-x? Eric Abrahamsen
2014-07-17 13:57 ` Drew Adams
2014-07-19 12:37   ` Eric Abrahamsen

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