1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#!/usr/bin/env -S emacs -Q --script
(require 'cl-lib)
(cl-assert (string-suffix-p "/package-lint/" default-directory)
"Not in the package-lint directory")
(package-install 'compat)
(cl-assert (package-installed-p 'compat (version-to-list "29.1")))
(let (symbols functions)
(dolist (file (directory-files (file-name-directory (locate-library "compat"))
t "compat-[0-9]+\\.el$"))
(with-temp-buffer
(insert-file-contents file)
(goto-char (point-min))
(while (search-forward-regexp (rx line-start
"(compat-" (group (or "defun" "defmacro" "defvar" "defalias"))
(+ space)
symbol-start
(group (+? any))
symbol-end)
nil t)
(pcase (match-string 1)
("defvar" (push (match-string 2) symbols))
((or "defun" "defmacro" "defalias") (push (match-string 2) functions))))))
(push "compat" functions)
(push "compat-call" functions)
(with-temp-buffer
(insert (prin1-to-string (cons (mapcar #'intern (sort symbols #'string<))
(mapcar #'intern (sort functions #'string<)))))
(write-region (point-min) (point-max) "data/compat-symbols"))
(message "Wrote %d symbols and %d functions" (length symbols) (length functions)))
|