|
1 |
| -(load (expand-file-name "setup.el") t t t) |
| 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 | + )) |
2 | 15 |
|
3 | 16 | (director-run
|
4 | 17 | :version 1
|
5 | 18 | :before-start
|
6 | 19 | (lambda ()
|
7 |
| - (setq initial-scratch-message "") |
| 20 | + ;; load required features |
8 | 21 | (require 'run-command)
|
9 | 22 | (require 'helm)
|
10 |
| - (require 'helm-config) |
11 |
| - (helm-mode 1) |
| 23 | + (require 'term) |
| 24 | + |
| 25 | + ;; remove distractions |
| 26 | + (setq initial-scratch-message "") |
12 | 27 | (menu-bar-mode 'toggle)
|
13 |
| - (add-to-list 'run-command-recipes 'run-command-recipe-example) |
14 |
| - (erase-buffer) |
| 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 |
15 | 48 | (emacs-lisp-mode)
|
16 |
| - (eldoc-mode -1) |
17 |
| - (set-face-attribute 'helm-source-header nil :background "transparent" :foreground "dim gray" :weight 'normal) |
18 |
| - (set-face-attribute 'helm-selection nil :background "transparent") |
19 |
| - (set-face-attribute 'helm-match nil :foreground "brightred " :weight 'bold :underline t)) |
| 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 | + |
20 | 60 | :steps
|
21 |
| - '((:type "(defun run-command-recipe-example ()\r") |
22 |
| - (:type "(list\r") |
23 |
| - (:wait 1) |
24 |
| - (:type "'( :command-name \"say-hello\"\r") |
25 |
| - (:type ":command-line \"echo Hello, world!\"\r") |
26 |
| - (:type ":display \"Say hello\")\r") |
| 61 | + '( ;; don't rush |
27 | 62 | (:wait 1)
|
28 |
| - (:type "'( :command-name \"serve-dir-http\"\r") |
29 |
| - (:type ":command-line \"python3 -m http.server 8000\"\r") |
30 |
| - (:type ":display \"Serve current directory over HTTP\")))\r") |
31 |
| - (:call eval-last-sexp) |
| 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 |
32 | 76 | (:wait 1)
|
33 |
| - (:type "\n") |
34 |
| - (:type "(add-to-list 'run-command-recipes 'run-command-recipe-example)") |
35 |
| - (:call eval-last-sexp) |
| 77 | + (:eval (dired demo-directory)) |
36 | 78 | (:wait 1)
|
37 | 79 | (:type "\M-x")
|
38 | 80 | (:type "run-command")
|
| 81 | + (:wait 0.5) |
39 | 82 | (:type [return])
|
40 | 83 | (:wait 1.5)
|
41 |
| - (:assert (length= (window-list) 3)) |
42 |
| - (:type "say") |
| 84 | + (:type "cre") |
| 85 | + (:wait 1) |
| 86 | + (:type [return]) |
| 87 | + (:type "helloworld") |
43 | 88 | (:wait 1.5)
|
44 | 89 | (:type [return])
|
45 | 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) |
46 | 123 | (:type "\M-x")
|
47 |
| - (:type "run-command") |
| 124 | + (:type "run-command") |
| 125 | + (:wait 0.5) |
48 | 126 | (:type [return])
|
49 |
| - (:wait 1.5) |
50 |
| - (:assert (length= (window-list) 3)) |
51 |
| - (:type "http") |
52 |
| - (:wait 1.5) |
| 127 | + (:wait 1) |
| 128 | + (:type "run") |
| 129 | + (:wait 1) |
53 | 130 | (:type [return])
|
54 |
| - (:wait 4)) |
55 |
| - :delay-between-steps 0.1 |
56 |
| - :typing-style 'human |
57 |
| - :log-target '(file . "director.log") |
58 |
| - :on-failure (lambda () (kill-emacs 1)) |
59 |
| - :after-end (lambda () (kill-emacs))) |
| 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