(This is a follow-up of In-depth Review of Emacs tree-sitter integration .) As mentioned previously, Emacs doesn’t keep track of the line and column number in a buffer and passes dummy values to tree-sitter. This works fine most of the time, but breaks down when the grammar actually needs the column information for parsing, like Haskell . So now we have to have line and column tracking in Emacs.…
Unfortunately, there isn’t a single best algorithm that you can just learn and implement. There are many different algorithms, each with their own trade-offs and subtleties, none of which I found completely satisfactory. In this article, I hope to just introduce basic OT concepts in simple terms, and draw a rough picture of how it generally works, and point readers to materials for further…
A few month ago when working on tree-sitter indentation issues, I discovered a baseline indent rule for tree-sitter major modes in Emacs that covers 90% of the cases for C-like languages. So now we can replace lines and lines of indentation rule with just c-ts-common-baseline-indent-rule , and add a few override rules for the final adjustment. The best part is that it’s language-agnostic, so major…
The lower-level tree-sitter integration in Emacs is settling down, so I want to take some time to go over the design, both as a complement of the documentation 1 and as an (hopefully) entertaining reading for curious hackers. 1 Well, I’ve written extensive documentation in the source, but I guess an article could be easier to read? And I can include more tangent. The tree-sitter integration can be…
The story I’ve always been kind of a type enthusiast, and naturally I dream about making a typeface myself. So when Letterform Archive here in SF opened an online introductory type design course last summer, I snatched the opportunity and signed up. It was hella fun, and hella grind. I would start working on the font after I get off work and not stop until midnight. Kind of addicting,…
A year has passed since the release of Emacs 29 ; last time we added support for tree-sitter and several tree-sitter-based major modes. This time, there are more major modes, better support for multi-language modes, and more utility features. The first three sections introduce changes visible to end-users, the rest are for package and major mode developers. Derived mode check Now (derived-mode-p…
This is a guide for using webrtc-rs to create p2p connections that can go through NAT in Rust. This should be useful for anyone that wants to create a p2p /distributed program. I assume the reader knows about STUN, ICE 1 , websocket. I’ll brefly explain how WebRTC works. Reader also needs to know PEM, DER, X.509, and PKI in general, for the security side of things. I’m not an expert on WebRTC,…
During my time at UCSD, I enjoyed their systems courses greatly. It’d be a shame to let those wonderful things I learnt fade away from my memory. So I compiled my notes into this article. I hope this can be helpful to future me and entertaining for others. CSE 221 is the entry course, introducing students to reading papers and the essential systems papers. The cast of papers is pretty stable over…
I’m used to macOS’s key binding, that means for a desktop environment, I want three things: Caps lock act as Control System bindings are on the Command key (ie, the Windows key), specifically, Command+C/V for copy/paste In the terminal emulator, Command+C/V works as usual, and Ctrl+C/V sends respective control codes, as usual I’m a simple man, and this is all I want, but Thy Voice From Above hath…
Bonjour is Apple’s implementation of zeroconf networking. With Bonjour, you can plug in a printer into the local network and expect it to show up on computers in the network, without manually configuring anything. Linux’s implementation is Avahi. I recently needed to use Bonjour for some project and read some documentation. This is an article summarizing some concepts one needs to know in order to…
This guide gives you a starting point on writing a tree-sitter major mode. Remember, don’t panic and check your manuals! Build Emacs with tree-sitter You can either install tree-sitter by your package manager, or from source: git clone https://github.com/tree-sitter/tree-sitter.git cd tree-sitter make make install To build and run Emacs 29: git clone https://git.savannah.gnu.org/git/emacs.git -b…
Emacs’ release branch is now on complete feature freeze, meaning absolutely only bug fixes can happen on it. Now is a good time to talk about the state of tree-sitter in Emacs: what do you get in Emacs 29, what you don’t, and what would happen going forward. What’s in Emacs 29 From a pure user’s perspective, Emacs 29 just adds some new built-in major modes which look more-or-less identical to the…
Right now this site resides on archive.casouri.cat , I really love the .cat TLD. Alas, .cat was never meant for generic use and my site doesn't comply to its requirements, which is to use and promote Catalan language and culture. I don’t want to wake up one day recieving a take down notice, however slim the possibility is. Plus, the longer this site uses this domain, the more backlinks to it, the…
When searching for NAT traversal I found all these protocols but no one can tell me what do they essentially do to traverse NAT, surely not by magic? Turns out it’s conceptually very simple. What NAT traversal does is not really “punching holes” on the NAT, or delivering message through some tunnel, or some demotic portals, but to simply find the public address:port that can can reach me . If I’m…
Fontset? Fontset is a feature of Emacs that allows you to bundle together multiple fonts and use them as a single font, such that it covers more characters than a single font could have. For example, you can combine a Latin font, a Greek font and a Chinese font together. With fontsets, we can use different Unicode fonts for different faces. For example, serif Latin and Chinese font for a “serif”…
So I was installing a new OS on my desktop machine, and for some technical reasons I need to install the OS manually. That means typing in a console. I couldn’t help but wonder: what the font is it showing? I was typing in this Turns out the typeface isn’t even a typeface. It is a encoding that extends ASCII. It maps 8-bit patterns to characters. For example, 10000110 corresponds to “å”. According…
Today’s typeface isn’t really interesting in itself, but in the way I came across it. It’s a long story, are you ready? Ok, so I was reading assigned papers for my OS class, and I started on this one: The title immediately caught my attention: it’s a elegant, graceful font. So I clipped an image and searched on myfont.com, and it turns out to be ... Dutch 801 Headline. The end. I don’t know about…
Academica is a typeface I found out when reading aeon (a digital magazine in Science and Humanities). Academica is designed by Josef Týfa for scientific texts. The original design was cut and cast in metal in 1968, and in 2003, Týfa and František Štorm worked together to rework it for digital printing. Academica shares some similarities with Charter in tall x‑height and emphasize on legibility,…
Tree-sitter is a incremental parser that can provide a concrete syntax tree for the source code and is fast enough to parse on each key press. It has supported a wide range of languages, and support for more languages is on the way. I’ve been working on a integration of tree-sitter library into Emacs’ core. The integration consists of two parts, first the direct translate of tree-sitter’s API,…
If you like enamel pins, you know there are three types of backings: rubber, butterfly, and “secure/locking backing”. I grew up with butterfly backings, but nowadays, when you buy a enamel pin, more often than not, it comes with rubber backings. Rubber backings—they feel insecure at first sight, but then the difficulty to remove one from the packaging might give you a false sense of security. Let…