changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > org > docs / ulang.org

changeset 7: a6cf5a2a2f8d
parent: 713c22bdab6a
child: 4cb5e087f588
author: ellis <ellis@rwest.io>
date: Tue, 28 Nov 2023 21:45:46 -0500
permissions: -rw-r--r--
description: pub update
1 {{{header(ulang,
2 Richard Westhaver,
3 ellis@rwest.io,
4 The Universal Language)}}}
5 
6 This document describes a *U-Language* as described by the late great
7 Haskell Curry:
8 
9 #+begin_quote
10 Every investigation, including the present one, has to be communicated
11 from one person to another by means of language. It is expedient to
12 begin our study by calling attention to this obvious fact, by giving a
13 name to the language being used, and by being explicit about a few of
14 its features. We shall call the language being used the
15 U-Language. [...] There would be no point in calling attention to it,
16 if it were not for the fact that language is more intimately related
17 to our job than of most others.
18 #+end_quote
19 
20 * ulang
21 :PROPERTIES:
22 :CUSTOM_ID: ulang
23 :END:
24 As the title suggest we refer to our *U-Language* as
25 ulang. When I say something along the lines of "Please refer to
26 [[*Hyperlinks][ulang.Hyperlinks]]", I am referencing the section named /Links/ of this
27 document.
28 
29 Each section of this document describes an element of the ulang. It is
30 recommended to skim through the top-level sections ([[Org-mode][Org-mode]] and
31 [[Elements][Elements]]) and review the element sub-headings as needed.
32 
33 #+TOC: headlines 3
34 
35 ** Org-mode
36 :PROPERTIES:
37 :CUSTOM_ID: 98a02bb2-3f39-49c6-898a-68ccd8f3cbe1
38 :END:
39 [[https://www.gnu.org/software/emacs/][GNU Emacs]] is our text editor, so naturally [[https://orgmode.org/][Org Mode]] is our
40 documentation engine.
41 
42 If you are already familiar with Emacs and org-mode, I recommend
43 opening the source file of this document in Emacs and following along.
44 
45 If not, I recommend browsing through the [[https://orgmode.org/worg/][Worg resources]], but we won't
46 be getting too deep into tribal hacker knowledge of Emacs. The choice
47 of Org is arbitrary and the concepts here would apply to other formats
48 (LaTeX, Markdown, etc).
49 
50 *** TODO organ
51 :PROPERTIES:
52 :CUSTOM_ID: 22474039-5c18-4179-82aa-a6731e6313a2
53 :END:
54 - State "TODO" from [2023-11-05 Sun 19:21]
55 
56 =Org-mode= the application depends on Emacs (it's written in Emacs
57 Lisp) but that doesn't mean we need to. To solve the issue of
58 interoperability between different systems, we are developing a tool
59 called [[https://lab.rwest.io/comp/core/-/tree/branch/default/lisp/lib/organ][organ]]. The purpose of =organ= is to provide an external API for
60 Org documents that doesn't depend on GNU Emacs.
61 
62 If we were designing a /personal/ note-taking system, I would argue
63 that we don't need this tool. The problem is it's /not/ personal - we
64 have a much wider intended audience and need to present information in
65 many different ways. This means thinking about hundreds to thousands
66 of documents instead of tens, about processing those documents into a
67 full-text search database, and reducing cost along the way.
68 
69 Emacs can do all of these things, but do you really want it to?
70 
71 ** Syntax
72 Let us first consider /Org the syntax/.
73 
74 Org syntax is much less popular than Markdown and lacks parsing
75 utilities in popular programming languages[fn:1]. Regardless, we are
76 committed to it as a foundation because it is the most hackable
77 documentation engine available. With enough experience you can morph
78 Org into whatever documentation system that is needed.
79 
80 
81 As such, all documentation we write is done using =Org syntax=. When
82 we refer to Org syntax we are referring to the vanilla syntax which
83 comes built-in with Emacs.
84 
85 =Ulang syntax= is an extension of =Org syntax=. If some feature of the
86 =Ulang= is undocumented, refer to =Org syntax= for guidance.
87 
88 [fn:1] The ecosystem is changing though, thanks to the dedication of
89 some excellent hackers: [[https://github.com/karlicoss/orgparse][python]], [[https://github.com/tecosaur/Org.jl][julia]]
90 
91 ** Elements
92 :PROPERTIES:
93 :CUSTOM_ID: 4aa3ec2a-b360-43ae-b2d8-f9735f211290
94 :END:
95 This section documents the /extensions/ made to =Org syntax=. Each
96 sub-heading focuses on a pre-existing =Org= element and describes
97 =Ulang= functionality included with =ulang.el=.
98 
99 *** Keywords
100 :PROPERTIES:
101 :CUSTOM_ID: 2cadda9a-22a3-4b42-ad4e-d7a774f74cba
102 :END:
103 The ulang *Keywords* are a superset of those defined by [[https://datatracker.ietf.org/doc/html/rfc2119][RFC-2119]].
104 
105 #+begin_quote
106 In many standards track documents several words are used to signify
107 the requirements in the specification. These words are often
108 capitalized. This document defines these words as they should be
109 interpreted in IETF documents. Authors who follow these guidelines
110 should incorporate this phrase near the beginning of their document:
111 
112 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
113 NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
114 "OPTIONAL" in this document are to be interpreted as described in
115 RFC 2119.
116 #+end_quote
117 
118 #+begin_quote
119 1. MUST This word, or the terms "REQUIRED" or "SHALL", mean that the
120  definition is an absolute requirement of the specification.
121 
122 2. MUST NOT This phrase, or the phrase "SHALL NOT", mean that the
123  definition is an absolute prohibition of the specification.
124 
125 3. SHOULD This word, or the adjective "RECOMMENDED", mean that there
126  may exist valid reasons in particular circumstances to ignore a
127  particular item, but the full implications must be understood and
128  carefully weighed before choosing a different course.
129 
130 4. SHOULD NOT This phrase, or the phrase "NOT RECOMMENDED" mean that
131  there may exist valid reasons in particular circumstances when the
132  particular behavior is acceptable or even useful, but the full
133  implications should be understood and the case carefully weighed
134  before implementing any behavior described with this label.
135 
136 5. MAY This word, or the adjective "OPTIONAL", mean that an item is
137  truly optional. One vendor may choose to include the item because a
138  particular marketplace requires it or because the vendor feels that
139  it enhances the product while another vendor may omit the same item.
140  An implementation which does not include a particular option MUST be
141  prepared to interoperate with another implementation which does
142  include the option, though perhaps with reduced functionality. In the
143  same vein an implementation which does include a particular option
144  MUST be prepared to interoperate with another implementation which
145  does not include the option (except, of course, for the feature the
146  option provides.)
147 #+end_quote
148 
149 One of the important features of keywords is that we use them as Org
150 [[https://orgmode.org/manual/Workflow-states.html][Workflow states]]. You may use any of the keywords above or below as the
151 first word in a heading to signify a requirement or a workflow state:
152 
153 6. TBD A task to be done at a later date.
154 
155 7. TODO A task yet to be done.
156 
157 8. WIP Work In Progress task.
158 
159 9. NOTE Designates a note item.
160 
161 10. DRAFT Designates a draft item.
162 
163 11. DEAD Item that will not be completed.
164 
165 12. DONE Completed task.
166 
167 13. COMMENT A 'commented' item.
168 
169 *** Macros
170 :PROPERTIES:
171 :CUSTOM_ID: cdb4976b-1d0d-49df-bfb1-3dbd5d99590e
172 :END:
173 Several *global* [[https://orgmode.org/manual/Macro-Replacement.html][Org Macros]] are used throughout our documents. They are listed
174 here for convenience.
175 
176 #+name: ulang-macros
177 #+begin_src emacs-lisp :exports both :results replace pp
178  org-export-global-macros
179 #+end_src
180 
181 #+RESULTS: ulang-macros
182 : (("header" .
183 : "#+TITLE: $1\n#+AUTHOR: $2\n#+EMAIL: $3\n#+DESCRIPTION: $4\n#+SUBTITLE: $4\n#+OPTIONS: ^:nil toc:nil num:nil html-postamble:nil\n#+HTML_HEAD: <link rel=\"stylesheet\" href=\"https://fonts.xz.style/serve/inter.css\"/>\n#+HTML_HEAD: <link rel=\"stylesheet\" type=\"text/css\" href=\"https://cdn.compiler.company/css/new.min.css\"/>\n#+HTML_HEAD: <link rel=\"stylesheet\" type=\"text/css\" href=\"https://cdn.compiler.company/css/night.css\"/>\n")
184 : ("opts" . "#+OPTIONS: $1\n"))
185 
186 Macros /are not expanded/ in source files - you will see them in the
187 form ={{{NAME(ARGS)}}}=. You will need the relevant macro definition
188 (in =ulang.el=) in order to export ulang docs with the macros
189 expanded.
190 
191 *** Hyperlinks
192 The Org-mode [[https://orgmode.org/manual/Link-Format.html][Link Format]] is used throughout the Ulang and needs little
193 introduction.
194 **** Types
195 #+begin_src emacs-lisp :results replace pp :exports both
196 (org-link-types)
197 #+end_src
198 
199 #+RESULTS:
200 : ("notmuch-tree" "notmuch-search" "notmuch" "man" "eww" "rmail" "mhe"
201 : "irc" "info" "gnus" "docview" "bibtex" "bbdb" "w3m" "doi" "id"
202 : "elfeed" "file+sys" "file+emacs" "shell" "news" "mailto" "https"
203 : "http" "ftp" "help" "file" "elisp")
204 
205 **** Abbrevs
206 For ease of use we have defined some special link handling abbrevs:
207 
208 #+begin_src emacs-lisp :results replace pp :exports both
209  org-link-abbrev-alist
210 #+end_src
211 
212 #+RESULTS:
213 : (("vc" . "https://vc.compiler.company/%s")
214 : ("comp" . "https://compiler.company/%s")
215 : ("cdn" . "https://cdn.compiler.company/%s")
216 : ("packy" . "https://packy.compiler.company/%s")
217 : ("yt" . "https://youtube.com/watch?v=%s"))
218 
219 *** Dynamic Blocks
220 [[https://orgmode.org/manual/Blocks.html][Blocks]] are a feature of vanilla Org-mode which are described in the
221 manual. We extend this functionality with [[https://orgmode.org/manual/Dynamic-Blocks.html][Dynamic Blocks]]. The
222 important feature of these blocks is that their contents are updated
223 /dynamically/ by a user within an Org-mode document.
224 
225 For example, typing ~C-c C-c~ on the block below dynamically generates
226 the standard clocktable for the current file.
227 
228 To update all dynamic blocks in a document, use the
229 =org-dblock-update= ~C-c C-x C-u~ function.
230 
231 #+BEGIN: clocktable
232 #+CAPTION: Clock summary at [2023-11-25 Sat 15:26]
233 | Headline | Time |
234 |--------------+--------|
235 | *Total time* | *0:00* |
236 #+END:
237 
238 #+begin_src emacs-lisp :results replace pp :exports both
239  org-dynamic-block-alist
240 #+end_src
241 
242 #+RESULTS:
243 : (("files" . ulang-dblock-insert-files)
244 : ("links" . ulang-dblock-insert-links)
245 : ("columnview" . org-columns-insert-dblock)
246 : ("clocktable" . org-clock-report))
247 
248 *** Tables
249 :PROPERTIES:
250 :CUSTOM_ID: ulang-tables
251 :END:
252 
253 Org [[https://orgmode.org/manual/Tables.html][Tables]] are powerful but require many extensions to really /feel/
254 powerful. As they come in vanilla Emacs, they don't feel as good as
255 commercial spreadsheet-based software. The Ulang Table extensions add
256 some sane defaults and additional data-processing utilities to work
257 with tables in any text, not just Org docs.
258 
259 A vanilla Org Table may look like this:
260 
261 | x | y | z |
262 |---+----+----|
263 | 1 | 2 | 3 |
264 | 8 | 9 | 10 |
265 | 9 | 10 | 11 |
266 | 3 | 4 | 5 |
267 | 7 | 8 | 9 |
268 | 2 | 3 | 4 |
269 #+TBLFM: $2=$1+1::$3=$2+1
270 
271 Just like in Excel, we can define a table outline like the one above
272 and use code to fill in the values with a formula: =$2=$1+1::$3=$2+1=.
273 
274 Unlike Excel, these tables can appear pretty much anywhere - including
275 in source code.
276 
277 Usually we prefer to use lisp to prepare our data and
278 populate complex tables, or no-nonsense keyboard commands for short
279 tables. This is done with a few functions in Org docs and the =orgtbl=
280 minor-mode everywhere else.