- Emacs uses different modes,
cpp-files
usesc++-mode
- Org-mode is used in Emacs for
org-files
- Content of an org-file is plain text
- We can have different lists, links, tags, and tables
In Org-mode
- New list items
- New headings
- Links
- New table information
- Close TODO
Inspiration: Howard Abrams Harry Scwartz Mike Zimansky
- Literate programming for me is the ability to mix code and regular text
- I got into Emacs by using Org-mode as my advance notebook
- I have found many inspiring texts and presentations on the internet.
Especially from
Howard Abrams
Babel
extension provides literate programming capabilites
Create a block with <s
- shell
ls
andcd
- elisp
hello-world
(format “”) - python
hello-world
(print vs output results) - cpp
hell o-world
(more code use popup)#include <iostream> int main() { std::cout << "Hello there" << std::endl; return 0; }
Ex1:
cpp Eigen example (more advanced)
- Mixing text and code
how to control the granuality?
Ex2:
splitting it updoesn't work
Ex3:
solution
Ex4:
python, utilizing header-args, use subheading
:header-args: :session session-python-chain
- Not all languages supports session
- How to connect blocks with
noweb
Ex5:
python, inline with nowebEx6:
python + elisp, inline and value with noweb
Org is an excellent tooexl when studying programming
Global links
to navigate to other documentsEx7:
Context~
is missing, the book is the missing pieceOrg-Noter
, solves this problem- Linking to parts of files is more useful, use
Org-capture
- Look at
org-capture~
source code withfind-file
- I want to build my own Docker image and deploy an application on it
Ex8
requirements, I want it to be tangled:tangle docker_image/requirements.txt
Ex9
dockerfile, I want to split it up and add comments, mix noweb and tangle- application is self explenatory
- creating the image
We need to fix the issue. We could go back to the application make some changes and rebuild the image to see if we solved the issue. That sounds a bit slow though, let’s see if we can improve that workflow.
I wan to be able to make changes directly into a running docker image.
Ex10
start the docker and verify that it runs- We saw before sudo, that was using TRAMP
(Transparent, Remote, Access, Multiple Protocols)
- Show with find-file docker:nick_name:
- Show with eshell cd docker:nick_name:
Ex11
run this block to show the tramp complient pathEx12
elisp code can be used in header argumentsEx13
tangle to running imagesolution: use print() instead of print
Ex14
get the previous session nameEx15
snippet solution Finding the name with the function seems to work. But how can we use that?
Add `(my/org-babel-previous-session)`
to the snippet to have a working solution
- Create a previous session block add
:results output
the content should bepython app.py
Ex16
elisp block with code to generate data- Add name and caption to table
- #+NAME: est-truth-data
- #+CAPTION: Truth and estimate
Ex17
change formating of output with post- add
:post add-header(*this*)
- add
Ex18
I like visualization for clarity, I know how to plot inpython
Ex19
and inoctave
if I am in to that
- Pull up the table formulas with ~C-c ‘~
- Look at the different functions,
calc
, andelisp
is used Ex20
Mean error in the table, use a elisp blockEx21
RMSE in the table, use a python block
Ex22
Sometimes it’s good to be able to describe the flow- add a caption
The flow of the investigation
- add a caption
Emacs calc
just mentioned briefly, but it’s more powerful then I thought
10 + 3 * 5 /2.0
cos(180)
Solve the x*2+x=4
equation
x*2+x=4
fsolve(x*2+x=4,x)
Or how about a derivation
deriv(sqrt(x),x)
Ex23
table derivation formula:$2=deriv($1,x)
Now when we have made these awesome discoveries it would be nice to share it with our colleges. Pdf latex is nice!
Too bad it doesn’t seem to export correctly
Ex24
- Use
org-revel-export-to-html
- Context,
- make things come together,
- make notes that exists with your code
- include links to other files etc
- Documentation
- it’s very easy to track the way you are doing things
- Improvise
- for me org-mode is very much about the sky is the limit
- come up with new ways, mix languages, etc
- Emacs (hackable)
- emacs-lisp, it’s been a red thread throughout the presentation
- it’s not possible to talk about Org-mode without mentioning the Emacs way
- Exports
- You can make Org files your pdf latex files, your presenations and your markdown
Create a new entry
hugo server -D
- Insert
ex25
- Insert
ex26
- Follow global link to the post
- Navigate to
terminal
and start hugo server - Open
Firefox
and navigate to local host - Show the post
- Go back to
Emacs
and the post and mark as done - Back to
firefox
- We want to publish it for everyone to share. Use
deploy.sh
- Navigate to real site and wait
Hope that you have find this video inspiring and thanks for watching!