emacs-diffs
[Top][All Lists]
Advanced

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

scratch/bulk-tracing da5bb9ad26 1/2: squash! New commands for bulk traci


From: Phil Sainty
Subject: scratch/bulk-tracing da5bb9ad26 1/2: squash! New commands for bulk tracing of elisp functions (bug#27397)
Date: Thu, 14 Jul 2022 20:42:00 -0400 (EDT)

branch: scratch/bulk-tracing
commit da5bb9ad263b93e47a0389245dfcc2c9e3fc8aa2
Author: Phil Sainty <psainty@orcon.net.nz>
Commit: Phil Sainty <psainty@orcon.net.nz>

    squash! New commands for bulk tracing of elisp functions (bug#27397)
    
    (trace--after-load-alist): New variable.
    (trace--after-load, trace--after-load-function)
    (trace--remove-after-load, trace--remove-after-load-all):
    New functions for optionally re-processing the `trace-regexp',
    `untrace-regexp', and `trace-library' calls via
    `after-load-functions'.
    
    (untrace-all): Call `trace--remove-after-load-all'.
    
    (trace-currently-traced): New function.
---
 etc/NEWS                 |  4 ++--
 lisp/emacs-lisp/trace.el | 20 +++++++++++---------
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 4fbc7ca0bf..3cea3ced82 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1894,8 +1894,8 @@ and friends.
 *** New commands 'trace-package', 'trace-regexp', and 'trace-library'
 (and their counterparts 'untrace-package', 'untrace-regexp', and
 'untrace-library') allow for the bulk tracing of calls to functions
-with names matching the specified prefix, regexp, or defined by the
-specified file.
+with names matching a specified prefix or regexp, or functions defined
+by a specified file.
 
 ** Tramp
 
diff --git a/lisp/emacs-lisp/trace.el b/lisp/emacs-lisp/trace.el
index c4129c5f07..690276f986 100644
--- a/lisp/emacs-lisp/trace.el
+++ b/lisp/emacs-lisp/trace.el
@@ -297,6 +297,12 @@ Autoloaded functions are traceable."
 
 (define-obsolete-function-alias 'trace-is-traced 'trace-is-traced-p "29.1")
 
+(defun trace-currently-traced ()
+  "Return the list of currently traced function symbols."
+  (cl-loop for sym being the symbols
+           if (trace-is-traced-p sym)
+           collect sym))
+
 (defun trace--read-function (prompt)
   "Read a function name, prompting with string PROMPT."
   (let ((default (function-called-at-point)))
@@ -520,13 +526,11 @@ See also `untrace-library'."
   (when after-load
     (trace--after-load 'library library buffer context)))
 
-(defun trace--library-defuns (library &optional type)
-  "Returns a list of loaded function definitions associated with LIBRARY.
-
-Optionally return autoload definitions when TYPE is `autoload'."
+(defun trace--library-defuns (library)
+  "Returns a list of loaded function definitions associated with LIBRARY."
   (delq nil (mapcar (lambda (x)
                       (and (consp x)
-                           (eq (car x) (or type 'defun))
+                           (eq (car x) 'defun)
                            (cdr x)))
                     (cdr (load-history-filename-element
                           (load-history-regexp library))))))
@@ -591,9 +595,7 @@ function.
 
 Adds `trace--after-load-function' to `after-load-functions'."
   ;; Remove any existing spec for this (TYPE VALUE) key.
-  (setq trace--after-load-alist
-        (cl-delete (cons 'library value) trace--after-load-alist
-                   :key #'car))
+  (trace--remove-after-load type value)
   ;; Add the new spec.
   (push (list (cons type value) buffer context)
         trace--after-load-alist)
@@ -620,7 +622,7 @@ Remove `trace--after-load-function' from 
`after-load-functions'
 if it is no longer needed."
   (setq trace--after-load-alist
         (cl-delete (cons type value) trace--after-load-alist
-                   :key #'car))
+                   :key #'car :test #'equal))
   (unless trace--after-load-alist
     (remove-hook 'after-load-functions #'trace--after-load-function)))
 



reply via email to

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