Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!im4u!ut-sally!utah-cs!utah-gr!spline!thomas From: thomas%spline.uucp@utah-gr.UUCP (Spencer W. Thomas) Newsgroups: comp.emacs Subject: Re: gathering interactive function usage statistics Message-ID: <2172@utah-gr.UUCP> Date: Fri, 9-Oct-87 13:30:35 EDT Article-I.D.: utah-gr.2172 Posted: Fri Oct 9 13:30:35 1987 Date-Received: Sun, 11-Oct-87 16:14:03 EDT References: <1031@cc5.bbn.com.BBN.COM> Sender: news@utah-gr.UUCP Reply-To: thomas%spline.UUCP@utah-gr.UUCP (Spencer W. Thomas) Organization: Univ of Utah CS Dept Lines: 42 One way is to redefine the function to count its usage. Here is a function that should do that: (defun count-fn (sym) "Cause uses of FUNCTION to be counted in the variable &count-FUNCTION. The function is redefined so that it can be called from C code and its \"commandness\" is preserved." (interactive "aFunction to count: ") (let* ((fun (symbol-function sym)) (doc (or (documentation sym) "")) (counted-doc "<> ") (counted-len (min (length counted-doc) (length doc))) (iactive (commandp fun)) (counted-var (intern (concat "&count-" (symbol-name sym))))) (if (and iactive (not (listp iactive)) (not (yes-or-no-p (format "%s will lose command status when counted, ok? " sym)))) (error "%s not counted" sym)) (if (string= (substring doc 0 counted-len) counted-doc) (error "%s is already counted" sym)) (put sym 'count-fun fun) (eval (` (defvar (, counted-var) 0))) (set counted-var 0) (eval (` (defun (, sym) (&rest arglist) (, (concat counted-doc doc)) (, iactive) (setq (, counted-var) (1+ (, counted-var))) (apply '(, fun) arglist))))) ) (defun uncount (sym) "Stop counting FUNCTION." (interactive "aFunction to stop counting: ") (if (not (get sym 'count-fun)) (error "function %s is not counted" sym)) (fset sym (get sym 'count-fun)) (put sym 'count-fun nil) (eval (intern (concat "&count-" (symbol-name sym))))) -- =Spencer ({ihnp4,decvax}!utah-cs!thomas, thomas@cs.utah.edu) =Spencer ({ihnp4,decvax}!utah-cs!thomas, thomas@cs.utah.edu)