Parsing unloaded .el files for defun interactive forms
Heime <[email protected]>
| Newsgroups | gmane.emacs.help |
|---|---|
| Message-ID | <9OFbR63-S_lwX93Vx-ZarKdMQMt145hfPNE39ca_Qh9sOiNWXHCv60gIWedQ2cm7e_5THAwdHmipmhD6PuMQET6ZINKACYUbb3lhFualPHQ=@protonmail.com> |
I've struggled to list interactive functions from .el files using obarray
symbols, as it requires prior loading. I need to parse unloaded .el files
directly to extract defun forms with (interactive ...).
Current broken code:
(defun ramazones-smbptn (smb pattern file)
"Filter symbol SMB defined in a specific file that are currently loaded."
(when (and (commandp smb)
(string-match-p pattern (symbol-name smb)))
smb))
(defun ramazonas-agfun (file pattern)
"List all interactive functions defined in FILE."
(interactive
(list
(read-file-name "File: ")
(read-regexp "Symbol Pattern (RET for all): ")))
(let ( (smbs nil)
(count 0) )
(when (find-file-noselect file)
(mapatoms (lambda (smb)
(when (ramazonas-smbptn smb pattern file)
(setq count (1+ count))
(push smb smbs))))
(if (> count 0)
(progn (message "Interactive functions: %s"
(seq-filter #'commandp smbs))
(seq-filter #'commandp smbs))
(message "No interactive functions found")))))