Hi
Stephen J. Turnbull wrote:
The following message is a courtesy copy of an article
that has been posted to comp.emacs.xemacs as well.
>>>>> "Klaus" == Klaus Berndl <klaus.berndl(a)sdm.de>
writes:
Klaus> Regardless which interactive command XXX i call via M-x XXX
Klaus> RET i always get `minibuffer-complete-and-exit' as content
Klaus> of `this-command' in the `pre-command-hook' direct before
Klaus> running XXX.
Klaus> Sure, this is not against the documentation of
Klaus> `this-command' but now I'm wondering how can i get the name
Klaus> "XXX" in the `pre-command-hook' direct before XXX runs?
Klaus> Seems that `this-command' is not what i need ;-)
Try `last-command'. However, it's possible that what should really
happen is that `minibuffer-complete-and-exit' should be fixed to setq
this-command last-command. So make sure you comment this work-around
well.
Cc'ing xemacs-beta to get (maybe) more-informed opinions.
Hmm, i have tested your suggestion with the following very short code:
(defun my-pre-command-hook ()
(message "This-command: %s, last-command: %s"
this-command last-command))
(add-hook 'pre-command-hook 'my-pre-command-hook)
Then i do:
1. [C-h i] to get an info buffer and then
2. [q] which quits the info-buffer.
Then i get the following output:
This-command: info, last-command: eval-last-sexp
Loading info...
Loading info...done
Composing main Info directory...
[...]
Composing main Info directory...done
This-command: Info-exit, last-command: info
This is what i want and need - i get `info' as value of `this-command'
in the `pre-command-hook' - Well!
But when i do M-x info RET i get:
This-command: execute-extended-command, last-command: eval-last-sexp
This-command: self-insert-command, last-command: t
This-command: self-insert-command, last-command: self-insert-command
This-command: self-insert-command, last-command: self-insert-command
This-command: self-insert-command, last-command: self-insert-command
This-command: minibuffer-complete-and-exit, last-command: self-insert-command
This-command: Info-exit, last-command: info
You see that i get never the name of the command `info' in the pre-command-hook,
neither as value of `this-command' (annoying) or as value of 'last-command'
(sounds clear). Note the difference between calling a command via a key-short-cut and
calling via M-x.
So, what should i do?
BTW: IMHO Stephen is right with "...that `minibuffer-complete-and-exit' should
be
fixed to setq this-command last-command.".
Thanks for your help,
Klaus