-
Notifications
You must be signed in to change notification settings - Fork 32
/
demo-it.info
1409 lines (1086 loc) · 52.4 KB
/
demo-it.info
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
This is demo-it.info, produced by makeinfo version 5.2 from
demo-it.texi.
This manual is for demo-it (version 2.0, last updated 24 October 2016),
a project for running demonstrations within Emacs.
Copyright © 2016, Howard Abrams
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License,
Version 1.3 or any later version published by the Free Software
Foundation; with no Invariant Sections, with no Front-Cover Texts,
and with no Back-Cover Texts. A copy of the license is included in
the section entitled “GNU Free Documentation License”.
INFO-DIR-SECTION Emacs
START-INFO-DIR-ENTRY
* Demo It: (demo-it). Demonstrations made and shown in Emacs.
END-INFO-DIR-ENTRY
File: demo-it.info, Node: Top, Next: Basics, Up: (dir)
Demo It
*******
This manual is for demo-it (version 2.0, last updated 24 October 2016),
a project for running demonstrations within Emacs.
Copyright © 2016, Howard Abrams
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License,
Version 1.3 or any later version published by the Free Software
Foundation; with no Invariant Sections, with no Front-Cover Texts,
and with no Back-Cover Texts. A copy of the license is included in
the section entitled “GNU Free Documentation License”.
* Menu:
* Basics::
* Showing Presentations::
* Showing Files::
* Running Commands::
* Inserting Text::
* Extra Functions::
* Customization::
* Index::
— The Detailed Node Listing —
Basics
* Simple Example::
* Step Types::
* Demonstration Options::
* Running the Demo::
* Demo Modes::
Demo Modes
* demo-it-mode::
* demo-it-mode-adv::
Showing Presentations
* demo-it-presentation::
* demo-it-presentation-quit::
* demo-it-presentation-return::
* demo-it-presentation-return-noadvance::
* demo-it-presentation-advance::
* demo-it-presentation-highlight-phrase::
* demo-it-single-presentation::
Showing Files
* demo-it-load-file::
* demo-it-load-part-file::
* demo-it-load-fancy-file::
* demo-it-show-image::
* demo-it-compare-files::
Running Commands
* demo-it-start-shell::
* demo-it-run-in-shell::
* demo-it-show-shell::
Extra Functions
* demo-it-end::
* demo-it-step::
* demo-it-restep::
* demo-it-show-step::
* demo-it-hide-mode-line::
* demo-it-show-mode-line::
* demo-it-title-screen::
* demo-it-message-keybinding::
* demo-it-highlight-dwim::
Customization
* demo-it--keymap-mode-style::
* demo-it--shell-or-eshell::
* demo-it--open-windows::
* demo-it--open-windows-size::
* demo-it--text-scale::
* demo-it--start-fullscreen::
* demo-it--start-single-window::
* demo-it--presentation-hide-mode-line::
* demo-it--presentation-hide-org-markers::
* demo-it--presentation-variable-width::
* demo-it--presentation-hide-org-blocks::
* demo-it--insert-text-speed::
File: demo-it.info, Node: Basics, Next: Showing Presentations, Prev: Top, Up: Top
Basics
******
At the end of each sprint, each of us demonstrate our accomplishments.
These reviews often incorporate the following trifecta:
• Presentations explaining the technology and whatnot
• Source code reviews…correctly highlighted and interactive
• Executing the code in a shell
During my sprint reviews, I noticed I used my org-mode-formatted
files, eshell and source code buffers… In other words, I was always in
Emacs. However, fat-fingering or mentally burping delayed the
gratification for my audience while I laboriously typed. I originally
solved this problem by predefining each “step” as an Emacs Lisp
function, and then had another function execute each function when I hit
an _advance_ key (F12).
After I had amassed a small army of _helper functions_, I packaged it
as demo-it, because I lack the imagination to come up with anything more
clever.
See the following videos as examples of what can be done:
• Emacs: An Introduction for the Curious
(http://www.youtube.com/watch?v=B6jfrrwR10k)
• Literate DevOps Programming
(https://www.youtube.com/watch?v=dljNabciEGg)
• Learn You Some Lisp for Great Good
(http://www.youtube.com/watch?v=3T00X_sNg4Q)
* Menu:
* Simple Example::
* Step Types::
* Demonstration Options::
* Running the Demo::
* Demo Modes::
File: demo-it.info, Node: Simple Example, Next: Step Types, Up: Basics
Simple Example
==============
Using this project is a four step process:
1. Load the library in your own Elisp source code file
2. Create zero or more helper functions that “do things”, or use the
functions provided by this project.
3. Order the functions by calling (demo-it-create)
4. Call demo-it-start to begin the fun.
Press the space for each step, or call demo-it-end to end early.
For instance:
(require 'demo-it)
(defun my-demo-step/show-code ()
"Helper demo function that displays some source code and
advances the presentation at the same time."
(demo-it-load-side-window "example/example.py")
(demo-it-presentation-advance))
;; Order the functions and forms for this presentation:
(demo-it-create (demo-it-presentation "example/example.org")
my-demo-step/show-code
demo-it-presentation-return ; close file and advance
(demo-it-run-in-eshell "python example/example.py"))
(demo-it-start)
File: demo-it.info, Node: Step Types, Next: Demonstration Options, Prev: Simple Example, Up: Basics
Step Types
==========
The ‘demo-it-create’ is a macro that stores a single demonstration.
Calling it a second time replaces any previously created demonstrations.
Each “step” given to the demo-it-create macro can be one of the
following:
• Expression typically calling a helper function, for instance:
(demo-it-presentation "example/example.org")
• Name of a function to call that does multiple actions, for
instance:
demo-it-presentation-return
• a string referring to a key-binding to run, for instance:
"C-x C-f example.el "
• a property that affects demonstration behavior, see the *note
Demonstration Options: Demonstration Options. or *note
Customization: Customization.
Note: Any Emacs function can be called, either by name or as part of
an expression. These functions can be standard functions, supplied by
this demo-it package, or even ones you write. ;-)
File: demo-it.info, Node: Demonstration Options, Next: Running the Demo, Prev: Step Types, Up: Basics
Demonstration Options
=====================
The following list of keywords can be passed to demo-it-create to
override various *note Customization: Customization. settings:
• :simple-mode uses mode where space advances demonstration.
• :advance-mode uses mode where ‘F12’ advances demonstration.
• :use-shell chooses a standard shell command line interface when
running the *note demo-it-start-shell: demo-it-start-shell.
command.
• :use-shell chooses to use the built-in Emacs shell, which Emacs
uses find more comfortable when subjected to Windows systems.
• :eshell is an alias for :use-eshell.
• :shell is an alias for :user-shell.
• :windows-on-right defaults to opening auxiliary windows on the
right side of the frame (see *note demo-it-load-file: Showing
Files. and other helper functions for examples).
• :windows-on-side is an alias for :windows-on-right.
• :windows-on-left like the above, but defaults to the _left_ side of
the frame.
• :windows-below opens other windows at the bottom of the current
frame.
• :windows-above opens other windows at the top of the current frame.
• :fullscreen starts the demonstration with the current frame in
fullscreen mode.
• :single-window deletes other windows when started, and restores
those windows when the demonstration completes.
• :text-small starts presentations and other files in a slightly
smaller font that the current default. Yeah, it seems like a nice
idea to offer it, but I wonder if that is really helpful as a
default for a demonstration.
• :text-normal starts presentations and other loaded files in the
default font and size.
• :text-medium starts presentations and other loaded files in a
slight larger font size (technically scaled at 1).
• :text-large scales presentations and other loaded files at 2.
• :text-x-large scales loaded files at 3.
• :text-xx-large scales loaded files at 4 … go figure.
• :text-huge scales newly loaded files at 5. Got a big monitor or
very few words, I see.
• :insert-slow shell commands (and other calls to *note
demo-it-insert: Inserting Text. function) are inserted character by
character as if a hacker who never took a typing class in middle
school was typing the text.
• :insert-medium shell commands and other text are inserted as if a
medium-grade nerd with sufficient typing skills entered them.
• :insert-fast shell commands are entered like a typist, but to an
audience with the attention span of a gerbil.
• :insert-quickly shell commands are instantly entered, and the
audience is spared the gimmickry of yet-another Emacs feature.
• :show-mode-line leaves the mode-line alone for presentations and
files loaded by the demonstration package.
• :hide-mode-line hides the mode line so neckbeards pay attention to
your demonstration and quit straining to see what minor modes you
prefer. Still using paredit, I see.
• :hide-org-markers hides the asterisks, slashes, and other markup
characters that format text, but still shows the text in bold and
italics.
• :show-org-markers displays org-mode presentations as you wrote it.
• :variable-width uses a variable width font for presentations
because we want to make the vi users cry.
• :fixed-width displays org-mode presentations with your default
monospaced font for ultra nerd cred. You may need this feature if
source code in your presentation.
• :show-block-headers Should the #+begin and #+end markers be shown?
If you are trying to talk about _literate devops_ then, the answer
is yes, show them the way you see them.
• :hide-block-headers Hides the #+begin and #+end markers, but shows
the glorious source code inside. Currently, also shows the
surrounding #+HEADER entries, so beware.
File: demo-it.info, Node: Running the Demo, Next: Demo Modes, Prev: Demonstration Options, Up: Basics
Running the Demo
================
Once the demonstration has been created using ‘demo-it-create’, start it
by calling demo-it-start, as this will invoke the first step.
Typically, pressing the SPACE or RETURN key will advance to the next
step, but this depends on which of the *note Demo Modes: Demo Modes. was
chosen.
A deprecated version of demo-it-start allows you to pass in a list of
the steps, but creating this list can be problematic, so you’ll get more
mileage from the demo-it-create macro.
File: demo-it.info, Node: Demo Modes, Prev: Running the Demo, Up: Basics
Demo Modes
==========
Some demonstrations are so complete that pressing the space bar to
advance to each step is sufficient. However, this project can be used
as a _helper_ where each step merely sets up an environment where some
Emacs feature or source code can be elaborated with personal
prestidigitation. In this case, using the space and return to advance
the demonstration would limit what can be demonstrated manually.
So demo-it contains two minor modes, and starting a demonstration,
one of the following minor mode is chosen.
The choice is either made by setting the global customization value,
, or by passing the following keyword to demo-it-create.
• :simple-mode
• :advance-mode
* Menu:
* demo-it-mode::
* demo-it-mode-adv::
File: demo-it.info, Node: demo-it-mode, Next: demo-it-mode-adv, Up: Demo Modes
demo-it-mode
------------
The standard minor mode for demonstrations, has the following key
features:
• ‘Space’ or ‘Return’ advances to the next demonstration step
• ‘q’ turns off this mode, allowing you to type normally. Call
demo-it-mode to resume this mode
• ‘Q’ ends the demonstration
Note: In this mode, clicking the mouse on the right-side of the
screen will advance the demonstration, while clicking elsewhere,
repositions the cursor.
File: demo-it.info, Node: demo-it-mode-adv, Prev: demo-it-mode, Up: Demo Modes
demo-it-mode-adv
----------------
The advanced mode is used when the demo-it project simply sets up an
environment, where you want most keys available to enter commands
manually. This mode has the following key features:
• ‘F12’ advances to the next step in the demonstration
• ‘M-F12’ ends the demonstration
Why yes, while called _advanced_ is certainly has limited features.
File: demo-it.info, Node: Showing Presentations, Next: Showing Files, Prev: Basics, Up: Top
Showing Presentations
*********************
This project relies on other projects to do most of the heavy lifting
for using ‘org-mode’ files as the basis of a presentation, especially
the org-tree-slide (https://github.com/takaxp/org-tree-slide) project,
which displays each section under a header as the sole contents of a
buffer.
The following functions can be added to your demonstration to control
the display of the presentation.
* Menu:
* demo-it-presentation::
* demo-it-presentation-quit::
* demo-it-presentation-return::
* demo-it-presentation-return-noadvance::
* demo-it-presentation-advance::
* demo-it-presentation-highlight-phrase::
* demo-it-single-presentation::
File: demo-it.info, Node: demo-it-presentation, Next: demo-it-presentation-quit, Up: Showing Presentations
demo-it-presentation
====================
(file &optional size style section)
Loads the given ‘org-mode’ file as a presentation. This
automatically calls org-tree-slide
(https://github.com/takaxp/org-tree-slide) if available.
This function takes an optional ‘size’ parameter to specifies the
text scale. If ‘nil’, this defaults to the value set in *note
demo-it–text-scale: demo-it--text-scale. customization variable.
The optional ‘style’ parameter can be set to either :variable for
variable font pitch, :blocks for diminished headers on org-blocks, or
:both to enable both features. This is a deprecated, legacy feature,
since it is easier and clearer to either use the customization
variables:
• *note demo-it–presentation-variable-width:
demo-it--presentation-variable-width.
• *note demo-it–presentation-hide-org-blocks:
demo-it--presentation-hide-org-blocks.
The final parameter, ‘section’, is a string containing the name of an
‘org-mode’ header to specify as the first section to display.
File: demo-it.info, Node: demo-it-presentation-quit, Next: demo-it-presentation-return, Prev: demo-it-presentation, Up: Showing Presentations
demo-it-presentation-quit
=========================
Undoes the display settings made to the presentation buffer.
File: demo-it.info, Node: demo-it-presentation-return, Next: demo-it-presentation-return-noadvance, Prev: demo-it-presentation-quit, Up: Showing Presentations
demo-it-presentation-return
===========================
Makes the last running presentation the current buffer, deletes other
windows, and advances to the next ‘org-mode’ section.
File: demo-it.info, Node: demo-it-presentation-return-noadvance, Next: demo-it-presentation-advance, Prev: demo-it-presentation-return, Up: Showing Presentations
demo-it-presentation-return-noadvance
=====================================
Similar to calling *note demo-it-presentation-return:
demo-it-presentation-return. in that the latest specified presentation
becomes the current buffer and all other windows are deleted.
However, the presentation is not advanced to the next section.
File: demo-it.info, Node: demo-it-presentation-advance, Next: demo-it-presentation-highlight-phrase, Prev: demo-it-presentation-return-noadvance, Up: Showing Presentations
demo-it-presentation-advance
============================
Advances the currently running presentation to the next section, but
doesn’t change focus to the window. Any further commands happen in the
current window.
This function is useful if a presentation discusses multiple
commands, then you can advance through them while other commands
actually perform the action (like executing commands in a shell).
As an example, the following demonstration will _live-code_ while the
presentation discusses each part:
(demo-it-create (demo-it-presentation "elisp-cookbook.org")
(demo-it-load-file "elisp-example.el")
; Advance to next section that talks about defun:
demo-it-presentation-advance
; Start coding an Emacs Lisp function:
(demo-it-insert "def") ; Begin yasnippet template
"TAB" ; Trigger yasnippet
(demo-it-insert "some-func") ; The function name
"TAB" ; Advance to parameters
(demo-it-insert "x y") ; parameters
"TAB" ; Advance to parameters
(demo-it-insert "Example function.")
"TAB" ; Advance to interactive
(demo-it-insert " ") ; No need for this section
"TAB" ; Advance to function body
; Advance to next section to talk about if statements
demo-it-presentation-advance
(demo-it-insert "if") ; Begin next template
"TAB" ; Trigger yasnippet
(demo-it-insert "(eq x y)") ; predicate expression
"TAB" ; Advance to if body
) ;; etc.
File: demo-it.info, Node: demo-it-presentation-highlight-phrase, Next: demo-it-single-presentation, Prev: demo-it-presentation-advance, Up: Showing Presentations
demo-it-presentation-highlight-phrase
=====================================
Given a string parameter, ‘phrase’, as a regular expression, this
function highlights a _phrase_ in the presentation buffer without
changing the current buffer. This is useful to highlight bullet point
items while executing appropriate code.
The ‘color’ parameter is a face from the ‘hi-lock’ project, e.g.
:hi-yellow.
Note: This unhighlights previous highlighted phrases. Call
‘demo-it-presentation-unhighlight-all’ if you just want to remove the
highlighting.
File: demo-it.info, Node: demo-it-single-presentation, Prev: demo-it-presentation-highlight-phrase, Up: Showing Presentations
demo-it-single-presentation
===========================
Demonstration similar to calling *note demo-it-presentation:
demo-it-presentation, in that it presents an ‘org-mode’ file as a
full-screen presentation. In this form, the demonstration doesn’t do
anything more than advance through the presentation, and calling either
‘demo-it-create’ or ‘demo-it-start’ is not needed.
This function begins a minor-mode where the space or return key
advances the presentation to the next section. In this mode, the ‘q’
disables this mode, and ‘Q’ quits the demonstration and presentation.
While the standard customization variables configure the presentation
display style, this function accepts a ‘size’ parameter to set the text
scaling size.
The optional ‘style’ parameter can be set to either :variable for
variable font pitch, :blocks for diminished headers on org-blocks, or
:both to enable both features.
File: demo-it.info, Node: Showing Files, Next: Running Commands, Prev: Showing Presentations, Up: Top
Showing Files
*************
While a simple call to find-file is often sufficient to display a file
in Emacs, the following functions can be helpful for showing files and
source code during a demonstration.
These functions often take the following optional parameters, and in
the spirit of DRY, we will specify them here:
The optional ‘side’ parameter specifies the side of the frame to
display the new window. Acceptable values can one of the following
keywords:
• :above
• :below
• :left
• :right
• :side is a synomym for :right
• :none loads the file in the current buffer.
If ‘nil’, defaults is to use the customized value of *note
demo-it–open-windows: demo-it--open-windows.
The optional ‘size’ parameter takes an integer and specifies the text
scale. If ‘nil’, this defaults to the value set in *note
demo-it–text-scale: demo-it--text-scale. customization variable.
The ‘width’ parameter specifies the size of the new window, which is
either the width of a side window, or the height if the window is :above
or :below.
* Menu:
* demo-it-load-file::
* demo-it-load-part-file::
* demo-it-load-fancy-file::
* demo-it-show-image::
* demo-it-compare-files::
File: demo-it.info, Node: demo-it-load-file, Next: demo-it-load-part-file, Up: Showing Files
demo-it-load-file
=================
Calling this function with a file, first splits the root frame into a
side window and loads the file into that window.
Keep in mind, that calling it a second time will result in further
splitting of the root window. Call delete-window or *note
demo-it-presentation-return-noadvance:
demo-it-presentation-return-noadvance, or close the window while also
updating the presentation with *note demo-it-presentation-return:
demo-it-presentation-return.
The optional parameters this function takes are *note described
above: Showing Files.
File: demo-it.info, Node: demo-it-load-part-file, Next: demo-it-load-fancy-file, Prev: demo-it-load-file, Up: Showing Files
demo-it-load-part-file
======================
Splits window and loads a file, but also narrows to particular region.
If the ‘type’ parameter is set to :line, then the ‘start’ and ‘end’
parameters specify the first and last lines of the region to narrow. If
‘type’ is set to :char, then ‘start’ and ‘end’ refer to specific
character positions.
The other optional parameters this function takes are *note described
above: Showing Files.
See *note demo-it-load-fancy-file: demo-it-load-fancy-file. for an
alternative version.
File: demo-it.info, Node: demo-it-load-fancy-file, Next: demo-it-show-image, Prev: demo-it-load-part-file, Up: Showing Files
demo-it-load-fancy-file
=======================
Splits the root frame and loads a ‘file’ specified by the first
parameter in that window (see *note demo-it-load-file:
demo-it-load-file.), however, this function can use the fancy narrow
(https://github.com/Malabarba/fancy-narrow) to highlight part of the
buffer (if it has been loaded), otherwise, it behaves like *note
demo-it-load-part-file: demo-it-load-part-file. and narrows to the area
specified.
If the second parameter, ‘type’ is a string that specifies a function
name (available via ‘imenu’), then it highlights that function.
If ‘type’ is a :line, then the next two parameters, ‘start’ and ‘end’
specifies the beginning or ending lines.
If ‘type’ is :char, then ‘start’ and ‘end’ are exact buffer
positions, which you can determine by evaluating (‘M-;’) the following
expression:
(kill-new (int-to-string (point)))
The optional parameters ‘side’ and ‘size’ are *note described above:
Showing Files.
Note: This function simply detects if the ‘fancy-narrow’ package has
been loaded. The demonstration will need to issue a ‘require’.
File: demo-it.info, Node: demo-it-show-image, Next: demo-it-compare-files, Prev: demo-it-load-fancy-file, Up: Showing Files
demo-it-show-image
==================
Loads a file as an image (or any other special file) in another window
without a mode line or fringe.
The optional parameters this function takes are *note described
above: Showing Files.
File: demo-it.info, Node: demo-it-compare-files, Prev: demo-it-show-image, Up: Showing Files
demo-it-compare-files
=====================
Loads two files in either two windows on top of each other on the right
side of the screen, or two windows below (depending on the value of the
‘side’, which should either be :below or :side.
The other optional parameter, ‘size’ is *note described above:
Showing Files.
File: demo-it.info, Node: Running Commands, Next: Inserting Text, Prev: Showing Files, Up: Top
Running Commands
****************
What Emacs-sponsored demonstration would be complete without being able
to run the application you created. While your demonstration could
easily call ‘shell-command’, starting a shell, and having Emacs _type_
the commands makes a demonstration appear more real and interactive.
The _typing_ abilities when inserting text are not very realistic, as
it simply picks a random delay between each letter. What is lacking,
however, it clacking should of the switches going off while the letter
appears (PRs are acceptable).
The following functions can be added to your demonstration to enter
commands in a shell (both your default shell, as well as the Eshell is
supported by setting the *note demo-it–shell-or-eshell:
demo-it--shell-or-eshell. variable or giving demo-it-create one of the
following keyword configurations:
• :use-shell
• :use-eshell
* Menu:
* demo-it-start-shell::
* demo-it-run-in-shell::
* demo-it-show-shell::
File: demo-it.info, Node: demo-it-start-shell, Next: demo-it-run-in-shell, Up: Running Commands
demo-it-start-shell
===================
Starts a shell or eshell instance, in a particular directory and
executes the given command. The command can be entered into the shell
with a slight random delay intended to mimic a person typing. This
speed of this is specified by *note demo-it–insert-text-speed:
demo-it--insert-text-speed.
The optional ‘name’ parameter labels the buffer, and defaults to
‘Shell’.
The other optional parameters this function takes are *note described
above: Showing Files.
File: demo-it.info, Node: demo-it-run-in-shell, Next: demo-it-show-shell, Prev: demo-it-start-shell, Up: Running Commands
demo-it-run-in-shell
====================
Run shell command in a shell previously started with *note
demo-it-start-shell: demo-it-start-shell. If a ‘name’ is not specified,
it defaults to name, ‘Shell’.
The optional ‘speed’ parameter overrides the customization value set
by *note demo-it–insert-text-speed: demo-it--insert-text-speed, or the
text-speed related keyword given to demo-it-create.
File: demo-it.info, Node: demo-it-show-shell, Prev: demo-it-run-in-shell, Up: Running Commands
demo-it-show-shell
==================
Call to display the shell buffer if the shell window of a given ‘name’
has been hidden. If ‘name’ is not specified, it defaults to ‘Shell’.
The other optional parameters this function takes are *note described
above: Showing Files.
File: demo-it.info, Node: Inserting Text, Next: Extra Functions, Prev: Running Commands, Up: Top
Inserting Text
**************
Perhaps you want to regale your audience with your programmatic prowess,
but don’t dare attempt to do live-coding in front of live individuals?
Yes, even creating a series of yasnippets can result in some serious
embarrassment (and compiler errors) if you fat-finger any of the fields.
Have no fear, just create a series of entries that contains calls to
‘demo-it-insert’, as this function inserts a string into the current
buffer as if you were typing it by hand (this is called by *note
demo-it-run-in-shell: demo-it-run-in-shell.).
The following demo-it example uses this function as well as the def
yasnippet for Ruby and particular keystrokes to move from field to
field:
(demo-it-create (find-file "foobar.rb")
(demo-it-insert "def")
(yas-expand)
(demo-it-insert "hello")
"TAB TAB"
(demo-it-insert "name")
"TAB"
(demo-it-insert "\"Hello, #{name}\"" :fast))
The optional ‘speed’ parameter is *note described above: Showing
Files.
Note: The previous version of demo-it offered specialized feature for
inserting text where each string to entered was put in a hashmap,
‘demo-it-text-entries’, and the entries were inserted with calls to a
dedicated function, ‘demo-it-insert-text’. However, the above seems to
work just as well without a special function, so it has been deprecated
and removed.
File: demo-it.info, Node: Extra Functions, Next: Customization, Prev: Inserting Text, Up: Top
Extra Functions
***************
The following are useful functions that don’t fit in the previous
sections, so consider this the _miscellaeous_ section.
* Menu:
* demo-it-end::
* demo-it-step::
* demo-it-restep::
* demo-it-show-step::
* demo-it-hide-mode-line::
* demo-it-show-mode-line::
* demo-it-title-screen::
* demo-it-message-keybinding::
* demo-it-highlight-dwim::
File: demo-it.info, Node: demo-it-end, Next: demo-it-step, Up: Extra Functions
demo-it-end
===========
Calling this command ends the current demonstration by disabling the
mode (see *note Demo Modes: Demo Modes.), resetting the values inflicted
on the presentation buffer as well as restoring the window arrangement
to their original glory before demo-it-start was called.
File: demo-it.info, Node: demo-it-step, Next: demo-it-restep, Prev: demo-it-end, Up: Extra Functions
demo-it-step
============
This function is typically called by one of the *note Demo Modes: Demo
Modes. to execute the next step in the current demonstration.
However, this function can be called to jump to a particular STEP by
specifying a step number to the optional parameter, ‘step’. This can
also be done with a prefix, e.g. C-6 <F12> to run the 6th step.
Keep in mind that normally step functions expect a particular state
to be established, so calling this function to jump to a particular step
may not work as intended.
Why yes, we do want to figure out a good mechanism for establishing a
state for each called step, but that be a wee-bit challenging.
File: demo-it.info, Node: demo-it-restep, Next: demo-it-show-step, Prev: demo-it-step, Up: Extra Functions
demo-it-restep
==============
Re-executes the previous step in the current demonstration.
Note, this doesn’t handle the concept of the state of the Emacs
system, so calling this function interactively does not rewind and
re-executes, it just re-executes given the current Emacs state.
File: demo-it.info, Node: demo-it-show-step, Next: demo-it-hide-mode-line, Prev: demo-it-restep, Up: Extra Functions
demo-it-show-step
=================
Displays a message about the expected function (that is, the function
that _will be run_) during the next step. This can be useful when
you’ve lost your way, and ask yourself, How did I get here?
Of course, you may ask yourself, How do I work this?
And you may ask yourself, Where is that large automobile?
And you may tell yourself, This is not my beautiful house!
And you may tell yourself, This is not my beautiful wife!
File: demo-it.info, Node: demo-it-hide-mode-line, Next: demo-it-show-mode-line, Prev: demo-it-show-step, Up: Extra Functions
demo-it-hide-mode-line
======================
Hides the mode line for a current buffer. This is done by setting the
‘mode-line-format’ to ‘nil’, but also saves off the value so that it can
be restored by calling *note demo-it-show-mode-line:
demo-it-show-mode-line.
File: demo-it.info, Node: demo-it-show-mode-line, Next: demo-it-title-screen, Prev: demo-it-hide-mode-line, Up: Extra Functions
demo-it-show-mode-line
======================
Shows the mode line of the current buffer, if it was previously hidden
with a call to *note demo-it-hide-mode-line: demo-it-hide-mode-line.
File: demo-it.info, Node: demo-it-title-screen, Next: demo-it-message-keybinding, Prev: demo-it-show-mode-line, Up: Extra Functions
demo-it-title-screen
====================
Displays a file as the demonstration’s title, e.g. displayed with a
larger-than-life font without a mode line, etc. Typically, a
specially-formatted org-mode file would do the job, but any file,
including an image will work.
The ‘size’ parameter specifies the text scale, which ignores the
*note demo-it–text-scale: demo-it--text-scale. customization setting and
defaults to :huge (or 5x your normal text font size).
File: demo-it.info, Node: demo-it-message-keybinding, Next: demo-it-highlight-dwim, Prev: demo-it-title-screen, Up: Extra Functions
demo-it-message-keybinding
==========================
When demonstrating Emacs features, you may want to display the keystroke
you type. Yes, you could (and probably should) use a package like
mwe-log-commands
(http://www.foldr.org/~michaelw/emacs/mwe-log-commands.el) by Michael
Weber, but you can’t really use that sort of feature with demo-it, as
you’d just log a bunch of spacebars bound to *note demo-it-step:
demo-it-step.
What you really want is to display the key you _wanted_ to type. For
that, you’ll want to end your _step function_ with a call to
‘demo-it-message-keybinding’, as it will take two strings, where the
first one is the “key” and the other is a function or command that it
normally calls.
For instance:
(defun my-demo/dired-a-directory ()
"Opens a `dired' buffer on a particular directory.
This is a step function that I add to demo-it-create."
(dired (expand-file-name "~/work"))
(demo-it-message-keybinding "C-x d" "dired"))
This sort of _step function_ would be added to demo-it-create as a
simple symbol, like:
(demo-it-create ;; :keybindings
;; other functions and expressions
my-demo/dired-a-directory
;; other functions and expressions
)
File: demo-it.info, Node: demo-it-highlight-dwim, Prev: demo-it-message-keybinding, Up: Extra Functions
demo-it-highlight-dwim
======================
Can use the fancy-narrow (https://github.com/Malabarba/fancy-narrow)
package to highlight a particular _section_. If the package is not
available, it simply _narrows_ to that area. If called interactively,
this highlights the region (if active) or the current function.
If the first parameter, ‘type-or-fn’ is a string, this specifies the
name of a function to highlight.
If it is a :line, then the next two parameters, ‘start’ and ‘end’
specifies the beginning or ending lines.
If it is :char, then ‘start’ and ‘end’ are exact buffer positions,
which you can determine by evaluating (‘M-;’) the following expression:
(kill-new (int-to-string (point)))
If ‘type-or-fn’ is ‘nil’ and the region is active, highlight the
region.
If none of the following match, simply select the function the point
is currently in.
Note: While this function checks to see if the package is available
and loaded, it does not actually do the loading (or the installing of
the package), for that, you will need to do something like:
(require 'fancy-narrow)
File: demo-it.info, Node: Customization, Next: Index, Prev: Extra Functions, Up: Top
Appendix A Customization
************************
The following is a list of custom variables that can be set through the
standard Emacs customization feature (under the demo-it group). Note,
each custom value may be overridden with a magic symbol to the *note
demo-it-create: Step Types. macro or with a parameter to many functions.
* Menu:
* demo-it--keymap-mode-style::
* demo-it--shell-or-eshell::