Subject: bug#27397: [PATCH] New commands for bulk tracing of elisp functions

From: Phil Sainty <[email-masked]>
Date: Tue, 20 Jun 2017 00:17:38 +1200

On 20/06/17 00:05, Michael Albinus wrote:
> So we shall parse indead every function for the library it belongs to. It
> shouldn't be too hard, based on `autoloadp', `find-lisp-object-file-name'
> and friends, see the implementation in `describe-function-1'. Something
> like this is a very rudimentary implementation:
> 
> (defun my-find-library (fun)
>   "Find library FUN is defined in.
> In case of subroutines, return t"
>   (when (fboundp fun)
>     (let ((def (symbol-function fun)))
>       (cond
>        ((autoloadp def) (cadr def))
>        ((subrp def) t)
>        (t (file-name-base (find-lisp-object-file-name fun nil)))))))

Meanwhile I was experimenting with load-history along these lines:

(require 'seq)
(defun trace-library (library)
  "Trace functions defined by LIBRARY."
  (mapcar 'trace-function-background
          (mapcar 'cdr (seq-filter
                        (lambda (x)
                          (and (consp x) (eq (car x) 'defun)))
                        (load-history-filename-element
                         (load-history-regexp library))))))