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

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

Checking if new commands have been defined: Can you help me find a bette


From: hans bennekop
Subject: Checking if new commands have been defined: Can you help me find a better approach?
Date: Mon, 21 Dec 2009 15:53:00 +0100
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

I want to check if new commands have been defined during a specific period of time.
There are two obvious approaches:

1)
Using 'mapatoms' to compile lists of available commands and
comparing them.
This technique is a bit too slow for my needs. It introduces a slight lag when used in a time-critical interactive function.

2)
Redefining 'defun' (and optionally 'fset') to trap command definitions.
This one messes rather crudely with the internals:
(fset 'old-defun (symbol-function 'defun))
(defmacro defun (&rest body)
  `(let* ((fn-symbol (first (quote ,body)))
          (was-command (commandp fn-symbol))
          (result (macroexpand (old-defun ,@body))))
     (and (not was-command) (commandp fn-symbol)
          (setq new-command-defined-flag t))
     result))

Are there other, more elegant ways to achieve the same effect?

Thanks,
Hans




reply via email to

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