Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun fetch-defuns (file)
- (save-excursion
- (goto-char (point-min))
- (let (sexp
- (defuns nil)
- (defmacros nil))
- (condition-case nil
- (while t
- (setq sexp (read file))
- (when (listp sexp)
- (case (car sexp)
- (defun (push (cons (cadr sexp) (doc-if-any sexp)) defuns))
- (defmacro (push (cons (cadr sexp) (doc-if-any sexp)) defmacros)))))
- (error nil))
- ;; reverse the reversed defuns
- (setq defuns (reverse defuns))
- (generate-docs defuns))))
- (defun doc-if-any (sexp)
- "search for the doc"
- (when (stringp (cadddr sexp))
- (cadddr sexp)))
- (defun generate-docs (defuns)
- "generate a simple org with the docs"
- (mapconcat
- (lambda (x)
- (format "\n* %s\n %s"
- (car x) (or (cdr x) "-undocumented-")))
- defuns "\n"))
- (defun display-defuns ()
- "Display the defuns."
- (interactive)
- (let* ((out-buf (format "*Docs for: %s*" (file-name-nondirectory buffer-file-name)))
- (orig-buf (current-buffer)))
- (get-buffer-create out-buf)
- (save-excursion
- (goto-char (point-min))
- (with-current-buffer out-buf
- (erase-buffer)
- (insert (fetch-defuns orig-buf))
- (org-mode)
- (goto-char (point-min))))
- (display-buffer out-buf)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement