all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Checking if new commands have been defined: Can you help me find a better approach?
@ 2009-12-21 14:53 hans bennekop
  0 siblings, 0 replies; only message in thread
From: hans bennekop @ 2009-12-21 14:53 UTC (permalink / raw)
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-12-21 14:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-21 14:53 Checking if new commands have been defined: Can you help me find a better approach? hans bennekop

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.