You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.org
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -77,7 +77,7 @@ And in my Emacs configuration file, I will add a hook to enable [[https://polymo
77
77
#+END_SRC
78
78
So Github can render such source file as org mode correctly.
79
79
** how to insert code block quickly
80
-
Please have a look of the section [[https://github.com/jingtaozf/literate-elisp/blob/master/literate-elisp.org#how-to-insert-code-block-in-org-file][How to insert code block in org file]] in library [[https://github.com/jingtaozf/literate-elisp][literate-lisp]].
80
+
Please have a look of the section [[https://github.com/jingtaozf/literate-elisp/blob/master/literate-elisp.org#how-to-insert-code-block-in-org-file][How to insert code block in org file]] in library [[https://github.com/jingtaozf/literate-elisp][literate-elisp]].
81
81
** Add dependence in project.clj
82
82
To use this library, please add dependence in your [[./demo/project.clj][project.clj]]:
@@ -29,7 +31,7 @@ It extends the clojure read syntax so clojure can load org file as source file d
29
31
30
32
[[https://github.com/limist/literate-programming-examples][literate programming examples]] show the reason why use org mode,
31
33
32
-
By using clojure package [[https://github.com/jingtaozf/literate-clojure][literate-clojure]] , emacs [[https://orgmode.org/][org mode]] and elisp library [[https://polymode.github.io/][polymode]],
34
+
By using clojure package [[https://github.com/jingtaozf/literate-clojure][literate-clojure]] , Emacs [[https://orgmode.org/][org mode]] and Elisp library [[https://polymode.github.io/][polymode]],
33
35
literate programming can be easy in one org file containing both documentation and source codes,
34
36
and this org file works well with [[https://github.com/clojure-emacs/cider][cider]].
35
37
@@ -52,7 +54,7 @@ and the clojure codes exists between ~#+begin_src clojure~ and ~#+end_src~
52
54
,#+END_SRC
53
55
#+END_EXAMPLE
54
56
55
-
So to let clojure can rean an org file directly, all lines out of surrounding
57
+
So to let clojure can read an org file directly, all lines out of surrounding
56
58
by ~#+begin_src~ and ~#+end_src~ should mean nothing,
57
59
and even codes surrounding by them should mean nothing
58
60
if the [[https://orgmode.org/manual/Code-block-specific-header-arguments.html#Code-block-specific-header-arguments][header arguments]] in a code block request such behavior.
@@ -63,8 +65,8 @@ then ignore all lines after that until it meet ~#+begin_src~.
63
65
When ~#+begign_src lisp~ occurs, org [[https://orgmode.org/manual/Code-block-specific-header-arguments.html#Code-block-specific-header-arguments][header arguments]] for this code block give us
64
66
a chance to switch back to normal clojure reader or not.
65
67
66
-
And if it switch back to normal clojure reader, the end line ~#+END_SRC~ should mean the end of current
67
-
code block,so a new clojure [[https://clojure.org/reference/reader#_dispatch][dispatch]] syntax for "#+"(sharp plus)will have an additional meaning
68
+
And if it switches back to normal clojure reader, the end line ~#+END_SRC~ should mean the end of current
69
+
code block,so a new clojure [[https://clojure.org/reference/reader#_dispatch][dispatch]] syntax for "#+"(sharp plus)will have an additional meaning
68
70
to determine if it is ~#+END_SRC~,
69
71
if it is, then clojure reader will switch back to org mode syntax,
70
72
if it is not, clojure reader will continue to read subsequent stream as like the original clojure reader.
@@ -75,7 +77,7 @@ for example I often put them in the first line of an org file:
75
77
#+BEGIN_SRC org
76
78
# -*- encoding:utf-8 Mode: POLY-ORG; -*- ---
77
79
#+END_SRC
78
-
Which make emacs open file with utf-8 encoding and [[https://github.com/polymode/poly-org][poly-org-mode]].
80
+
Which make Emacs open file with utf-8 encoding and [[https://github.com/polymode/poly-org][poly-org-mode]].
79
81
80
82
* Implementation
81
83
** Preparation
@@ -97,7 +99,7 @@ A boolean variable to toggle debug on/off
97
99
(defonce ^:dynamic debug-p nil)
98
100
#+END_SRC
99
101
100
-
a debug function to print out some log messages.
102
+
A debug function to print out some log messages.
101
103
#+BEGIN_SRC clojure
102
104
(defn debug [& args]
103
105
(when debug-p
@@ -165,13 +167,13 @@ Based on clojure's [[https://github.com/clojure/clojure/blob/master/src/jvm/cloj
165
167
(debug (cl-format nil "install dispatch reader macro for character '~a'" ch))
166
168
(aset dm (int ch) fun))))
167
169
#+END_SRC
168
-
But it only works in clojure instead of clojurescript, because clojurescript use [[https://github.com/clojure/tools.reader][tools.reader]].
170
+
But it only works in clojure instead of ClojureScript, because ClojureScript uses [[https://github.com/clojure/tools.reader][tools.reader]].
169
171
170
172
** handle org syntax
171
173
172
174
There are a lot of different lisp codes occur in one org file, some for function implementation,
173
175
some for demo, so a new [[https://orgmode.org/manual/Structure-of-code-blocks.html][org code block]] [[https://orgmode.org/manual/Code-block-specific-header-arguments.html#Code-block-specific-header-arguments][header argument]] ~load~ to decide to
174
-
read them or not should define,and it has three meanings:
176
+
read them or not should define,and it has three meanings:
175
177
- yes \\
176
178
It means that current code block should load normally,
177
179
it is the default mode when the header argument ~load~ is not provided.
@@ -238,7 +240,7 @@ The ~reader~ is returned so [[https://github.com/clojure/clojure/blob/master/src
238
240
#+END_SRC
239
241
240
242
** handle end of source code block
241
-
Let's define a new dispatch function for "#+" (sharp plus) to return back org syntax, until it meet ~#+begin_src clojure~.
243
+
Let's define a new dispatch function for "#+" (sharp plus) to switch back to org syntax, until it meet ~#+begin_src clojure~.
We make ~install-org-dispatcher~ accept as possible as many args so it can be a dummy handler for other module, for example
257
-
warning handler of clojurescript.
258
+
We make ~install-org-dispatcher~ accept arguments, so it can be a dummy handler for other modules, for example
259
+
warning handler of ClojureScript.
258
260
#+BEGIN_SRC clojure
259
261
(defn install-org-dispatcher [& args]
260
262
(when-not args
@@ -265,7 +267,7 @@ warning handler of clojurescript.
265
267
#+END_SRC
266
268
** install new dispatcher functions to tools.reader
267
269
Sadly [[https://github.com/clojure/tools.reader][tools.reader]] use a private function to return dispatch functions(see function [[https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader.clj][dispatch-macros]]).
268
-
So we have to advice this function to add new dispatch reader macro.
270
+
So we have to alter this function to add new dispatch reader macro.
@@ -328,9 +330,9 @@ If we want to release to [[./core.clj]], the following codes should execute:
328
330
#+END_SRC
329
331
330
332
* References
331
-
- [[http://www.literateprogramming.com/knuthweb.pdf][Literate. Programming.]] by [[https://www-cs-faculty.stanford.edu/~knuth/lp.html][Donald E. Knuth]]
332
-
- [[http://www.literateprogramming.com/][Literate Programming]] a site of literate programming
333
-
- [[https://www.youtube.com/watch?v=Av0PQDVTP4A][Literate Programming in the Large]] a talk video from Timothy Daly,one of the original authors of [[https://en.wikipedia.org/wiki/Axiom_(computer_algebra_system)][Axiom]].
333
+
- [[http://www.literateprogramming.com/knuthweb.pdf][Literate. Programming]], by [[https://www-cs-faculty.stanford.edu/~knuth/lp.html][Donald E. Knuth]]
334
+
- [[http://www.literateprogramming.com/][Literate Programming]] a site of literate programming
335
+
- [[https://www.youtube.com/watch?v=Av0PQDVTP4A][Literate Programming in the Large]] a talk video from Timothy Daly,one of the original authors of [[https://en.wikipedia.org/wiki/Axiom_(computer_algebra_system)][Axiom]].
334
336
- [[https://github.com/limist/literate-programming-examples][A collection of literate programming examples using Emacs Org mode]]
335
337
- [[https://orgmode.org/worg/org-contrib/babel/intro.html#literate-programming][literate programming in org babel]]
336
338
- a reader macro library for clojure: https://github.com/klutometis/reader-macros
0 commit comments