From b36715dcbd82372bc59d53d6f8fa4d3c46f50586 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 3 Apr 2020 06:42:53 -0700 Subject: tags: grok Lisp definitions inside @(do ...). * tags.tl (unexpand): New function. (process-clause): Walk the forms enclosed in a @(do ...) directive that appears at the top level. Because all Lisp is macro-expanded right inside the TXR parser, we need to "unexpand" the forms by chasing their macro-ancestor chain, gaining access to the original forms like defun and defstruct. We can then turn these forms into tags using the process-form function. --- tags.tl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tags.tl b/tags.tl index 66561d08..68a8527c 100755 --- a/tags.tl +++ b/tags.tl @@ -124,6 +124,11 @@ (name (add (ntag slot-tag name struct-name struct-obj)))))))))))) +(defun unexpand (form) + (whilet ((anc (macro-ancestor form))) + (set form anc)) + form) + (defun process-clause (path lines clause) (when (consp clause) (let ((elem (car clause))) @@ -137,7 +142,10 @@ (add (ntag fun-tag (car args))))) (bind (let ((syms (flatten (cadr elem)))) (each ((sym syms)) - (add (ntag fun-tag sym)))))))))))) + (add (ntag fun-tag sym))))) + (do (let ((forms [mapcar unexpand (cdr elem)])) + (each ((form forms)) + (pend (process-form path lines form)))))))))))) (defun collect-tags-tl (path) (let* ((text (file-get-string path)) -- cgit v1.2.3