#!/usr/bin/emacs --script (setq cur-path (file-name-directory load-file-name)) (add-to-list 'load-path (format "%s.." cur-path)) (require 'evil) (require 'json) (require 'help) (defun keymap-funcs (map) (let (funcs) (dolist (elt (cdr map)) (when (consp elt) (cond ((and (cdr elt) (symbolp (cdr elt))) (push (cdr elt) funcs)) ((keymapp (cdr elt)) (setq funcs (append (keymap-funcs (cdr elt)) funcs)))))) funcs)) (defun keymap-bindings (map) (let ((funcs (keymap-funcs map)) bindings) (dolist (func funcs) (unless (memq func '(undefined)) ;; (push (cons func (key-description (where-is-internal func map t))) bindings) ;; (message (format "%s %s" func (key-description (where-is-internal func map t)))) (push (cons func (key-description (where-is-internal func map t))) bindings))) bindings)) (with-temp-file (format "%s../doc/docstringdb.json" cur-path) (let (vars) (mapatoms (lambda (sym) (when (string-prefix-p "evil-" (symbol-name sym)) (let ((default (car (get sym 'standard-value)))) (while (and (consp default) (memq (car default) '(function quote))) (setq default (cadr default))) (when (eq 'funcall (car-safe default)) (setq default (eval default))) ;; (when (and (boundp sym) (keymapp (symbol-value sym))) ;; (message (format "%S" sym))) (push `(,sym (default . ,(cond ((consp default) (format "%S" default)) ((symbolp default) (symbol-name default)) (t default))) (local . ,(local-variable-if-set-p sym)) (default-type . ,(type-of default)) (var-docstring . ,(documentation-property sym 'variable-documentation 'raw)) (fn-docstring . ,(ignore-errors (documentation sym 'raw))) (arglist . ,(help-function-arglist sym)) (functionp . ,(functionp sym)) (macrop . ,(macrop sym)) (keymap-inv . ,(and (boundp sym) (keymapp (symbol-value sym)) (keymap-bindings (symbol-value sym))))) vars))))) (let ((json-encoding-pretty-print t)) (insert (json-encode vars)))))