-
Notifications
You must be signed in to change notification settings - Fork 5
/
Org-Mode_Fundamentals.html
1667 lines (1444 loc) · 52.6 KB
/
Org-Mode_Fundamentals.html
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
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2018-12-12 Wed 20:09 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>‎</title>
<meta name="generator" content="Org mode" />
<meta name="author" content="Grant Rettke" />
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.equation-container {
display: table;
text-align: center;
width: 100%;
}
.equation {
vertical-align: middle;
}
.equation-label {
display: table-cell;
text-align: right;
vertical-align: middle;
}
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { width: 90%; }
/*]]>*/-->
</style>
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2018 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
</head>
<body>
<div id="content">
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#orgabd7b5e">1. Org-Mode Fundamentals</a>
<ul>
<li><a href="#orgfb85fc2">1.1. Literate Programming</a>
<ul>
<li><a href="#org61aba16">1.1.1. Helper Functions</a></li>
<li><a href="#org0ce63f9">1.1.2. Identity</a></li>
<li><a href="#orgcd9b66c">1.1.3. Tangling</a></li>
<li><a href="#orgf96c55a">1.1.4. Evaluating</a></li>
<li><a href="#org0a7e6f8">1.1.5. Weaving</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<p>
Never compile this.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="org8f194a8"><span class="org-comment-delimiter">;; </span><span class="org-comment">-*- no-byte-compile: t; -*-</span>
</pre>
</div>
<div id="outline-container-orgabd7b5e" class="outline-2">
<h2 id="orgabd7b5e"><span class="section-number-2">1</span> Org-Mode Fundamentals</h2>
<div class="outline-text-2" id="text-1">
<pre class="example">
ID: orgmode:gcr:vela:7E71A009-4DD3-4296-9851-293BC71D2DFF
</pre>
<p>
Configure Org-Mode core functionality to compile this system.
</p>
<p>
Sysop is likely to use this periodically.
</p>
<p>
Start EMACS with this command:
</p>
<pre class="example">
emacs --debug-init --no-init-file --no-splash --background-color white --foreground-color black --vertical-scroll-bars --eval '(switch-to-buffer "*Messages*")' --name FND-TEST --title FND-TEST --load ~/src/help/.org-mode-fundamentals.emacs.el &
</pre>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="orgc4a4f4f">(load-file <span class="org-string">"~/src/help/.org-mode-ecm.emacs.el"</span>)
</pre>
</div>
</div>
<div id="outline-container-orgfb85fc2" class="outline-3">
<h3 id="orgfb85fc2"><span class="section-number-3">1.1</span> Literate Programming</h3>
<div class="outline-text-3" id="text-1-1">
<pre class="example">
ID: orgmode:gcr:vela:8510C876-F644-4804-9F87-54A0B44DBA6A
</pre>
<p>
This system enables you to perform 3 Literate Document activities
</p>
<ul class="org-ul">
<li>Tangling</li>
<li>Evaluating</li>
<li>Weaving</li>
</ul>
<p>
Combined they provide a rich Literate Programming environment.
</p>
<p>
These activities are not performed interactively by the user. They are automatic
operations that occur as a result of the configuration by the document itself.
</p>
<p>
The following is the guide for the default configuration of this system and how
it behaves.
</p>
<p>
Key:
</p>
<ul class="org-ul">
<li>Columns
<dl class="org-dl">
<dt>S</dt><dd>Source document modified?</dd>
<dt>T</dt><dd>Destination tangled-document modified?</dd>
<dt>W</dt><dd>Destination weaved-document modified?</dd>
<dt>C</dt><dd>Source-Block Evaluation occurred?</dd>
<dt>O</dt><dd>Org-Macro Expansion occurred?</dd>
</dl></li>
</ul>
<table border="2" cellspacing="0" cellpadding="6" rules="all" frame="border">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Activity</th>
<th scope="col" class="org-left">S</th>
<th scope="col" class="org-left">T</th>
<th scope="col" class="org-left">W</th>
<th scope="col" class="org-left">C</th>
<th scope="col" class="org-left">O</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left">Tangling</td>
<td class="org-left">F</td>
<td class="org-left">T</td>
<td class="org-left">F</td>
<td class="org-left">F</td>
<td class="org-left">F</td>
</tr>
<tr>
<td class="org-left">Evaluating</td>
<td class="org-left">T</td>
<td class="org-left">F</td>
<td class="org-left">F</td>
<td class="org-left">T</td>
<td class="org-left">F</td>
</tr>
<tr>
<td class="org-left">Weaving</td>
<td class="org-left">F</td>
<td class="org-left">F</td>
<td class="org-left">T</td>
<td class="org-left">F!</td>
<td class="org-left">T</td>
</tr>
</tbody>
</table>
<p>
They are separate and distinct operations.
</p>
<p>
"Programming" is logically an activity that is the combination of these 3
activites. It is interactively performed by Sysop. It is not a distinct
or isolated operation. Results of one activity exist here and serve as inputs to
another activity.
</p>
<ul class="org-ul">
<li>Note about <code>F!</code>: Weaving Source-Block Evaluation occurred?<sup>*</sup>
<ul class="org-ul">
<li>Source block evaluation on export is disabled using header arguments:
those source blocks will never be evaluated on weaving</li>
<li>However the <i>ability</i> for them evaluate on weaving <i>is</i> enabled so that weaved
source blocks can be replaced by their result value. This gives a kind of
template system. More details <a href="#orgc4783d9">here</a></li>
</ul></li>
</ul>
</div>
<div id="outline-container-org61aba16" class="outline-4">
<h4 id="org61aba16"><span class="section-number-4">1.1.1</span> Helper Functions</h4>
<div class="outline-text-4" id="text-1-1-1">
<pre class="example">
ID: orgmode:gcr:vela:B14776FD-6835-4D1D-BCD3-50D56555423C
</pre>
<p>
Help configure Org-Mode.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="orgee2c6e3">(<span class="org-keyword">defun</span> <span class="org-function-name">help/set-org-babel-default-header-args</span> (property value)
<span class="org-doc">"Easily set system header arguments in org mode.</span>
<span class="org-doc">PROPERTY is the system-wide value that you would like to modify.</span>
<span class="org-doc">VALUE is the new value you wish to store.</span>
<span class="org-doc">Attribution: URL `http://orgmode.org/manual/System_002dwide-header-arguments.html#System_002dwide-header-arguments'"</span>
(<span class="org-keyword">setq</span> org-babel-default-header-args
(cons (cons property value)
(assq-delete-all property org-babel-default-header-args))))
(<span class="org-keyword">defun</span> <span class="org-function-name">help/set-org-babel-default-inline-header-args</span> (property value)
<span class="org-doc">"See `</span><span class="org-doc"><span class="org-constant">help/set-org-babel-default-header-args</span></span><span class="org-doc">'; same but for inline header args."</span>
(<span class="org-keyword">setq</span> org-babel-default-inline-header-args
(cons (cons property value)
(assq-delete-all property org-babel-default-inline-header-args))))
(<span class="org-keyword">defun</span> <span class="org-function-name">help/set-org-babel-default-header-args:R</span> (property value)
<span class="org-doc">"See `</span><span class="org-doc"><span class="org-constant">help/set-org-babel-default-header-args</span></span><span class="org-doc">'; same but for R.</span>
<span class="org-doc">This is a copy and paste. Additional languages would warrant a refactor."</span>
(<span class="org-keyword">setq</span> org-babel-default-header-args:R
(cons (cons property value)
(assq-delete-all property org-babel-default-header-args:R))))
(<span class="org-keyword">defun</span> <span class="org-function-name">help/set-org-babel-default-header-args:ditaa</span> (property value)
<span class="org-doc">"See `</span><span class="org-doc"><span class="org-constant">help/set-org-babel-default-header-args</span></span><span class="org-doc">'; same but for ditaa.</span>
<span class="org-doc">This is a copy and paste. Additional languages would warrant a refactor."</span>
(<span class="org-keyword">setq</span> org-babel-default-header-args:ditaa
(cons (cons property value)
(assq-delete-all property org-babel-default-header-args:ditaa))))
(<span class="org-keyword">defun</span> <span class="org-function-name">help/set-org-babel-default-header-args:dot</span> (property value)
<span class="org-doc">"See `</span><span class="org-doc"><span class="org-constant">help/set-org-babel-default-header-args</span></span><span class="org-doc">'; same but for dot.</span>
<span class="org-doc">This is a copy and paste. Additional languages would warrant a refactor."</span>
(<span class="org-keyword">setq</span> org-babel-default-header-args:dot
(cons (cons property value)
(assq-delete-all property org-babel-default-header-args:dot))))
(<span class="org-keyword">defun</span> <span class="org-function-name">help/set-org-babel-default-header-args:plantuml</span> (property value)
<span class="org-doc">"See `</span><span class="org-doc"><span class="org-constant">help/set-org-babel-default-header-args</span></span><span class="org-doc">'; same but for plantuml.</span>
<span class="org-doc">This is a copy and paste. Additional languages would warrant a refactor."</span>
(<span class="org-keyword">setq</span> org-babel-default-header-args:plantuml
(cons (cons property value)
(assq-delete-all property org-babel-default-header-args:plantuml))))
(<span class="org-keyword">defun</span> <span class="org-function-name">help/org-toggle-macro-markers</span> ()
(<span class="org-keyword">interactive</span>)
(<span class="org-keyword">let</span> ((old org-hide-macro-markers)
(new (not org-hide-macro-markers)))
(<span class="org-keyword">setq</span> org-hide-macro-markers new)
(message <span class="org-string">"Just changed org-hide-macro-markers from %s to %s"</span> old new)
(font-lock-mode)
(font-lock-mode)))
(<span class="org-keyword">defun</span> <span class="org-function-name">help/org-prp-hdln</span> ()
<span class="org-doc">"Visit every Headline. If it doesn't have an ID property then add one and</span>
<span class="org-doc"> assign it a UUID. Attribution: URL</span>
<span class="org-doc"> `</span><span class="org-doc"><span class="org-constant">http://article.gmane.org/gmane.emacs.orgmode/99738</span></span><span class="org-doc">'. It is OK to leave the</span>
<span class="org-doc"> colon separator in here because these are never used as Source-Blocks and</span>
<span class="org-doc"> the rest of the code expects the colon separator."</span>
(<span class="org-keyword">interactive</span>)
(<span class="org-keyword">save-excursion</span>
(goto-char (point-min))
(<span class="org-keyword">dolist</span> (p (nreverse
(org-element-map (org-element-parse-buffer <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">headline</span>) <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">headline</span>
(<span class="org-keyword">lambda</span> (headline) (org-element-property <span class="org-builtin">:begin</span> headline)))))
(goto-char p)
(org-id-get-create))
(save-buffer)))
(<span class="org-keyword">defun</span> <span class="org-function-name">help/org-id-new</span> ()
<span class="org-doc">"Re-purposing `</span><span class="org-doc"><span class="org-constant">org-id</span></span><span class="org-doc">' hit a snag when colons were forbidden in Source-Block</span>
<span class="org-doc"> names. Adding support for a user-defined Org-Id separator would have fixed</span>
<span class="org-doc"> this but with no benefit to Org-Id. So this function removes the colon</span>
<span class="org-doc"> instead.</span>
<span class="org-doc"> "</span>
(<span class="org-keyword">interactive</span>)
(<span class="org-keyword">let*</span> ((gend (org-id-new))
(newid (replace-regexp-in-string <span class="org-string">":"</span> <span class="org-string">"_"</span> gend)))
newid))
(<span class="org-keyword">defun</span> <span class="org-function-name">help/org-prp-src-blk</span> ()
<span class="org-doc">"If it doesn't have a NAME property then add one and</span>
<span class="org-doc"> assign it a UUID. Attribution: URL `</span><span class="org-doc"><span class="org-constant">http://article.gmane.org/gmane.emacs.orgmode/99740</span></span><span class="org-doc">'"</span>
(<span class="org-keyword">interactive</span>)
(help/org-2every-src-block
<span class="org-highlight-quoted-quote">#'</span>(lambda (element)
(<span class="org-keyword">if</span> (not (org-element-property <span class="org-builtin">:name</span> element))
(<span class="org-keyword">let</span> ((i (org-get-indentation)))
(beginning-of-line)
(<span class="org-keyword">save-excursion</span> (insert <span class="org-string">"#+NAME: "</span> (help/org-id-new) <span class="org-string">"\n"</span>))
(indent-to i)
(forward-line 2))))))
(<span class="org-keyword">defconst</span> <span class="org-variable-name">help/org-special-pre</span> <span class="org-string">"^\s*#[+]"</span>)
(<span class="org-keyword">defun</span> <span class="org-function-name">help/org-2every-src-block</span> (fn)
<span class="org-doc">"Visit every Source-Block and evaluate `</span><span class="org-doc"><span class="org-constant">FN</span></span><span class="org-doc">'."</span>
(<span class="org-keyword">interactive</span>)
(<span class="org-keyword">save-excursion</span>
(goto-char (point-min))
(<span class="org-keyword">let</span> ((case-fold-search t))
(<span class="org-keyword">while</span> (re-search-forward (concat help/org-special-pre <span class="org-string">"BEGIN_SRC"</span>) nil t)
(<span class="org-keyword">let</span> ((element (org-element-at-point)))
(<span class="org-keyword">when</span> (eq (org-element-type element) <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">src-block</span>)
(funcall fn element)))))
(save-buffer)))
(<span class="org-keyword">defun</span> <span class="org-function-name">help/org-babel-demarcate-block</span> ()
<span class="org-doc">"Add a NAME property then assign it a UUID."</span>
(<span class="org-keyword">interactive</span>)
(org-babel-demarcate-block)
(insert <span class="org-string">"#+name: "</span> (help/org-id-new))
(beginning-of-line)
(insert <span class="org-string">"\n"</span>))
</pre>
</div>
</div>
</div>
<div id="outline-container-org0ce63f9" class="outline-4">
<h4 id="org0ce63f9"><span class="section-number-4">1.1.2</span> Identity</h4>
<div class="outline-text-4" id="text-1-1-2">
<pre class="example">
ID: orgmode:gcr:vela:25F4226F-2EB2-48EC-A4D5-56DD5CCC753E
</pre>
<p>
A Headline's primary key is <code>ID</code>. Use <code>org-id</code> to manage it.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="orgdf2a217">(<span class="org-keyword">require</span> <span class="org-highlight-quoted-quote">'</span><span class="org-constant">org-id</span>)
</pre>
</div>
<p>
In Links: Never use <code>ID</code> or <code>CUSTOM_ID</code>; always use the file name and text to make
it accessible outside of Emacs.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="orgc5af2f2">(<span class="org-keyword">setq</span> org-id-link-to-org-use-id <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">nil</span>)
</pre>
</div>
<p>
Make sure that <code>ID</code> is always unique, portable, and easy to maintain by
</p>
<ul class="org-ul">
<li>Using an acceptable prefix
<ul class="org-ul">
<li>Memorable
<ul class="org-ul">
<li>So you can remember where you created it and when</li>
<li>So you can share it and let the recipient know (in theory useful)</li>
<li>So you can enable a non Emacs/Org-Mode user to work with the tangled
code referencing it's origin</li>
</ul></li>
<li>Valid
<ul class="org-ul">
<li>Must be both LaTeX label and XHTML identifier compliant
<ul class="org-ul">
<li><code>org-lint</code> checks for this</li>
</ul></li>
</ul></li>
</ul></li>
<li>Include the current login</li>
<li>Include the current domain</li>
<li>Use a UUID</li>
</ul>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="org0b71e18">(<span class="org-keyword">setq</span> org-id-prefix (concat <span class="org-string">"org_"</span> (user-real-login-name) <span class="org-string">"_"</span> (help/get-timestamp-no-colons) <span class="org-string">"_"</span> (system-name)))
(<span class="org-keyword">setq</span> org-id-method <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">uuid</span>)
</pre>
</div>
</div>
</div>
<div id="outline-container-orgcd9b66c" class="outline-4">
<h4 id="orgcd9b66c"><span class="section-number-4">1.1.3</span> Tangling</h4>
<div class="outline-text-4" id="text-1-1-3">
<pre class="example">
ID: orgmode:gcr:vela:267EEDED-1367-405F-807C-B3C489045704
</pre>
<p>
<code>ID</code> and <code>NAME</code> are essential for successful <code>LP</code> using <code>org-babel-tangle-jump-to-org</code>.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="orgb450997">(add-hook <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">org-babel-pre-tangle-hook</span> <span class="org-highlight-quoted-quote">#'</span><span class="org-highlight-quoted-symbol">help/org-prp-hdln</span>)
(add-hook <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">org-babel-pre-tangle-hook</span> <span class="org-highlight-quoted-quote">#'</span><span class="org-highlight-quoted-symbol">help/org-prp-src-blk</span>)
</pre>
</div>
<p>
There is a way to disable property inheritance that speeds up tangling a lot.
This is only for user-defined properties; <b>not</b> Org-Mode properties.
</p>
<p>
The problem is that you lose property inheritance which is unacceptable. Never,
never allow that. Its inconsistent with how Org-Mode works.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="orga4c2251">(<span class="org-keyword">setq</span> org-babel-use-quick-and-dirty-noweb-expansion nil)
</pre>
</div>
<p>
Assume that tangled document always live within the same directory structure
as their origin document.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="org4e76590">(<span class="org-keyword">setq</span> org-babel-tangle-use-relative-file-links t)
</pre>
</div>
<ul class="org-ul">
<li>Post tangle actions
<ul class="org-ul">
<li>Indentation
<ul class="org-ul">
<li>At first glance this is surprising! The author should be responsible for
the indentation, right? Yes, that is right. But there is one exception:
using <code>:noweb-ref</code> source block concatenation. <a href="http://orgmode.org/manual/noweb_002dref.html">It</a> is powerful and elegant.
But the source blocks are indented on their own line. It forces any
reader format it to make any sense of it. That is a poor start to using
the tangled files. So tangled files get indented.</li>
</ul></li>
</ul></li>
</ul>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="org076025e">(<span class="org-keyword">defun</span> <span class="org-function-name">help/org-babel-post-tangle-hook-fn</span> ()
(<span class="org-keyword">interactive</span>)
(indent-region (point-min) (point-max) nil)
(save-buffer))
(add-hook <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">org-babel-post-tangle-hook</span> <span class="org-highlight-quoted-quote">#'</span><span class="org-highlight-quoted-symbol">help/org-babel-post-tangle-hook-fn</span>)
</pre>
</div>
</div>
<ol class="org-ol">
<li><a id="org92cde24"></a>comments<br />
<div class="outline-text-5" id="text-1-1-3-1">
<pre class="example">
ID: orgmode:gcr:vela:49787FC5-CAA7-466B-B742-0F38973E070B
</pre>
<blockquote>
<p>
Toggle insertion of comments in tangled code files
</p>
</blockquote>
<p>
Provide as much information as possible in the tangled artifact about the
origin artifact.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="org429627c">(help/set-org-babel-default-header-args <span class="org-builtin">:comments</span> <span class="org-string">"noweb"</span>)
</pre>
</div>
</div>
</li>
<li><a id="orgf752cd3"></a>mkdirp<br />
<div class="outline-text-5" id="text-1-1-3-2">
<pre class="example">
ID: orgmode:gcr:vela:B0F9A321-3B69-46BB-B512-0AF3C663A4C0
</pre>
<blockquote>
<p>
Toggle creation of parent directories of target files during tangling
</p>
</blockquote>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="orgd98b3c6">(help/set-org-babel-default-header-args <span class="org-builtin">:mkdirp</span> <span class="org-string">"yes"</span>)
</pre>
</div>
</div>
</li>
<li><a id="orgac9f255"></a>no-expand<br />
<div class="outline-text-5" id="text-1-1-3-3">
<pre class="example">
ID: orgmode:gcr:vela:90170E6A-AA1A-44EA-9BF8-1A6AA38FD224
</pre>
<blockquote>
<p>
Turn off variable assignment and noweb expansion during tangling
</p>
</blockquote>
<p>
Configuration likely per Source-Block or System.
</p>
</div>
</li>
<li><a id="org64d0256"></a>noweb<br />
<div class="outline-text-5" id="text-1-1-3-4">
<pre class="example">
ID: orgmode:gcr:vela:E12B48AB-68E8-4515-89E3-30A16FB6FD22
</pre>
<blockquote>
<p>
Toggle expansion of noweb references
</p>
</blockquote>
<p>
Expand noweb references in source-blocks before:
</p>
<table border="2" cellspacing="0" cellpadding="6" rules="all" frame="border">
<colgroup>
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Activity</th>
<th scope="col" class="org-left">Expand</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left">Tangling</td>
<td class="org-left">T</td>
</tr>
<tr>
<td class="org-left">Evaluating</td>
<td class="org-left">T</td>
</tr>
<tr>
<td class="org-left">Weaving</td>
<td class="org-left">F</td>
</tr>
</tbody>
</table>
<p>
This embraces the notion that you are telling the right thing to the
computer and the right thing to the human. By the time you get to exporting, you
ought to refer to the generated document.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="orgaf99a80">(help/set-org-babel-default-header-args <span class="org-builtin">:noweb</span> <span class="org-string">"no-export"</span>)
</pre>
</div>
</div>
</li>
<li><a id="org57090d9"></a>noweb-ref<br />
<div class="outline-text-5" id="text-1-1-3-5">
<pre class="example">
ID: orgmode:gcr:vela:2836D0AA-5DBA-48AC-A338-B47002DE8D7F
</pre>
<blockquote>
<p>
Specify block's noweb reference resolution target
</p>
</blockquote>
<p>
Configuration likely per Source-Block or System.
</p>
</div>
</li>
<li><a id="org50be8ac"></a>noweb-sep<br />
<div class="outline-text-5" id="text-1-1-3-6">
<pre class="example">
ID: orgmode:gcr:vela:B1A57D15-6BBF-4E78-A0D9-0B02C283C6B0
</pre>
<blockquote>
<p>
String used to separate noweb references
</p>
</blockquote>
<p>
Configuration likely per Source-Block or System.
</p>
</div>
</li>
<li><a id="org1d825a2"></a>padline<br />
<div class="outline-text-5" id="text-1-1-3-7">
<pre class="example">
ID: orgmode:gcr:vela:DDE727A6-DDF7-4B61-9063-549614B135F0
</pre>
<blockquote>
<p>
Control insertion of padding lines in tangled code files
</p>
</blockquote>
<ul class="org-ul">
<li><code>org-babel-tangle-jump-to-org</code> requires padded lines. This configuration could
arguably appear in the "Programming" heading because it impacts operation. It
lives here because it <b>must</b> occur as part of the Tangling activity so that it
can be used in the Programming activity.</li>
<li>Often I go back and for on this one. Sometimes it is nicer to have less spaces
in generated code when guests are viewing it. When no one else is reading it
I love the spaces. Defaulting to what I like.</li>
</ul>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="org83db7e1">(help/set-org-babel-default-header-args <span class="org-builtin">:padline</span> <span class="org-string">"yes"</span>)
</pre>
</div>
</div>
</li>
<li><a id="org15ac270"></a>session<br />
<div class="outline-text-5" id="text-1-1-3-8">
<pre class="example">
ID: orgmode:gcr:vela:8219A42A-E90F-418A-8EF0-EB150CF6D730
</pre>
<blockquote>
<p>
Preserve the state of code evaluation
</p>
</blockquote>
<p>
Configuration likely per Source-Block or System.
</p>
<p>
For some situations, this may be the same for every source block for a
particular language. R is a good example.
</p>
</div>
</li>
<li><a id="org48d26eb"></a>shebang<br />
<div class="outline-text-5" id="text-1-1-3-9">
<pre class="example">
ID: orgmode:gcr:vela:542185DD-4FD6-459A-B422-DA7B546FB292
</pre>
<blockquote>
<p>
Make tangled files executable
</p>
</blockquote>
<p>
Configuration likely per Source-Block or System.
</p>
</div>
</li>
<li><a id="org78ce86c"></a>tangle<br />
<div class="outline-text-5" id="text-1-1-3-10">
<pre class="example">
ID: orgmode:gcr:vela:EA716FC9-4A90-4F3E-ABD0-31FEA575C969
</pre>
<blockquote>
<p>
Toggle tangling and specify file name
</p>
</blockquote>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="orgfaf9fcb">(help/set-org-babel-default-header-args <span class="org-builtin">:tangle</span> <span class="org-string">"no"</span>)
</pre>
</div>
</div>
</li>
<li><a id="orgcf11b0e"></a>tangle-mode<br />
<div class="outline-text-5" id="text-1-1-3-11">
<pre class="example">
ID: orgmode:gcr:vela:5F0B7157-2DC8-4AFD-8F26-4B21025A5ECE
</pre>
<blockquote>
<p>
Set permission of tangled files
</p>
</blockquote>
<p>
Configuration likely per Source-Block or System.
</p>
</div>
</li>
</ol>
</div>
<div id="outline-container-orgf96c55a" class="outline-4">
<h4 id="orgf96c55a"><span class="section-number-4">1.1.4</span> Evaluating</h4>
<div class="outline-text-4" id="text-1-1-4">
<pre class="example">
ID: orgmode:gcr:vela:ED23FF0B-1F90-435C-9B56-ACA06C1ACAE0
</pre>
<p>
Org-Mode may use all of the listed languages.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="org5c92aa4">(org-babel-do-load-languages
<span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">org-babel-load-languages</span>
<span class="org-highlight-quoted-quote">'</span>((emacs-lisp . t)
(org . t)
<span class="org-comment-delimiter">;;</span>
(C . t)
(R . t)
(python . t)
(sass . t)
(scheme . t)
(sql . t)
(js . t)
<span class="org-comment-delimiter">;;</span>
(latex . t)
<span class="org-comment-delimiter">;;</span>
(makefile . t)
(shell . t)
<span class="org-comment-delimiter">;;</span>
(ditaa . t)
(dot . t)
(plantuml . t)))
</pre>
</div>
</div>
<ol class="org-ol">
<li><a id="orgcbe1d4f"></a>cache<br />
<div class="outline-text-5" id="text-1-1-4-1">
<pre class="example">
ID: orgmode:gcr:vela:49B8BFE9-643B-450F-A8A1-20CE3079E215
</pre>