|
| 1 | +;; This demo is scripted using director.el: https://github.com/bard/emacs-director |
| 2 | +;; |
| 3 | +;; To record it: |
| 4 | +;; |
| 5 | +;; asciinema rec --overwrite -c 'emacs -Q -nw -l director-bootstrap.el -l demo.el' demo.asciicast |
| 6 | +;; agg --font-size 24 demo.asciicast ../docs/public/demo2.gif |
| 7 | + |
| 8 | +(director-bootstrap |
| 9 | + :user-dir "/tmp/run-command-demo.userdir" |
| 10 | + :packages '(helm ivy async rust-mode) |
| 11 | + :load-path |
| 12 | + '("~/projects/emacs-run-command" |
| 13 | + "~/projects/emacs-director" ;; won't be needed after director is published on Melpa |
| 14 | + )) |
| 15 | + |
| 16 | +(director-run |
| 17 | + :version 1 |
| 18 | + :before-start |
| 19 | + (lambda () |
| 20 | + ;; load required features |
| 21 | + (require 'run-command) |
| 22 | + (require 'helm) |
| 23 | + (require 'term) |
| 24 | + |
| 25 | + ;; remove distractions |
| 26 | + (setq initial-scratch-message "") |
| 27 | + (menu-bar-mode 'toggle) |
| 28 | + (setq helm-display-header-line nil) |
| 29 | + (set-face-attribute 'helm-source-header nil |
| 30 | + :background "transparent" |
| 31 | + :foreground "dim gray" |
| 32 | + :weight 'normal) |
| 33 | + (set-face-attribute 'helm-match nil |
| 34 | + :foreground "brightred " |
| 35 | + :weight 'bold |
| 36 | + :underline t) |
| 37 | + |
| 38 | + ;; create a fresh space for each demo run |
| 39 | + (setq demo-directory (make-temp-file "run-command-demo-" t)) |
| 40 | + |
| 41 | + ;; prepare the environment |
| 42 | + (helm-mode 1) |
| 43 | + |
| 44 | + ;; configure package to be demo'd |
| 45 | + (setq run-command-recipes '(run-command-recipe-example)) |
| 46 | + |
| 47 | + ;; prepare the buffer where most typing will happen |
| 48 | + (emacs-lisp-mode) |
| 49 | + (eldoc-mode -1)) |
| 50 | + |
| 51 | + :delay-between-steps 0.1 |
| 52 | + |
| 53 | + ;; give useful feedback during development |
| 54 | + :on-error (lambda (err) (message "Error while executing director script: %S" err)) |
| 55 | + |
| 56 | + :after-end (lambda () (kill-emacs)) |
| 57 | + |
| 58 | + :typing-style 'human |
| 59 | + |
| 60 | + :steps |
| 61 | + '( ;; don't rush |
| 62 | + (:wait 1) |
| 63 | + |
| 64 | + ;; define recipe for creating project |
| 65 | + (:eval (switch-to-buffer "*scratch*")) |
| 66 | + (:type "(defun run-command-recipe-example ()\r") |
| 67 | + (:wait 0.5) |
| 68 | + (:type "(list ") |
| 69 | + (:type "'( :command-name \"Create Rust project\"\r") |
| 70 | + (:wait 0.5) |
| 71 | + (:type ":command-line (lambda () (format \"cargo new %s\" (read-string \"Name: \"))))\r") |
| 72 | + (:type "))") |
| 73 | + (:eval (eval-buffer)) |
| 74 | + |
| 75 | + ;; execute first recipe |
| 76 | + (:wait 1) |
| 77 | + (:eval (dired demo-directory)) |
| 78 | + (:wait 1) |
| 79 | + (:type "\M-x") |
| 80 | + (:type "run-command") |
| 81 | + (:wait 0.5) |
| 82 | + (:type [return]) |
| 83 | + (:wait 1.5) |
| 84 | + (:type "cre") |
| 85 | + (:wait 1) |
| 86 | + (:type [return]) |
| 87 | + (:type "helloworld") |
| 88 | + (:wait 1.5) |
| 89 | + (:type [return]) |
| 90 | + (:wait 2) |
| 91 | + (:eval (delete-other-windows)) |
| 92 | + (:type "g") |
| 93 | + (:wait 2) |
| 94 | + |
| 95 | + ;; define second recipe |
| 96 | + (:eval (progn |
| 97 | + (switch-to-buffer "*scratch*") |
| 98 | + (goto-char (point-min)) |
| 99 | + (re-search-forward "(list ") |
| 100 | + (forward-sexp))) |
| 101 | + (:wait 2) |
| 102 | + (:type [return]) |
| 103 | + (:type "'( :command-name \"Run Rust project in watch mode\"\r") |
| 104 | + (:type ":command-line \"cargo watch --clear -x run\")") |
| 105 | + (:eval (eval-buffer)) |
| 106 | + (:wait 2) |
| 107 | + |
| 108 | + ;; execute second recipe |
| 109 | + (:eval (dired demo-directory)) |
| 110 | + (:wait 1) |
| 111 | + (:type [return]) |
| 112 | + (:wait 1) |
| 113 | + (:type [down]) |
| 114 | + (:wait 0.2) |
| 115 | + (:type [down]) |
| 116 | + (:wait 0.2) |
| 117 | + (:type [down]) |
| 118 | + (:wait 1) |
| 119 | + (:type [return]) |
| 120 | + (:wait 1) |
| 121 | + (:type [return]) |
| 122 | + (:wait 1) |
| 123 | + (:type "\M-x") |
| 124 | + (:type "run-command") |
| 125 | + (:wait 0.5) |
| 126 | + (:type [return]) |
| 127 | + (:wait 1) |
| 128 | + (:type "run") |
| 129 | + (:wait 1) |
| 130 | + (:type [return]) |
| 131 | + (:wait 2) |
| 132 | + |
| 133 | + ;; modify file |
| 134 | + (:eval (re-search-forward "world" nil t)) |
| 135 | + (:wait 2) |
| 136 | + (:call backward-kill-word) |
| 137 | + (:wait 1) |
| 138 | + (:type "Emacs") |
| 139 | + (:wait 2) |
| 140 | + (:call save-buffer) |
| 141 | + (:wait 4))) |
0 commit comments