* Time of last command invoked
@ 2021-02-26 14:20 Jean Louis
2021-02-26 21:56 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 12+ messages in thread
From: Jean Louis @ 2021-02-26 14:20 UTC (permalink / raw)
To: Help GNU Emacs
Is there some internal log in Emacs that keeps the date and time of
last command invoked by a key or M-x?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Time of last command invoked
2021-02-26 14:20 Time of last command invoked Jean Louis
@ 2021-02-26 21:56 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-27 6:21 ` Jean Louis
2021-02-27 15:31 ` Stefan Monnier
0 siblings, 2 replies; 12+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-02-26 21:56 UTC (permalink / raw)
To: help-gnu-emacs
Jean Louis wrote:
> Is there some internal log in Emacs that keeps the date and
> time of last command invoked by a key or M-x?
That would imply a huge overhead.
For the command subset that is relevant to whatever you want
to do you can alias a logger, perhaps.
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Time of last command invoked
2021-02-26 21:56 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-02-27 6:21 ` Jean Louis
2021-03-02 3:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-27 15:31 ` Stefan Monnier
1 sibling, 1 reply; 12+ messages in thread
From: Jean Louis @ 2021-02-27 6:21 UTC (permalink / raw)
To: help-gnu-emacs
* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-02-27 00:57]:
> Jean Louis wrote:
>
> > Is there some internal log in Emacs that keeps the date and
> > time of last command invoked by a key or M-x?
>
> That would imply a huge overhead.
>
> For the command subset that is relevant to whatever you want
> to do you can alias a logger, perhaps.
Is "logger" some function that exists in Emacs, or should I simply
make it?
(defun rcd/emacs-lisp-log (log)
"Allows functions to log their usage"
(let* ((function (second (backtrace-frame 5 nil)))
(timestamp (format-time-string "%Y-%m-%d-%H:%M:%S"))
(log (format "%s %s %s\n" timestamp function log))
(save-silently t))
(with-temp-buffer
(insert log)
(append-to-file (point-min) (point-max) *emacs-lisp-log*))))
(defun rcd-space ()
(interactive)
(rcd/emacs-lisp-log "SPACE")
(self-insert-command 1 32))
Then I made global-set-key SPC to rcd-space and now I log each SPACE
as *emacs-lisp-log* is like ~/tmp/lisp.log. Typing is not obstracted.
It is useful for self supervision.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Time of last command invoked
2021-02-26 21:56 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-27 6:21 ` Jean Louis
@ 2021-02-27 15:31 ` Stefan Monnier
2021-02-28 6:17 ` Robert Thorpe
2021-03-02 3:02 ` Emanuel Berg via Users list for the GNU Emacs text editor
1 sibling, 2 replies; 12+ messages in thread
From: Stefan Monnier @ 2021-02-27 15:31 UTC (permalink / raw)
To: help-gnu-emacs
>> Is there some internal log in Emacs that keeps the date and
>> time of last command invoked by a key or M-x?
> That would imply a huge overhead.
Not really, no.
We already keep a log of the keys and commands (as used for `C-h l`),
so it's a small matter of adding timestamps in there.
But given the way this is currently implemented, it would have to be
done in the C code, I think.
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Time of last command invoked
2021-02-27 15:31 ` Stefan Monnier
@ 2021-02-28 6:17 ` Robert Thorpe
2021-02-28 7:22 ` Jean Louis
2021-03-02 3:02 ` Emanuel Berg via Users list for the GNU Emacs text editor
1 sibling, 1 reply; 12+ messages in thread
From: Robert Thorpe @ 2021-02-28 6:17 UTC (permalink / raw)
To: Stefan Monnier, Jean Louis; +Cc: help-gnu-emacs
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> Is there some internal log in Emacs that keeps the date and
>>> time of last command invoked by a key or M-x?
>> That would imply a huge overhead.
>
> Not really, no.
> We already keep a log of the keys and commands (as used for `C-h l`),
> so it's a small matter of adding timestamps in there.
>
> But given the way this is currently implemented, it would have to be
> done in the C code, I think.
I think this depends on what Jean Louis wants. There are different
possible interpretations.
For just M-x it wouldn't be so difficult. That would just mean
replacing execute-extended-command with something that records the time
somewhere. The problem is that other keys.
If it means a function that's activated directly then it seems possible.
Every key that doesn't do "self-insert-command" could be remapped to a
different command. That command could record the key pressed before
handing over to the usual command. That would be tricky though, and
would break some Emacs features like C-h k. It would be a lot of work
and I don't think it would be worth it.
BR,
Robert Thorpe
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Time of last command invoked
2021-02-28 6:17 ` Robert Thorpe
@ 2021-02-28 7:22 ` Jean Louis
2021-02-28 15:25 ` Stefan Monnier
0 siblings, 1 reply; 12+ messages in thread
From: Jean Louis @ 2021-02-28 7:22 UTC (permalink / raw)
To: Robert Thorpe; +Cc: help-gnu-emacs, Stefan Monnier
* Robert Thorpe <rt@robertthorpeconsulting.com> [2021-02-28 09:18]:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
> >>> Is there some internal log in Emacs that keeps the date and
> >>> time of last command invoked by a key or M-x?
> >> That would imply a huge overhead.
> >
> > Not really, no.
> > We already keep a log of the keys and commands (as used for `C-h l`),
> > so it's a small matter of adding timestamps in there.
> >
> > But given the way this is currently implemented, it would have to be
> > done in the C code, I think.
>
> I think this depends on what Jean Louis wants. There are different
> possible interpretations.
It is very personal, just to review when did I do some of my last
works after untracked pauses of time. So even logging one key or
some common command gives me that information.
> If it means a function that's activated directly then it seems possible.
> Every key that doesn't do "self-insert-command" could be remapped to a
> different command. That command could record the key pressed before
> handing over to the usual command. That would be tricky though, and
> would break some Emacs features like C-h k. It would be a lot of work
> and I don't think it would be worth it.
There are also those advise functions. I have not express myself
well first time as first I was thinking maybe each command like in
lossage would have somewhere its timestamp which is maybe hidden and
I could just access it and find out my times of work. It would be
possible before exit from Emacs to make a report of full work and
statistics. It is for self observation.
Working in the area with frequent power outages is difficult. Then
some information about my last work helps me find out other pieces
of information and analyze what I was doing at what time.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Time of last command invoked
2021-02-28 7:22 ` Jean Louis
@ 2021-02-28 15:25 ` Stefan Monnier
2021-03-01 6:45 ` Jean Louis
0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2021-02-28 15:25 UTC (permalink / raw)
To: Robert Thorpe; +Cc: help-gnu-emacs
> There are also those advise functions. I have not express myself
> well first time as first I was thinking maybe each command like in
> lossage would have somewhere its timestamp which is maybe hidden and
> I could just access it and find out my times of work. It would be
> possible before exit from Emacs to make a report of full work and
> statistics. It is for self observation.
>
> Working in the area with frequent power outages is difficult. Then
> some information about my last work helps me find out other pieces
> of information and analyze what I was doing at what time.
BTW, it's not hard to do what you want:
Use a `post-command-hook` or `pre-command-hook` where you record the
current time the `this-command` and/or the `(this-command-keys)`.
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Time of last command invoked
2021-02-28 15:25 ` Stefan Monnier
@ 2021-03-01 6:45 ` Jean Louis
0 siblings, 0 replies; 12+ messages in thread
From: Jean Louis @ 2021-03-01 6:45 UTC (permalink / raw)
To: Stefan Monnier; +Cc: help-gnu-emacs, Robert Thorpe
* Stefan Monnier <monnier@iro.umontreal.ca> [2021-02-28 20:55]:
> > There are also those advise functions. I have not express myself
> > well first time as first I was thinking maybe each command like in
> > lossage would have somewhere its timestamp which is maybe hidden and
> > I could just access it and find out my times of work. It would be
> > possible before exit from Emacs to make a report of full work and
> > statistics. It is for self observation.
> >
> > Working in the area with frequent power outages is difficult. Then
> > some information about my last work helps me find out other pieces
> > of information and analyze what I was doing at what time.
>
> BTW, it's not hard to do what you want:
> Use a `post-command-hook` or `pre-command-hook` where you record the
> current time the `this-command` and/or the `(this-command-keys)`.
Ah, yes, that is right. Thank you.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Time of last command invoked
2021-02-27 15:31 ` Stefan Monnier
2021-02-28 6:17 ` Robert Thorpe
@ 2021-03-02 3:02 ` Emanuel Berg via Users list for the GNU Emacs text editor
1 sibling, 0 replies; 12+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-03-02 3:02 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier wrote:
>>> Is there some internal log in Emacs that keeps the date
>>> and time of last command invoked by a key or M-x?
>>
>> That would imply a huge overhead.
>
> Not really, no.
One would still think that compared to the mere execution (not
the whole commands themselves) that'd be some overhead but in
practice I guess keeping time in C is fast enough.
Or would the overhead still be small?
You keep track of time anyway so it would just be a read and
print thing?
What's the granularity, then? drift? do it in Ada instead? :)
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Time of last command invoked
2021-02-27 6:21 ` Jean Louis
@ 2021-03-02 3:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-03-07 9:26 ` Jean Louis
0 siblings, 1 reply; 12+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-03-02 3:07 UTC (permalink / raw)
To: help-gnu-emacs
Jean Louis wrote:
> Is "logger" some function that exists in Emacs, or should
> I simply make it?
Do it :)
Now we're talking some real overhead!
> (defun rcd/emacs-lisp-log (log)
> "Allows functions to log their usage"
> (let* ((function (second (backtrace-frame 5 nil)))
> (timestamp (format-time-string "%Y-%m-%d-%H:%M:%S"))
> (log (format "%s %s %s\n" timestamp function log))
> (save-silently t))
> (with-temp-buffer
> (insert log)
> (append-to-file (point-min) (point-max) *emacs-lisp-log*))))
OMG! Severe errors found:
First sentence should end with punctuation
Argument ‘log’ should appear (as LOG) in the doc string
Probably "Allows" should be imperative "Allow"
This is your friend:
(require 'checkdoc)
(setq checkdoc-permit-comma-termination-flag t)
(defun check-package-style ()
(interactive)
(let ((msg "Style check..."))
(message msg)
(checkdoc-current-buffer t) ; TAKE-NOTES
(message "%sdone" msg) ))
(defalias 'check-style #'check-package-style)
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Time of last command invoked
2021-03-02 3:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-03-07 9:26 ` Jean Louis
2021-03-07 9:47 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 12+ messages in thread
From: Jean Louis @ 2021-03-07 9:26 UTC (permalink / raw)
To: help-gnu-emacs
* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-03-02 06:11]:
> Jean Louis wrote:
>
> > Is "logger" some function that exists in Emacs, or should
> > I simply make it?
>
> Do it :)
>
> Now we're talking some real overhead!
>
> > (defun rcd/emacs-lisp-log (log)
> > "Allows functions to log their usage"
> > (let* ((function (second (backtrace-frame 5 nil)))
> > (timestamp (format-time-string "%Y-%m-%d-%H:%M:%S"))
> > (log (format "%s %s %s\n" timestamp function log))
> > (save-silently t))
> > (with-temp-buffer
> > (insert log)
> > (append-to-file (point-min) (point-max) *emacs-lisp-log*))))
>
> OMG! Severe errors found:
>
> First sentence should end with punctuation
>
> Argument ‘log’ should appear (as LOG) in the doc string
>
> Probably "Allows" should be imperative "Allow"
Thanks, I know those. I have functions in development files and
packaged files (ready). Then functions are moved from one to other and
verified to those conventions.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Time of last command invoked
2021-03-07 9:26 ` Jean Louis
@ 2021-03-07 9:47 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 12+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-03-07 9:47 UTC (permalink / raw)
To: help-gnu-emacs
Jean Louis wrote:
>>> (defun rcd/emacs-lisp-log (log)
>>> "Allows functions to log their usage"
>>> (let* ((function (second (backtrace-frame 5 nil)))
>>> (timestamp (format-time-string "%Y-%m-%d-%H:%M:%S"))
>>> (log (format "%s %s %s\n" timestamp function log))
>>> (save-silently t))
>>> (with-temp-buffer
>>> (insert log)
>>> (append-to-file (point-min) (point-max) *emacs-lisp-log*))))
>>
>> OMG! Severe errors found:
>>
>> First sentence should end with punctuation
>>
>> Argument ‘log’ should appear (as LOG) in the doc string
>>
>> Probably "Allows" should be imperative "Allow"
>
> Thanks, I know those. I have functions in development files
> and packaged files (ready). Then functions are moved from
> one to other and verified to those conventions.
OK, but I think that comment referred to the function in the
quotation in particular...
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-03-07 9:47 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-26 14:20 Time of last command invoked Jean Louis
2021-02-26 21:56 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-27 6:21 ` Jean Louis
2021-03-02 3:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-03-07 9:26 ` Jean Louis
2021-03-07 9:47 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-27 15:31 ` Stefan Monnier
2021-02-28 6:17 ` Robert Thorpe
2021-02-28 7:22 ` Jean Louis
2021-02-28 15:25 ` Stefan Monnier
2021-03-01 6:45 ` Jean Louis
2021-03-02 3:02 ` Emanuel Berg via Users list for the GNU Emacs text editor
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).