blob: 41307f2d844a86132ceb68a5c3a94c038b06d6a9 (
plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#!/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)))))
|