refactor(emacs-lisp): elisp-demos: reorganize Doom demos

- Move Doom core elisp API demos out of docs/examples.org into lisp/demos.org.
- Recognize and search demos.org file in modules for additional
  demos (including $DOOMDIR/demos.org).
- Refactor emacs-lisp module to use new elisp-demos-user-files variable
  instead of an advice. This way, elisp-demo's commands (such as
  `elisp-demos-find-demo` and `elisp-demos-add-demo`) will include
  Doom's demos.
This commit is contained in:
Henrik Lissner 2024-02-03 17:01:37 -05:00
parent 77ea4013dd
commit 3bea4f66a8
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
4 changed files with 675 additions and 703 deletions

View file

@ -217,7 +217,26 @@ See `+emacs-lisp-non-package-mode' for details.")
(advice-add #'describe-function-1 :after #'elisp-demos-advice-describe-function-1)
(advice-add #'helpful-update :after #'elisp-demos-advice-helpful-update)
:config
(advice-add #'elisp-demos--search :around #'+emacs-lisp--add-doom-elisp-demos-a))
;; Add Doom's core and module demo files, so additional demos can be specified
;; by end-users (in $DOOMDIR/demos.org), by modules (modules/X/Y/demos.org),
;; or Doom's core (lisp/demos.org).
(dolist (file (doom-module-locate-paths (doom-module-list) "demos.org"))
(add-to-list 'elisp-demos-user-files file))
;; HACK: These functions open Org files non-interactively without any
;; performance optimizations. Given how prone org-mode is to being tied to
;; expensive functionality, this will often introduce unexpected freezes
;; without this advice.
;; TODO: PR upstream?
(defadvice! +emacs-lisp--optimize-org-init-a (fn &rest args)
"Disable unrelated functionality to optimize calls to `org-mode'."
:around #'elisp-demos--export-json-file
:around #'elisp-demos--symbols
:around #'elisp-demos--syntax-highlight
(let ((org-inhibit-startup t)
enable-dir-local-variables
org-mode-hook)
(apply fn args))))
(use-package! buttercup