Babel is why I keep blogging with Emacs
(entropicthoughts.com)209 points by ibobev 13 hours ago
209 points by ibobev 13 hours ago
The neat thing about org-mode for writing and publishing (I don't use it for "productivity") is that every time I have a new requirement, there is a solution that I can integrate into my existing writing workflow. And I get multimedia publishing "for free".
Discussed here: https://news.ycombinator.com/item?id=43157672
Why and How I use "Org Mode" for my writing and more
217 points by sebg 7 months ago | 64 comments
src: https://github.com/adityaathalye/shite/blob/master/sources/p...Ditto. I wanted to show JavaScript text art animation, and could "just" do this:
*** ~setInterval~ and ~setTimeout~ worked just right
These let us call functions that do exactly the thing we want,
viz. punch /[[#the-aesthetic-of-text-art-and-its-animation][characters]]/
into our "live spreadsheet" medium, exactly the way the artist
placed them in the original art source.
These methods can make a CPU sing, but hey, the awesome art
is worth every watt it, ah, draws.
#+html: <div class="box invert">
#+html: <em>Random twitch loop <code>setTimeout</code> and recursion.</em>
#+html: <div id="blink-demo"></div>
#+html: </div>
#+html: <script type="text/javascript">demoBlink();</script>
#+html: <div class="box invert">
#+html: <em>Flipbook-like frame-by-frame animation loop with <code>setInterval</code>.</em>
#+html: <div id="glider-demo"></div>
#+html: </div>
#+html: <script type="text/javascript">demoGlider();</script>
This works very nicely because I've structured my website as "every post is just a microsite". See:src: https://github.com/adityaathalye/shite/tree/master/sources/p...
\_ (develop %|u+4) $ tree sources/posts/animate-text-art-javascript/
sources/posts/animate-text-art-javascript/
├── animations.js
├── blink.ddw
├── DarkDrawSheetView.png
├── glider.ddw
├── HanukkahOfData2022ArtCopyrightDwimmertxt.png
├── HanukkahOfData2022ArtSliceCopyrightDwimmertxt.png
├── HanukkahOfData2022DarkDrawDrawingViewCopyrightDwimmer.png
├── HanukkahOfData2022DarkDrawSheetViewCopyrightDwimmer.png
├── index.org
├── loading.ddw
└── spinner.ddw
1 directory, 11 files
I was in the same boat for many years! Having started using org-mode for my website in 2018 [1] (just add index.org to the path to see the source), it grew into this massive pile of obscure gen and with my limited comfort level with lisp, turned into a scary smelling concoction of dozens of perl/sed/sh scripts that modified the output to fit my needs and have them do something fancy.
But then, really, sat down for about 48 hours on a lonely weekend when everyone was away and wrote a simple static site generator [2] that takes exact same files and produces output that I fully understand e2e, becoming the project I'm most proud of.
There are so many other generators I tried (hugo, jekyll, rails, asciidoctor, org-publish, astro), rolling up your own gives a sense of a stable foundation. Love your website! So clean. One thing that I'm thinking of adding (though I haven't touched my generator that much, I consider it "complete") is the dynamic execution of source code blocks.
Hah! Superfriend!
First... Love your site (clean, fast, easy on the eyes, no need for JS to read). And your writing... yours is a proper blog. I used to feel bad about not being able to "just blog" like a real blogger, but I discovered that what I really like, is to write, in order to think. So, my blog has become part of my Big Reason to write (a lot) locally, and I am very happy to publish giant-ass blog posts; longform thinking.
Second... I went down a very similar path to custom site-buildin'.
Reject Wordpress because it's the 2020s -> reject anything mandating npm, gem, pip, lockfile web-scale dependency madness -> just hugo (single binary, wow) -> hugo + ox-hugo -> ouch, yet another custom templating language, and no backwards compatibility -> should I just Wordpress like it's 2005? -> NO, wait. Now I know programming. -> Voila! `shite` [1] (org-mode content -> pandoc -> plain HTML-and-CSS website [2]).
[1] https://github.com/adityaathalye/shite (dicussed here, that one time: https://news.ycombinator.com/item?id=34486596)
Show HN: Shite – little hot-reloadin' static site maker from shell
141 points by adityaathalye on Jan 23, 2023 | 60 comments
(The discussion will answer anyone's burning question about the project name :)Third... Again... superfriend! 10000% same sentiment as yours:
> that takes exact same files and produces output that I fully understand e2e, becoming the project I'm most proud of
See my `shite`'s incredible documentation---animated GIFs and everything. Probably my second-best documented personal project (or tied for first-best with clojure-multiproject-example).
Things that give me inordinate joy:
- `shite` weighs in at ~300 Lines of Code (and why does it have 240 Github Internet Points, who are these insane people???)
- it is truly "serverless" - I don't run a local dev server even
- it hot-compiles and hot-refreshes on save - fully interactive local authoring (as well as live template modifications)
- since Feb 2022, it broke (only very slightly), after I distro upgraded Ubuntu 22.04 LTS to 24.04 LTS, because pandoc changed its default handling of line breaks, breaking layout of hand-indented "verse" text.
- Under 10 second full site rebuild, with 43 posts totalling over 100K words and over 40 more auto-generated pages (rss feed, various xmls, and per-tag blog post index pages). And I haven't even made it parallel yet. Probably will, if full rebuilds get longer than 30 seconds.
- The resulting site scores top marks on lighthouse and even image-heavy pages render fully in under a second on 4G mobile internet. (zero analytics, or tracking javascript).
- And my most favourite part: I've made Internet Friends because of the site! https://www.evalapply.org/about.html#standing-invitation
It's hilarious --- I've done such sophisticated work for work, but this little piece of personal software is my pride and joy... It makes me grin almost every single day.
May The Source be with you too! _\\ // (yes, I love mixing metaphors)
I write my blog (https://lambdaland.org) entirely in Emacs now. It's Hugo, but I use ox-hugo [1] to convert from org-mode to markdown and Hugo converts it to HTML.
What I like about this: everything else I do is in org-mode anyway, so this fits my brain. I also have some nice org-mode tooling to make things like footnotes, margin notes, etc. look really nice.
A little convoluted, sure, but I've seen worse. :-P
I used Hugo's native `.org` file support for a while. It was… fine. There are some serious issues (for me) that I had with it though. The most salient one is that it didn't convert straight quotes in the source ("") to proper curly-quotes. (“”) I don't remember what else but I'm sure there was more than just that. I've spent a lot of time on the typography of my site and I wanted everything to be as perfect as I could make it.
Didn't know that Hugo supports org files. But just one example of added functionality is being able to use one big file with a subtree for each post.
I started using Hugo's built-in org support, but I found it quite limiting. I can't remember the specifics, but it doesn't support everything you can do with Markdown. So I quickly switched to ox-hugo. They can co-exist though so you can try the native support then switch if you run into the same shortcomings as I did.
Equations: very yes. You have to create some custom short codes. Example of it in action here: https://lambdaland.org/posts/2024-08-06_zkp/
Here's the source for that entire post: https://gist.github.com/ashton314/e63c9ed31c38c421f11d84df1f...
The shortcodes are a little messy, I will admit, but I have a temp.el snippet that expands to the right thing so authoring isn't too bad.
org-babel: I'm not sure. Here's the docs for code block handling in ox-hugo: https://ox-hugo.scripter.co/doc/source-blocks/
FWIW, org's HTML export is about 4000 lines of elisp, and it is pretty well modularized.
https://git.sr.ht/~bzg/org-mode/tree/main/item/lisp/ox-html....
The publish front end is in
https://git.sr.ht/~bzg/org-mode/tree/main/item/lisp/ox.el
and
https://git.sr.ht/~bzg/org-mode/tree/main/item/lisp/ox-publi...
If it’s about wanting to understand your end to end workflow and you don’t mind it being “except for babel” then you could run emacs as a headless daemon and pass through to babel with emacsclient.
It’s a bit inelegant, and lacks the complete purity of “just 2,000 lines of code”. But the sentiment is already drawing lines based on arbitrary gradations in levels of abstraction. So if it improves your workflow to switch away from the rest of emacs’ baroque cathedral of unused functionality, and you want the simplicity of your bespoke engine, just make a handful of those 2,000 lines a wrapper around some i/o through to babel.
After all, it’s turtles all the way down on this sort of thing, at least until you’re staring at circuit diagrams of thinking, “huh, wonder if I can build it all with multi-, no, half adders..”. Further than that and you’ll probably need to learn some advanced metallurgy.
I was a long time org mode user and used babel extensively [1]. It was a marvelous experience, but the market chose markdown. I still drop into org-mode some times for specific features, and the babel integration is still in its own league, but technically there's nothing preventing something similar for markdown.
I pulled some org-babel code to make a code fence evaluator for markdown a while back [2] but haven't found myself needing it that much. So without a need to wrangle reports or run exports, I think it's a 1% feature for text file connoisseurs.
[1] https://ess.r-project.org/ with babel is an experience I find superior to jupyter tools even after all these years
Conforming to “the market” is just a pandoc call away. I export to markdown, pdf, html and even docx all the time when i need to share with colleagues. I prefer writing in org-mode because of the complete ecosystem it offers inside emacs. But also just as plaintext I really miss src blocks in markdown.
What’s the recommendation for the simplest blogging setup to say s3? Req: 0 javascript, simple css, absolutely minimal functions for blogs. My ideal is I open a text file on my Mac in vi, type my thoughts and then save and run some script to publish it and it gets the style and date and index entry automatically.
You can set up any static site generator (like Astro or Hugo) with a pre-made blog template. Then you'll just have to write posts in markdown files and the generator will handle the rest.
(Or you can write a custom template in any of those, they both don't add any JS or anything else to your page by default unless you explicitly add it. I like Astro more since it's basically just HTML with extra features unlike Hugo which uses a separate templating language, but they're all pretty much the same)
You can deploy it automatically and completely for free on platforms like GitHub Pages or Cloudflare Pages, which are pretty easy to set up and will automatically build and deploy new versions of your site on every git push.
Babel sounds awesome, I should give it a try.
I've been using Pandoc for my static site, which I also used for my PhD thesis. I wrote pandoc-plot[0] to render figures in documents like the author does, inspired by Matplotlib's plot-directive[1]. I feel like this feature is a must for technical writing, but getting the details right is tricky!
[0]: https://github.com/LaurentRDC/pandoc-plot
[1]: https://matplotlib.org/stable/api/sphinxext_plot_directive_a...
Heh. I write my blog posts in org mode, and have a way to get Pelican[1] to read them. It doesn't support executing Babel source blocks on export - I should probably add that feature to my package.[2]
[2]https://blog.nawaz.org/posts/2022/Dec/reintroducing-opel-put...
I wrote my own org-mode static generator: https://github.com/facundoolano/jorge
More robust than my previous emacs setup and much lighter than hugo. No fancy babel generation but I don’t really need that.
Just started my blog[1] as another way to dogfood Tritium. So far works pretty well. My posts are going to be short and simple but since Docx -> HTML conversion is straightforward, I should have more capability as the product improves as a word processor.
I’m trying to make it a bi-weekly, 1-hour exercise but finding things to write about that might be interesting in a short window is kinda tough.
I used to use org-mode with hugo but it got annoying, I didn't like how I needed to structure my org files, it kind of forced me into some structure. Now I use Zola with Markdown. I'm losing in power but it's so much simpler tbh.
If you ever happen to go back, https://ox-hugo.scripter.co/ has a couple different options for supported structures. I use it for https://dylanfitzgerald.net without much issue.
> Any lightweight markup format (like Markdown or ReStructuredText or whatever) allows for embedding code blocks, but Org, through Babel, can run that code on export, and then display the output in the published document, even when the output is a table or an image.
This is what I love about blogging with Quarto.
Almost everything I write, from programs to SQL to HTML to email, I do in emacs. I’ve tried to get Teams chat working but it just isn’t reliable so I use a browser for that.
Do you have any resources for your sql workflow in emacs? I use eMacs for everything else, but keep going back to dbeaver whenever I write SQL or interact with PostgreSQL. All the tutorials I’ve turned up seem to be doing simple things with small tables, rather than a more complex workflow. I’m sure there are ways to use emacs effectively for SQL but I just can’t find out how.
Not really. I write SQL in text files, manage them in version control (git these days, but in the past it has been mercurial or subversion, doesn't really matter) and execute them in psql via a SQLi postgres buffer (emacs comint mode that wraps a psql command shell in a buffer).
I haven't used (or heard of) dbeaver but took a quick look at it and I have tried other SQL tools that seem similar. Never really felt they gave me much.
I like keeping my tools very simple.
The main thing that I like is that it gives you nice table autocomplete as well as some nice metadata. As well as some connection management stuff. And it drives me mad because I am sure there must be a way to get the psql autocomplete to work in a buffer, but I have never managed it.
> Anybody have something better?
I wrote this to publish Org docs to S3 - https://github.com/EnigmaCurry/s3-publish.el - I wanted something extremely lightweight, not even wanting to commit things to git like I normally would and waiting for CI to build something. Uploading html directly to S3 means it gets published in <1s from push.
That's neat! For org, if it had an option to generate the HTML file name from slugifying the org file name instead of the salted hash, it could be fantastic for rapid lightweight blogging.
yes I used to use it too :) I think I've written three or four SSG since then haha.
Basically the .plan file revived (: [1]
John Carmack was well-known for keeping his development notes and other thoughts in a .plan file[2][3]
Aside: it saddens me a little how the simple idea of copying files onto a server is so many steps removed from modern "web framework" behemoths. I think some people genuinely don't know about the simpler older ways, and the pros and cons between them.
[1] https://unix.stackexchange.com/questions/122782/what-is-plan...
[2] https://garbagecollected.org/2017/10/24/the-carmack-plan/
Man, he was so productive.
https://github.com/oliverbenns/john-carmack-plan/blob/master...
frag bar
start profile on late frame
fixed relinking bug
improved prediction bounding
change weapon chooses supers first
ammo pictures on status bar
drop pain flash again and bound
tweak armor and spike damages
don't pick up equal armor
ceiling doors don't cause damage
demons crash when jumping
monsters need to use bsp clipping
need to save memory...
Fatal error: NaN impact time from entity
change armor damage
drop weapons
face to face with nailgun does no damage
+pointfile from cmdline doesn't work
conglomerate hunk printing
shoot triggers
missing a Z update on rockets sometimes?
firing after net games
negative scores on frag bar and frag board
world backpack and armor model
weapon bounce down
center look key
check change levels in high res mode
show ammo counts in single player
frag screen
radius damage should open secret doors
five point font on kills
rocket poke into walls
shoot open connected doors
gib bounce sound
I mean that 2000 lines, I assume, is going to only be that many lines because it will have 20-50k lines of dependencies under it.
It’s not a bad idea to understand the software you use. A matter of where you want to spend your time. Learning about the org-mode internals is also a valid choice.
Just one Google search away, also linked at the top of this page: https://orgmode.org/worg/org-contrib/babel/intro.html
Literate programming + code execution in org mode files. You can run code for most languages (all if you're willing to add in the hooks for those not supported out of the box). Turns any org file into a notebook (in the Maple, Mathematica, Jupyter, etc. sense), and since org files are easily exported into other file formats, you can execute the babel blocks in the exporting process to have an up-to-date execution of your program/notebook.
So we shouldn't ever post anything about what we find interesting or useful in tech/computing then?
What to write about then? Hobby - yes, your human, humans have hobbies so it’s not noteworthy. Food, travel… yes we know that we need to eat, yes we know we live on a planet with places on it.
Nothing would be noteworthy to post because everything is about obvious if we abstract it to some basic underlying principle.
This works if your code snippets generate relatively static output. Lately I often need to create animations, often interactive ones. See https://akkartik.name/debugUIs.html, for example.
In my life I've often switched to more manual tools when I notice that the more automated tool causes me to live within certain limitations. Sometimes it has taken me a decade to notice these limitations. Automation matters when I do something tens of times a day. But I publish a blog post once in tens of days. It feels worth some additional work to get a little more control and break out of ruts.