RSSAmplifier

Blog

Notes

archive.casouri.ccRSS feed ↗21 posts

Latest posts

Line-column tracking in Emacs for tree-sitter

(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.…

Practical Intro to Operational Transformation

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 Baseline Indentation Algorithm for C-like Languages Utilizing a Parse-tree

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…

In-depth Review of Emacs tree-sitter integration

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…

I Made a Font!

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,…

Tree-sitter Changes in Emacs 30

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…

Peer-to-peer Connection with WebRTC in Rust Using webrtc-rs

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,…

Classic Systems Papers: Notes for CSE 221

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…

Remap modifiers in Linux Desktop and Alacritty

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 Crash Course

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…

Tree-sitter Starter Guide

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…

Tree-sitter in Emacs 29 and Beyond

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…

This Site is Changing its Domain

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…

NAT traversal: STUN, TURN, ICE, what do they actually do?

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…

Using Fontsets in Emacs

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”…

Code Page 437

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…

Dutch 801 Headline

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

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,…

RFC: Emacs tree-sitter integration

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,…

Don’t Use Rubber Pin Backings on Backpacks

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…

自动处理网页里的全角引号和标点挤压

全角引号 在 Unicode 里 , 问号 、 叹号 、 各种括号都有全角半角两种版本 , 各自有独立的编码 ; 但因为莫名的原因 , 最常用的引号却不在此列 。 中英混排的时候想要正确显示直角和半角的引号就很头疼 ; 搞不好的话 , 中文里显示半角引号还不算太违和 , 英文里蹦出来一个全角引号就太丑了 。 CSS 没法自动区别什么时候用全角引号 、 什么时候用半角 , 只能靠标记 。 好在还没复杂到需要手工标记的地步 , 只要用程序检查引号前后的字是中文还是英文 , 以此标记全角还是半角 , 就基本不会出错 。 我现在的办法是这样 , 默认字体还是英文先中文后 : body { font-family: Charter, Source Han Serif CN, serif; } 需要全角的引号用 span 标签包起来 : <span…