(redirected from Homepage)

Strona domowa

Witam na mojej prywatnej stronie internetowej!

[If this is all Polish to you, click here: English]

Uwaga: z oczywistych powodów nie mogę zagwarantować swojej nieomylności, choć staram się o zgodność tego, co piszę, z Prawdą. Jest również oczywiste, że nie gwarantuję takiej zgodności w przypadku komentarzy. Umieszczenie linku do strony spoza niniejszego serwisu nie musi oznaczać, że podzielam poglądy autora tej strony, a jedynie, że uważam ją za wartościową z takich czy innych powodów.

Marcin ‘mbork’ Borkowski

2026-07-27 Outlining in programs

One of the Emacs’ “killer apps” is Org mode, and one of the most iconic features of Org mode is visibility cycling. It is no wonder people (including me) want a similar feature in other modes.

Some time ago, I was writing a Node.js script which (as is usual in many programs) could be naturally divided into “sections” which I could then fold. I wrote about Hideshow mode, which provides such a thing for code blocks, but I wanted something operating on a slightly different level, grouping sets of functions to one foldable unit.

My first thought was that it would be great to be able to use pages for that. I imagined creating “headings” like this:

^L// This is a heading

(in case you don’t know, // is JS’ syntax for a line comment), and being able to press TAB on such a line to fold the whole page. I asked the Emacs devs whether it would be possible to extend Hideshow mode to support that (fully aware that it might be much more difficult than it sounds), and to my surprise, I learned that Emacs already has such a feature built in! It is called Outline minor mode, and turning the option outline-minor-mode-cycle on allows to use TAB to cycle (which is a prerequisite for me – I won’t risk breaking my fingers on the default C-c @ C-c and its ilk;-)). It has some more customization options (which see), but it turned out it has another drawback for me: the Eslint configuration used in the project I participate in does not like whitespace before comments. However, adding "ignoreComments": true to that rule fixed the problem.

However, Outline minor mode is neither the only nor the best solution to this issue. Folding in non-Org files is an itch many people have, and there are numerous third-party solutions to it. Evaluating all (or even a few) of them would be tedious and probably counterproductive. I generally tend to stick with built-in solutions for my Emacs needs – third-party packages, while often useful, have some drawbacks. This is definitely the case here – many folding packages are unmaintained, undocumented, bloated, do not support what I’d like, or several of the above;-). After a short research, I found two other solutions which seemed good candidates for my needs.

The first one is called Allout and is built into Emacs, too. It seems fairly feature-rich, but apparently does not support what I’d like the most – visibility cycling on TAB. I don’t care too much about its other features – this is the most basic thing I need, so I decided to look further.

The second one I couldn’t remember, but I do remember that a friend of mine recommended it, and after a short search I found his blog post where he did so. The tool is called outli and after a short experiment I think it’s the solution for me. It doesn’t seem abandoned, has no open issues, it has few but well-thought out features, and it has less than 400 lines of code (compare this to Allout’s 5000+!).

The main advantage of Outli over Outline minor mode is its keybindings. With the point on a headline, tab (un)folds it, p and n move the point to the previous and next headline, and b​/​f move the point to the previous/next headline on the same level. Pressing ? on a headline shows a buffer with a list of these and other keybindings.

The only thing that Outli lacks (in a sense) is an easy way to jump to the previous or next headline when the point is not on one of them. That is not a very big deal, though – Outli uses Outline minor mode under the hood, so you can always press C-c @ C-p or C-c @ C-n to do that. (If you happen to need that often, my advice would be to bind them to C-c C-3 C-p and C-c C-3 C-n instead to avoid the shift/control dance.)

That’s it for today, see you next week!

CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryOrgMode

Comments on this page

More...