* Create a command-history with timestamps?
@ 2006-04-05 18:32 Michael T Decerbo
2006-04-06 4:22 ` Timestamped command-history and post-command-hook Michael T Decerbo
2006-04-06 14:08 ` Create a command-history with timestamps? Mathias Dahl
0 siblings, 2 replies; 3+ messages in thread
From: Michael T Decerbo @ 2006-04-05 18:32 UTC (permalink / raw)
The command M-x command-history-mode puts you in a buffer with the
current command history, one command to a line.
I would like to create a similar command that creates such a history
with a timestamp at which each command was performed, perhaps as a
comment.
Is this likely to be simple or complicated? Can anyone suggest a
starting point?
--
Mike --- mike@mit.edu
^ permalink raw reply [flat|nested] 3+ messages in thread
* Timestamped command-history and post-command-hook
2006-04-05 18:32 Create a command-history with timestamps? Michael T Decerbo
@ 2006-04-06 4:22 ` Michael T Decerbo
2006-04-06 14:08 ` Create a command-history with timestamps? Mathias Dahl
1 sibling, 0 replies; 3+ messages in thread
From: Michael T Decerbo @ 2006-04-06 4:22 UTC (permalink / raw)
I wrote:
>The command M-x command-history-mode puts you in a buffer with the
>current command history, one command to a line.
>
>I would like to create a similar command that creates such a history
>with a timestamp at which each command was performed, perhaps as a
>comment.
So far, the best I have come up with is the following:
(defun history-timestamp ()
"Append a timestamp to the most recent event"
(interactive)
(setq command-history (cons (append (car command-history) (list (format-time-string "%H:%M:%S %d.%m.%Y"))) (cdr command-history))))
(add-hook 'post-command-hook 'history-timestamp)
... which gives me results like the following.
(kill-buffer "foo3" "00:13:52 06.04.2006" "00:13:53 06.04.2006" "00:13:53 06.04.2006" "00:13:53 06.04.2006" "00:13:53 06.04.2006" "00:13:53 06.04.2006" "00:13:53 06.04.2006" "00:13:53 06.04.2006" "00:13:53 06.04.2006" "00:13:54 06.04.2006" "00:13:54 06.04.2006" "00:13:54 06.04.2006")
(switch-to-buffer "foo3" "00:13:51 06.04.2006" "00:13:52 06.04.2006")
(find-file "/tmp/foo8" 1 "00:13:48 06.04.2006" "00:13:49 06.04.2006" "00:13:49 06.04.2006" "00:13:50 06.04.2006" "00:13:50 06.04.2006" "00:13:51 06.04.2006")
(kill-buffer "foo2" "00:12:41 06.04.2006" "00:12:42 06.04.2006" "00:12:42 06.04.2006" "00:12:42 06.04.2006" "00:12:43 06.04.2006" "00:12:43 06.04.2006" "00:12:43 06.04.2006" "00:12:43 06.04.2006" "00:12:43 06.04.2006" "00:12:43 06.04.2006" "00:12:43 06.04.2006" "00:12:43 06.04.2006")
Curiously, post-command-hook seems to be getting called multiple times
for each command, which is not at all what I had expected! Can anyone
shed any light on this?
I'm sure this breaks compatibility with packages that use the command-history;
is there a better way to do this?
--
Mike --- mike@mit.edu
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Create a command-history with timestamps?
2006-04-05 18:32 Create a command-history with timestamps? Michael T Decerbo
2006-04-06 4:22 ` Timestamped command-history and post-command-hook Michael T Decerbo
@ 2006-04-06 14:08 ` Mathias Dahl
1 sibling, 0 replies; 3+ messages in thread
From: Mathias Dahl @ 2006-04-06 14:08 UTC (permalink / raw)
mike@mit.edu (Michael T Decerbo) writes:
> The command M-x command-history-mode puts you in a buffer with the
> current command history, one command to a line.
Cool! I did not even know about this command! Seems useful if you want
to repeat certain complex commands without wanting to record a macro.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-04-06 14:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-05 18:32 Create a command-history with timestamps? Michael T Decerbo
2006-04-06 4:22 ` Timestamped command-history and post-command-hook Michael T Decerbo
2006-04-06 14:08 ` Create a command-history with timestamps? Mathias Dahl
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).