From bdf9a71ab7baa2b1de9abcfd5df1a9107a55d141 Mon Sep 17 00:00:00 2001 From: Jack Jamison Date: Sun, 5 Jul 2026 01:19:30 -0400 Subject: add a bunch of emacs packages HELP --- .../lisp/evil/scripts/evil-extract-docstrings | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 .config/emacs/lisp/evil/scripts/evil-extract-docstrings (limited to '.config/emacs/lisp/evil/scripts/evil-extract-docstrings') diff --git a/.config/emacs/lisp/evil/scripts/evil-extract-docstrings b/.config/emacs/lisp/evil/scripts/evil-extract-docstrings new file mode 100755 index 0000000..55dbd79 --- /dev/null +++ b/.config/emacs/lisp/evil/scripts/evil-extract-docstrings @@ -0,0 +1,41 @@ +#!/usr/bin/env -S emacs --script + +(setq cur-path (file-name-directory load-file-name)) + +(add-to-list 'load-path (expand-file-name ".." cur-path)) +(require 'evil) +(require 'evil-digraphs) +(require 'json) +(require 'help) + +(defun mark-command-keys (string) + "Mark key bindings in STRING with the \":kbd:\" Sphinx role." + (when string + (cl-loop + for prev = 0 then pos until (>= prev (length string)) + for pos = (next-single-property-change prev 'face string (length string)) + concat + (let ((s (substring string prev pos))) + (if (eq (get-text-property prev 'face string) 'help-key-binding) + (format ":kbd:`%s`" s) + s))))) + +(let (vars) + (mapatoms + (lambda (sym) + (when (string-prefix-p "evil-" (symbol-name sym)) + (let ((default (eval (car (get sym 'standard-value))))) + (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 . ,(mark-command-keys (documentation-property sym 'variable-documentation))) + (fn-docstring . ,(ignore-errors (mark-command-keys (documentation sym)))) + (arglist . ,(help-function-arglist sym)) + (functionp . ,(functionp sym)) + (macrop . ,(macrop sym))) + vars))))) + (with-temp-file (expand-file-name "../doc/docstringdb.json" cur-path) + (insert (json-encode vars)))) -- cgit v1.2.3