help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Time of last command invoked


From: Jean Louis
Subject: Re: Time of last command invoked
Date: Sat, 27 Feb 2021 09:21:56 +0300
User-agent: Mutt/2.0 (3d08634) (2020-11-07)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]