/
demo-helm-org-ql.sh
executable file
·202 lines (160 loc) · 3.34 KB
/
demo-helm-org-ql.sh
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/bin/bash
# NOTE: Run "setxkbmap us" before running. See https://github.com/jordansissel/xdotool/issues/49
# NOTE: <f1> should be bound to this function in the Emacs window, like this:
# (global-set-key [f1]
# (defun gif-screencast-start-or-stop ()
# (interactive)
# (if gif-screencast-mode
# (progn
# (gif-screencast-stop)
# (setq gc-cons-threshold gc-cons-threshold-original))
# (setq gc-cons-threshold-original gc-cons-threshold)
# (setq gc-cons-threshold (* 1024 1024 500))
# (gif-screencast))))
# * Functions
function ensure_window_name {
if ! [[ $(xdotool getwindowfocus getwindowname) = $1 ]]
then
echo "Wrong window!" >&2
exit 1
fi
}
function key {
xdotool key "$@"
}
function input {
raw_input "$@"
# Correct for Helm's input idle delay by sending extra commands to
# make the screenshots be taken. Not sure why two are necessary,
# but they seem to be.
key ctrl+p
sleep 0.26
key ctrl+p
}
function raw_input {
xdotool type --delay 200 "$@"
}
# * Script
# No matter what I try, xdotool is not working properly to focus/raise/select
# a window. And for some bizarre reason, the "xdotool selectwindow" command
# outputs a completely different window ID than "xdotool search" outputs. In
# fact, the window ID it outputs does not even appear in the output of
# "xprop" for that window. I have no idea where it's getting that ID.
# So rather than cleanly selecting the proper window in the script, we have to
# do a hacky workaround by sleeping and checking the name of the active
# window.
sleep 3
ensure_window_name "data.org"
# Start gif-screencast
key F1
sleep 5
# M-x helm-org-ql RET
key alt+x
sleep 0.2
raw_input "helm-org-ql"
key ctrl+e
sleep 0.5
key Return
sleep 0.5
# "Emacs"
input Emacs
sleep 1
# "tags:Emacs"
key ctrl+a
input 'tags:'
sleep 1.5
# "tags&:Emacs,elisp"
key Left
input "&"
key ctrl+e
input ",elisp"
sleep 2
# "universe"
key ctrl+a ctrl+k
input "universe"
sleep 1
# "tags:universe,space"
key ctrl+a
input "tags:"
key ctrl+e
input ",space"
sleep 1
# "tags&:universe,space"
key ctrl+a Right Right Right Right
input "&"
sleep 2
# "deadline:"
key ctrl+a ctrl+k
input "deadline:"
sleep 2
# "deadline:to=2017-07-06"
input "to=2019-10-06"
sleep 2
# "deadline:to=2017-07-07"
key BackSpace
sleep 0.5
input "7"
sleep 2
# "scheduled:"
key ctrl+a ctrl+k
input "scheduled:"
sleep 2
# "scheduled:on=2017-07-04"
input "on=2019-10-04"
sleep 1
# "scheduled:on=2017-07-05"
key BackSpace
sleep 0.5
input "5"
sleep 2
# property:agenda-group
key ctrl+a ctrl+k
input "property:agenda-group"
sleep 2
# property:agenda-group=plans
input "=plans"
sleep 2
# category:ambition
key ctrl+a ctrl+k
input "category:ambition"
sleep 2
# ts-inactive:
key ctrl+a ctrl+k
input "ts-inactive:"
sleep 2
# closed:
key ctrl+a ctrl+k
input "closed:"
sleep 2
# Show match in persistent buffer
key ctrl+j
sleep 2
# closed:on=2017-07-04 (which is a day too early)
input "on=2019-10-04"
sleep 2
# closed:on=2017-07-05 (which is the closed date)
key BackSpace
input 5
sleep 2
# done:
key ctrl+a ctrl+k
input "done:"
sleep 2
# "todo:"
key ctrl+a ctrl+k
input "todo:"
sleep 2
# "todo: priority:"
input " priority:"
sleep 1
# "todo: priority:A"
input "A"
sleep 1
# "todo: priority:A,B"
input ",B"
sleep 2
# Save to a view buffer
key ctrl+x ctrl+s
sleep 2
# Stop the screencast
key F1